WARNING
⚠️ 仅支持对话调用
该模型目前仅支持对话调用,暂未适配 Agent 场景。若将其接入 Agent 使用,可能会出现请求报错或结果异常。
Gemini 端点使用 streamGenerateContent 返回流式结果。函数调用结果会出现在 candidates[].content.parts[].functionCall 中。
Streaming Response Format:
parts[].functionCall 中返回thoughtSignature 和 usage 信息体现contents 进行标准对话。googleSearch 启用联网搜索。functionDeclarations 进行函数调用。generationConfig.thinkingConfig 控制思考配置。contents 作为主要输入字段。tools.googleSearch 开启 Google Search。tools.functionDeclarations 定义可调用函数。generationConfig.thinkingConfig 控制思考输出与 thinking level。鉴权:请求头携带 Authorization: Bearer YOUR_API_KEY。
错误以 HTTP 200 返回,响应体为 {"code": , "msg": "<原因>"}。读取 choices/candidates 前请先判断 code(200 为成功)。
curl --location 'https://api.kie.ai/gemini/v1/models/gemini-3-8-flash:streamGenerateContent' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"stream": true,
"contents": [
{
"role": "user",
"parts": [
{
"text": "What is the weather in Beijing today?"
}
]
}
],
"tools": [
{
"functionDeclarations": [
{
"name": "get_weather_forecast",
"description": "Get the weather forecast for a given location",
"parameters": {
"type": "OBJECT",
"properties": {
"location": {
"type": "STRING",
"description": "The city name, e.g. Beijing"
}
},
"required": [
"location"
]
}
}
]
}
],
"generationConfig": {
"thinkingConfig": {
"includeThoughts": true,
"thinkingLevel": "high"
}
}
}'{
"candidates": [
{
"content": {
"role": "model",
"parts": [
{
"text": "Hello! How can I help you today?"
}
]
},
"finishReason": "STOP"
}
],
"usageMetadata": {
"promptTokenCount": 5,
"candidatesTokenCount": 9,
"thinkingTokenCount": 0,
"totalTokenCount": 14
},
"credits_consumed": 0.01
}