POST
/
v1beta
/
models
/
gemini-2.5-pro:streamGenerateContent
curl -X POST "https://api.example.com/v1beta/models/gemini-2.5-pro:streamGenerateContent?key=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "parts": [{"text": "1+2+3+4+5+....+999?"}],
        "role": "user"
      }
    ],
    "generationConfig": {
      "temperature": 1,
      "topP": 1,
      "thinkingConfig": {
        "includeThoughts": true,
        "thinkingBudget": 26240
      }
    }
  }'
{
  "candidates": [
    {
      "content": {
        "parts": [
          {"thought": "Let me calculate the sum..."},
          {"text": "The sum is 499500."}
        ],
        "role": "model"
      },
      "finishReason": "STOP"
    }
  ]
}
Official documentation: https://ai.google.dev/gemini-api/docs/text-generation
Streaming text generation with thinking process using Google Gemini 2.5 Pro model.

Request Parameters

key
string
required
API key.
contents
array
required
Conversation content array.
systemInstruction
object
System instruction configuration.
safetySettings
array
Safety settings array. Configurable categories include:
  • HARM_CATEGORY_HATE_SPEECH
  • HARM_CATEGORY_SEXUALLY_EXPLICIT
  • HARM_CATEGORY_HARASSMENT
  • HARM_CATEGORY_DANGEROUS_CONTENT
  • HARM_CATEGORY_CIVIC_INTEGRITY
generationConfig
object
Generation configuration.
  • temperature (number): Sampling temperature
  • topP (number): Nucleus sampling parameter
  • thinkingConfig (object): Thinking configuration
    • includeThoughts (boolean): Whether to include thinking process
    • thinkingBudget (integer): Thinking budget (maximum 26240)
curl -X POST "https://api.example.com/v1beta/models/gemini-2.5-pro:streamGenerateContent?key=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "parts": [{"text": "1+2+3+4+5+....+999?"}],
        "role": "user"
      }
    ],
    "generationConfig": {
      "temperature": 1,
      "topP": 1,
      "thinkingConfig": {
        "includeThoughts": true,
        "thinkingBudget": 26240
      }
    }
  }'
{
  "candidates": [
    {
      "content": {
        "parts": [
          {"thought": "Let me calculate the sum..."},
          {"text": "The sum is 499500."}
        ],
        "role": "model"
      },
      "finishReason": "STOP"
    }
  ]
}