---
title: "Gemini Content Generation (All Models)"
method: POST
path: "/v1beta/models/{model}:generateContent"
tags: ["Content Generation"]
---

# Gemini Content Generation (All Models)

`POST /v1beta/models/{model}:generateContent`

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.

## 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

## Request body

- GenerateContentRequest
  - `contents` Content[], required — List of conversation contents, supports multi-turn dialogue and multimodal input
    - unknown
  - `generationConfig` unknown
  - `systemInstruction` unknown
  - `tools` object[] — List of tools the model can call, such as function calling or code execution
  - `toolConfig` object — Tool calling configuration (optional)
  - `safetySettings` object[] — Safety settings list (optional)
  - `cachedContent` string — Cached content name, in the form cachedContents/{cachedContent}

## Response `200`

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)

- union
  - GenerateContentResponse
    - `candidates` Candidate[] — List of candidate responses
      - `content` ContentResponse
        - `role` 'model' — Response role
        - `parts` TextPart[] — Response content parts
          - `text` string, required — Text content
      - `finishReason` 'STOP' | 'MAX_TOKENS' | 'SAFETY' | 'RECITATION' | 'OTHER' — Finish reason
      - `index` integer — Candidate index
      - `safetyRatings` object[], nullable — Safety ratings
    - `promptFeedback` PromptFeedback
      - `safetyRatings` object[], nullable — Prompt safety ratings
    - `usageMetadata` UsageMetadata — Usage statistics
      - `promptTokenCount` integer — Number of tokens in input
      - `candidatesTokenCount` integer — Number of tokens in output
      - `totalTokenCount` integer — Total number of tokens
      - `thoughtsTokenCount` integer — Number of reasoning tokens
      - `promptTokensDetails` TokenDetail[] — Detailed input token information (by modality)
        - `modality` 'TEXT' | 'IMAGE' | 'AUDIO' | 'VIDEO' — Content modality type
        - `tokenCount` integer — Number of tokens for this modality
    - `modelVersion` string — Model version
    - `responseId` string — Response ID
  - StreamGenerateContentResponse — Stream response chunk **Intermediate chunk**:

## Other responses

- `400` — Invalid request parameters
- `401` — Unauthorized, invalid or expired token
- `402` — Insufficient quota, recharge required
- `403` — Access denied
- `404` — Resource not found
- `413` — Request body too large, file too large
- `429` — Rate limit exceeded
- `500` — Internal server error
- `502` — Upstream service error
- `503` — Service temporarily unavailable

---

[API](https://skmtc.dev/evolink/apis/get-credits-usage-api.md) · [All operations](https://skmtc.dev/evolink/apis/get-credits-usage-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/evolink/get-credits-usage-api/revisions/88edb0ec881f/schema)
