跳转到主要内容
Gemini generateContent 接口的流式版本。返回服务器发送事件(Server-Sent Events)。

路径参数

model
string
必填
模型名称(例如,gemini-2.5-progemini-2.5-flash)。

查询参数

key
string
API 密钥(标头身份验证的替代方案)。

请求正文

生成内容 相同。

响应

返回一个 JSON 对象流,每个对象包含部分响应内容。
curl -X POST "https://api.lemondata.cc/v1beta/models/gemini-2.5-pro:streamGenerateContent?key=sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "parts": [{"text": "Tell me a story"}]
      }
    ]
  }'
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {"text": "Once upon a time"}
        ]
      }
    }
  ]
}