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 the response as server-sent events (SSE) with Content-Type: text/event-stream. This enables progressive delivery: message deltas are sent as they are generated. Each event contains partial message content so you can render the response in real time.
Streaming Response Format:
text/event-streamdata: followed by JSONfinish_reasonWARNING
In the content array of the messages parameter, all media files use the same structure, whether they are images, videos, audio, or other documents:
type field is always "image_url"image_url field name stays the sameurl value changes, pointing to the corresponding media fileFor example, images, videos, audio, PDFs, and other documents all use { type: 'image_url', image_url: { url: '...' } }.
tools is an optional array that lets you define functions the model can call. The array can contain multiple objects. When using function calling, you can declare multiple functions in the array.
[
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather for a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City and state, for example: San Francisco, CA"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"]
}
},
"required": ["location"]
}
}
},
{
"type": "function",
"function": {
"name": "get_stock_price",
"description": "Get the current price for a given stock symbol",
"parameters": {
"type": "object",
"properties": {
"symbol": {
"type": "string",
"description": "Stock symbol, for example: AAPL"
}
},
"required": ["symbol"]
}
}
}
]
To use function calling in the prompt, create a tools array that contains one or more function declarations. Define functions with JSON (specifically, a selected subset of the OpenAPI schema format).
A single function declaration can include the following fields:
name (string, required): Unique function name (for example, get_weather_forecast, send_email). Use a descriptive name without spaces or special characters (underscore or camelCase).
description (string, optional but recommended): A clear, detailed explanation of what the function does. This is critical for the model to know when to call it. Be specific and provide examples when needed (for example, "Find movie theaters by location, optionally including movies currently playing.").
parameters (object, required): Defines the input parameters the function expects. Includes:
type (string): Overall data type; must be "object".properties (object): Lists each parameter, each with:
type (string): Parameter data type, such as string, integer, boolean, array.description (string): Explains the purpose and format of the parameter. Provide examples and constraints (for example, "City and state, such as 'San Francisco, CA', or a ZIP code such as '95616'.").enum (array, optional): If values come from a fixed set, list allowed values with enum instead of only describing them in text. This improves accuracy (for example, "enum": ["daylight", "cool", "warm"]).required (array): An array of strings listing parameter names required for the function to run.
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-4-carbon-openai/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": "medium"
}'{
"id": "chatcmpl-c90c370251f24fd4b2d85a052e38f47a",
"object": "chat.completion",
"created": 1791213382,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "OK"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 6,
"completion_tokens": 1,
"total_tokens": 97,
"completion_tokens_details": {
"reasoning_tokens": 0
}
},
"credits_consumed": 0.01
}