v1

latestOpenAPI 3.1.0MIT2026-07-2614271305.9 KB
Content Generation

Gemini Content Generation (All Models)

Select the Gemini text model to call via {model} in the path (see the reference table for the model parameter for all available values).

  • Uses the Google native API format and returns conversation content synchronously
  • Plain text / multimodal input: mixed text + image / audio / video input
  • Streaming: replace generateContent in the path with streamGenerateContent (append ?alt=sse to receive SSE)

Model specs and differences

  • Sampling parameters temperature / topP / topK: consistent across the entire Gemini 3.x series, custom values do not affect the output; topK is dropped outright by the gateway (not forwarded upstream), and a temperature / topP value outside the valid range returns a 400.
  • Thinking control: the Gemini 3.x series uses thinkingConfig.thinkingLevel (see the thinkingLevel parameter for the levels supported and the default of each model); the Gemini 2.5 series uses thinkingConfig.thinkingBudget (an integer, 0=off). The two are mutually exclusive.
  • Function calling: for Gemini 3.x, the FunctionResponse must echo back the id and name matching the corresponding FunctionCall, otherwise the request errors.
  • Last-turn role: the role of the last message must not be model (Gemini 3.5+ will error).
  • Token limits: gemini-3.6-flash / gemini-3.5-flash-lite have a context window of 1,048,576 and a maximum output of 65,536; other models follow their respective specs.
post/v1beta/models/{model}:generateContent

Path parameters

model'gemini-3.6-flash' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-lite-preview' | 'gemini-3-pro-preview' | 'gemini-3-flash-preview' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-lite' required
Example:gemini-3.6-flash

Select the Gemini text model to call:

Model IDSeriesPositioning
gemini-3.6-flash3.6 FlashMulti-step orchestration / code refactoring / general reasoning
gemini-3.5-flash3.5 FlashGeneral-purpose Flash
gemini-3.5-flash-lite3.5 Flash-LiteLow cost / high throughput / lightweight agent
gemini-3.1-pro-preview3.1 Pro (Preview)Advanced reasoning
gemini-3.1-pro-preview-customtools3.1 Pro · CustomToolsAdvanced reasoning + custom tools
gemini-3.1-flash-lite-preview3.1 Flash-Lite (Preview)Low cost
gemini-3-pro-preview3.0 Pro (Preview)Advanced reasoning
gemini-3-flash-preview3.0 Flash (Preview)General-purpose Flash
gemini-2.5-pro2.5 ProAdvanced reasoning
gemini-2.5-flash2.5 FlashGeneral-purpose Flash
gemini-2.5-flash-lite2.5 Flash-LiteLow cost

Request body

{"stackTrail":"components:schemas:GenerationConfig","oasType":"schema","type":"unknown","description":"Referenced by this API but not published in the vendor's docs pages."}
{"stackTrail":"components:schemas:Content","oasType":"schema","type":"unknown","description":"Referenced by this API but not published in the vendor's docs pages."}
toolsobject[]

List of tools the model can call, such as function calling or code execution

toolConfigobject

Tool calling configuration (optional)

safetySettingsobject[]

Safety settings list (optional)

cachedContentstring

Cached content name, in the form cachedContents/{cachedContent}

Response

Content generated successfully

Response format description:

  • When using the generateContent endpoint, returns GenerateContentResponse (returns complete response at once)
  • When using the streamGenerateContent endpoint, returns StreamGenerateContentResponse (streaming response, returns content in chunks)
OR
StreamGenerateContentResponse required

Stream response chunk

Intermediate chunk:

Example response

{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "Hello! I'm glad to introduce myself.\n\nI'm a large language model trained and developed by Google..."
          }
        ]
      },
      "finishReason": "STOP"
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 4,
    "candidatesTokenCount": 611,
    "totalTokenCount": 2422,
    "thoughtsTokenCount": 1807,
    "promptTokensDetails": [
      {
        "modality": "TEXT",
        "tokenCount": 4
      }
    ]
  },
  "modelVersion": "gemini-3.6-flash",
  "responseId": "l-LoaPu0BPmo1dkP6ZPHiQc"
}