Skip to main content
POST
/
gemini-3.1-pro
/
v1
/
chat
/
completions
Chat Completions
curl --request POST \
  --url https://api.kie.ai/gemini-3.1-pro/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data @- <<EOF
{
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "What's 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"
}
EOF
{
  "id": "chatcmpl-example-123",
  "object": "chat.completion",
  "created": 1741569952,
  "model": "gemini-3.1-pro",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "hello,can i help you?",
        "refusal": null,
        "annotations": []
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "service_tier": "default"
}

Streaming Support

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:
  • Content-Type: text/event-stream
  • Each event line starts with data: followed by JSON
  • Events contain incremental message deltas
  • Final event indicates completion with finish_reason

Multimodal

Supports text and image inputs

Real-time Search

Google Search grounding enabled

Streaming

Server-sent events support

Flexible Roles

Multiple message roles supported

Google Search Parameter

Enable Google Search grounding for real-time information retrieval via the tools parameter:
{
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "googleSearch"
      }
    }
  ]
}

Unified Media File Format

In the messages parameter’s content array, whether it’s images, videos, audio, or other document types, all media files use the same format structure:
  • The type field is always "image_url"
  • The image_url field name remains unchanged
  • The only thing that changes is the url value, which points to the corresponding media file address
For example: images, videos, audio, PDFs, and other documents all use the same { type: 'image_url', image_url: { url: '...' } } structure.
{
  "id": "chatcmpl-example-123",
  "object": "chat.completion",
  "created": 1741569952,
  "model": "gemini-3.1-pro",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "hello,can i help you?",
        "refusal": null,
        "annotations": []
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "service_tier": "default"
}

Authorizations

Authorization
string
header
required

All APIs require authentication via Bearer Token.

Get API Key:

  1. Visit API Key Management Page to get your API Key

Usage: Add to request header: Authorization: Bearer YOUR_API_KEY

Note:

  • Keep your API Key secure and do not share it with others
  • If you suspect your API Key has been compromised, reset it immediately in the management page

Body

application/json
messages
object[]
required

Array of message objects. Each message has a role and content.

Unified Media File Format:

In the content array, whether it's images, videos, audio, or other document types, all media files use the same format structure:

  • The type field is always "image_url"
  • The image_url field name remains unchanged
  • The only thing that changes is the url value, which points to the corresponding media file address

For example: images, videos, audio, PDFs, and other documents all use the same { type: 'image_url', image_url: { url: '...' } } structure.

Minimum array length: 1
stream
boolean
default:true

If set to true, partial message deltas will be sent as server-sent events. Defaults to true.

tools
object[]

Optional array of tools the model can call. For Google Search grounding, use: [{"type": "function", "function": {"name": "googleSearch"}}] - This enables real-time information retrieval via Google Search. When you need up-to-date information, news, or current events, include this tool in your request.

include_thoughts
boolean
default:true

Whether to include thinking process. If set to true, thoughts will be included in the response; otherwise they will not appear. Defaults to true.

reasoning_effort
enum<string>
default:high

Reasoning effort. Low effort responds faster, high effort responds slower but solves more complex problems. Defaults to "high".

Available options:
low,
high

Response

Request successful. Returns standard chat completion format.

id
string

Unique identifier for the chat completion

Example:

"chatcmpl-example-123"

object
string

Object type

Example:

"chat.completion"

created
integer<int64>

Unix timestamp when the completion was created

Example:

1677652288

model
string

Model name

Example:

"gemini-3.1-pro"

choices
object[]

Array of completion choices

usage
object