stream: true 时,API 将以服务器发送事件(SSE)的形式返回响应,Content-Type 为 text/event-stream。这允许渐进式响应交付,消息增量会在生成时逐步发送。每个事件包含部分消息内容,使您能够在应用程序中实时显示响应。text/event-streamdata: 开头,后跟 JSONfinish_reason 指示完成messages 参数的 content 数组中,无论是图像、视频、音频还是其他文档类型,所有媒体文件都使用相同的格式结构:type 字段始终为 "image_url"image_url 字段名称保持不变url 值,它指向相应的媒体文件地址{ type: 'image_url', image_url: { url: '...' } } 结构。tools 参数是一个可选数组,允许您定义模型可以调用的函数。数组可以包含多个对象。使用函数调用时,可以在数组中定义多个函数。response_format 参数是一个可选的 JSON Schema 对象,定义响应的结构。提供此参数时,模型将生成符合此架构的响应。response_format 和函数调用是互斥的:不能在同一个请求中同时使用 response_format 和函数调用。请根据您的需求选择其中一种。curl --location --request POST 'https://api.kie.ai/gemini-2.5-pro/v1/chat/completions' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "这张图片里有什么?"
},
{
"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",
"properties": {
"response": {
"type": "string"
}
}
}
}'{
"id": "chatcmpl-example-123",
"object": "chat.completion",
"created": 1677652288,
"model": "gemini-2.5-pro",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "string"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 50,
"total_tokens": 60
}
}