WARNING
⚠️ Chat only
This model currently supports chat requests only and has not yet been adapted for agent use. Connecting it to an agent may cause request errors or unexpected results.
When stream: true is set in the request, the API returns responses as server-sent events (SSE) with Content-Type: text/event-stream. This allows for progressive response delivery, where message deltas are sent incrementally as they are generated. Each event contains partial message content, enabling real-time display of responses in your application.
Streaming Response Format:
text/event-streamdata: followed by JSONfinish_reason
To simplify integration, all media types (Images, Videos, Audio, or Documents) in the messages array share the exact same JSON structure:
type field is fixed as "image_url"image_url key name remains unchanged for all file typesurl value points to your specific media fileThe tools parameter is an optional array that allows you to define functions the model can call. The array can contain multiple objects. When using function calling, you can define multiple functions in the array.
{
"type": "function",
"function": {
"name": "googleSearch"
}
}
This enables real-time information retrieval via Google Search.
Errors are returned with HTTP 200 and a JSON body {"code": , "msg": ""}. Check code (200 = success) before reading choices/candidates.
curl --location 'https://api.kie.ai/gemini-3.1-pro/v1/chat/completions' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image?"
},
{
"type": "image_url",
"image_url": {
"url": "https://file.aiquickdraw.com/custom-page/akr/section-images/1759055072437dqlsclj2.png"
}
}
]
}
],
"tools": [
{
"type": "function",
"function": {
"name": "googleSearch"
}
}
],
"stream": true,
"include_thoughts": true,
"reasoning_effort": "high"
}'{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Hello! How can I help you today?",
"role": "assistant"
}
}
],
"created": 1768283309,
"credits_consumed": 0.27,
"id": "chatcmpl-********************z6IaTP6H",
"object": "chat.completion",
"usage": {
"completion_tokens": 383,
"completion_tokens_details": {
"audio_tokens": 0,
"text_tokens": 0,
"reasoning_tokens": 374
},
"prompt_tokens": 1,
"total_tokens": 384
}
}