Chuyển đến nội dung chính

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.

Phiên bản streaming của endpoint Gemini generateContent. Trả về Server-Sent Events.

Tham số đường dẫn

model
string
bắt buộc
Tên model (ví dụ: gemini-2.5-pro, gemini-2.5-flash).

Tham số truy vấn

key
string
API key (phương thức thay thế cho xác thực qua header).

Nội dung yêu cầu

Tương tự như Generate Content. Với yêu cầu streaming, hãy bỏ qua generationConfig.candidateCount hoặc giữ giá trị là 1; giá trị lớn hơn sẽ bị từ chối thay vì âm thầm bỏ các ứng viên bổ sung.

Phản hồi (Response)

Trả về một luồng (stream) các đối tượng JSON, mỗi đối tượng chứa một phần của phản hồi.
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"}
        ]
      }
    }
  ]
}