curl --request POST \
--url https://kaienapi.com/v1beta/models/{model}:streamGenerateContent \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": [
{
"parts": [
{
"text": "介绍这个接口"
}
]
}
]
}
'{}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}Gemini streamGenerateContent 基础接口
Gemini 原生流式协议兼容接口。通过 payload 支持文本、图片生成/编辑、结构化输出、工具、搜索、URL Context、Code Execution、文档/音频/视频理解。
请求格式
路径和 generateContent 一致,只是返回为流式内容。请求体仍使用 Gemini 原生 contents、generationConfig、tools 等字段。
读取结果
客户端按流式事件逐段消费候选内容。文本增量、工具调用和多模态结果可能出现在不同事件片段中,按事件结构解析,不要只拼接纯文本。
POST
/
v1beta
/
models
/
{model}
:streamGenerateContent
curl --request POST \
--url https://kaienapi.com/v1beta/models/{model}:streamGenerateContent \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": [
{
"parts": [
{
"text": "介绍这个接口"
}
]
}
]
}
'{}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}