跳转到主要内容

Documentation Index

Fetch the complete documentation index at: https://docs.tokenlab.sh/llms.txt

Use this file to discover all available pages before exploring further.

Gemini generateContent 接口的流式版本。返回服务器发送事件(Server-Sent Events)。

路径参数

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

查询参数

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

请求正文

生成内容 相同。 流式请求请省略 generationConfig.candidateCount 或保持为 1;更大的值会被拒绝,而不会静默丢弃额外候选结果。

响应

返回一个 JSON 对象流,每个对象包含部分响应内容。
curl -X POST "https://api.tokenlab.sh/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"}
        ]
      }
    }
  ]
}