Skip to main content
POST
Gemini streamGenerateContent
用于 Gemini 的流式文本生成和增量事件输出。
  • 官方常见鉴权方式是 x-goog-api-key: {API_KEY},也支持查询参数 API Key
  • 请求体结构与 generateContent 基本一致,核心仍是 contents
  • 返回内容是事件流而不是一次性 JSON,客户端需要按顺序拼接增量片段
  • 停止原因和安全信息可能在后续 chunk 中才完整出现

授权

x-goog-api-key
string
header
必填

路径参数

model
string
必填

Gemini model name.

示例:

"gemini-2.5-pro"

请求体

application/json
contents
object[]
必填
systemInstruction
object
generationConfig
object
safetySettings
object[]
tools
object[]

响应

Successful Gemini streaming response

The response is of type string.