メインコンテンツへスキップ
POST
/
v1beta
/
models
/
{model}
:streamGenerateContent
Gemini streamGenerateContent
curl --request POST \
  --url https://maas.apigo.ai/v1beta/models/{model}:streamGenerateContent \
  --header 'Content-Type: application/json' \
  --header 'x-goog-api-key: <api-key>' \
  --data '
{
  "contents": [
    {
      "role": "<string>",
      "parts": [
        {
          "text": "<string>",
          "inlineData": {
            "mimeType": "<string>",
            "data": "<string>"
          },
          "fileData": {
            "mimeType": "<string>",
            "fileUri": "<string>"
          }
        }
      ]
    }
  ],
  "systemInstruction": {
    "role": "<string>",
    "parts": [
      {
        "text": "<string>",
        "inlineData": {
          "mimeType": "<string>",
          "data": "<string>"
        },
        "fileData": {
          "mimeType": "<string>",
          "fileUri": "<string>"
        }
      }
    ]
  },
  "generationConfig": {
    "temperature": 123,
    "topP": 123,
    "maxOutputTokens": 123,
    "responseMimeType": "<string>"
  },
  "safetySettings": [
    {
      "category": "<string>",
      "threshold": "<string>"
    }
  ],
  "tools": [
    {}
  ]
}
'
"data: {\"candidates\":[{\"content\":{\"parts\":[{\"text\":\"这里是第一段\"}]}}]}\n\n"

Documentation Index

Fetch the complete documentation index at: https://docs.apigo.ai/llms.txt

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

このエンドポイントは、Gemini ストリーミング テキストの生成と増分イベント出力に使用します。
  • 一般的な認証パターンは x-goog-api-key: {API_KEY} ですが、クエリ文字列 API キーもサポートされています
  • リクエスト構造は generateContent とほぼ同じで、コア フィールドは contents です。
  • 応答は、最終的な JSON ペイロードではなく、イベント ストリームです。
  • 終了状態と安全性のメタデータは、後のチャンクでのみ完成する可能性があります

承認

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.