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.
[
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"]
}
},
"required": ["location"]
}
}
},
{
"type": "function",
"function": {
"name": "get_stock_price",
"description": "Get the current stock price for a given symbol",
"parameters": {
"type": "object",
"properties": {
"symbol": {
"type": "string",
"description": "The stock symbol, e.g. AAPL"
}
},
"required": ["symbol"]
}
}
}
]
When implementing function calling in your prompt, you need to create a tools array containing one or more function declarations. You can define functions using JSON (specifically, a selected subset of OpenAPI schema format).
A single function declaration can include the following parameters:
name (string, required): The unique name of the function (e.g., get_weather_forecast, send_email). Use descriptive names without spaces or special characters (use underscores or camelCase).
description (string, optional but recommended): A clear and detailed description of what the function does and its purpose. This is crucial for the model to understand when to use the function. Be specific and provide examples when necessary (e.g., "Find movie theaters by location, with an option to also find movies currently showing at those theaters.").
parameters (object, required): Defines the input parameters expected by the function. Contains:
type (string): Specifies the overall data type, must be "object".properties (object): Lists individual parameters, each with:
type (string): The parameter's data type, such as string, integer, boolean, array.description (string): Description of the parameter's purpose and format. Provide examples and constraints (e.g., "City and state, e.g. 'San Francisco, CA' or a postal code like '95616'.").enum (array, optional): If parameter values come from a fixed set, use enum to list allowed values rather than just describing them in the description. This helps improve accuracy (e.g., "enum": ["daylight", "cool", "warm"]).required (array): An array of strings listing the parameter names required for the function to run.
The response_format parameter is an optional JSON Schema object that defines the structure of the response. When provided, the model will generate responses that conform to this schema.
string: For text valuesnumber: For floating-point numbersinteger: For whole numbersboolean: For true/false valuesobject: For structured data with key-value pairsarray: For lists of itemsnull: To allow null values, add "null" to the type array (e.g., {"type": ["string", "null"]})For object values:
properties: Object mapping property names to their schema definitionsrequired: Array of required property namesadditionalProperties: Controls whether properties not in properties are allowedFor string values:
enum: List of specific possible string values for classificationformat: Specifies string syntax (e.g., date-time, date, time)For number and integer values:
enum: List of specific possible numeric valuesminimum: Inclusive minimum valuemaximum: Inclusive maximum valueFor array values:
items: Schema definition for all array elementsprefixItems: List of schemas for the first N items (tuple-like structures)minItems: Minimum number of items in the arraymaxItems: Maximum number of items in the array
{"type":"json_object"} is also supported.
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-2.5-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",
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "structured_output",
"strict": true,
"schema": {
"type": "object",
"properties": {
"response": {
"type": "string"
}
}
}
}
}
}'{
"id": "chatcmpl-example-123",
"object": "chat.completion",
"created": 1677652288,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "string"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 50,
"total_tokens": 60
}
}