Skip to main content
POST
/
v1beta
/
models
/
{model}
:streamGenerateContent
Gemini streamGenerateContent
curl --request POST \
  --url http://sandbox.mintlify.com/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"
Use this endpoint for Gemini streaming text generation and incremental event output.
  • The common auth pattern is x-goog-api-key: {API_KEY}, though query-string API keys are also supported
  • The request structure is mostly the same as generateContent, with contents as the core field
  • The response is an event stream rather than one final JSON payload
  • Finish state and safety metadata may only become complete in later chunks

Authorizations

x-goog-api-key
string
header
required

Path Parameters

model
string
required

Gemini model name.

Example:

"gemini-2.5-pro"

Body

application/json
contents
object[]
required
systemInstruction
object
generationConfig
object
safetySettings
object[]
tools
object[]

Response

Successful Gemini streaming response

The response is of type string.