---
title: "Generate content with the Google Gemini protocol"
method: POST
path: "/v1beta/models/{model}:generateContent"
tags: ["Gemini"]
---

# Generate content with the Google Gemini protocol

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

## Request

- Base URL: `https://api.sandbase.ai`
- URL: `https://api.sandbase.ai/v1beta/models/{model}:generateContent`
- Auth: one of:
  - API key in header `x-goog-api-key`
  - HTTP bearer
  - API key in query parameter `key`

Accepts a Google Gemini GenerateContent request and returns a Gemini-compatible response. A bare model name,
such as gemini-3.5-flash, is normalized to the SandBase catalog name google/gemini-3.5-flash. This endpoint
also accepts x-goog-api-key and the key query parameter for Google SDK compatibility, although headers are safer.
Models with a native passthrough mapping preserve provider-defined request and response fields, including image
response modalities. Other mappings may use the translated capability subset documented in the schema below.

## Path parameters

- `model` string, required

## Request body

- GeminiGenerateContentRequest: Google Gemini GenerateContent request. Native passthrough mappings preserve provider-defined fields; translated mappings use the documented capability subset.
  - `contents` GeminiContent[]
    - `role` 'user' | 'model'
    - `parts` object[]
  - `systemInstruction` GeminiContent
    - `role` 'user' | 'model'
    - `parts` object[]
  - `generationConfig` object
    - `temperature` number
    - `topP` number
    - `topK` integer
    - `maxOutputTokens` integer
    - `stopSequences` string[]
    - `candidateCount` integer: Translated mappings accept only 1 when supplied; native passthrough mappings preserve the provider request.
    - `seed` integer
    - `presencePenalty` number
    - `frequencyPenalty` number
    - `responseMimeType` 'text/plain' | 'application/json' | 'text/x.enum'
    - `responseSchema` object
    - `responseModalities` string[]: Native image mappings support provider image modalities. Other translated mappings may support TEXT only.
    - `thinkingConfig` object
  - `tools` object[]
  - `toolConfig` object
  - `safetySettings` object[]
  - `cachedContent` string: Passed through when the selected provider supports Gemini context caching.

## Response `200`

Gemini GenerateContent response

- GeminiGenerateContentResponse
  - `candidates` object[]
    - `content` GeminiContent
      - `role` 'user' | 'model'
      - `parts` object[]
    - `finishReason` string
    - `index` integer
    - `safetyRatings` object[]
  - `usageMetadata` object
    - `promptTokenCount` integer
    - `candidatesTokenCount` integer
    - `totalTokenCount` integer
    - `cachedContentTokenCount` integer
    - `thoughtsTokenCount` integer
  - `promptFeedback` object
  - `modelVersion` string
  - `responseId` string

## Other responses

- `400`: Invalid JSON or a request rejected by the selected native or translated mapping
- `401`: Missing, invalid, revoked, or expired API key
- `402`: Organization balance and credit are exhausted
- `403`: API Key spending limit reached, organization disabled, or upstream permission rejected
- `404`: Model, method, or upstream resource not found
- `429`: Provider rate limit exceeded
- `500`: Prediction lifecycle or provider error
- `502`: Upstream response failed or could not be processed
- `503`: Routing failed or all provider candidates were unavailable
- `504`: Upstream request timed out

---

[API](https://skmtc.dev/sandbase/apis/sandbase-api.md) · [All operations](https://skmtc.dev/sandbase/apis/sandbase-api/llms.txt) · [OpenAPI document](https://skmtc.dev/sandbase/apis/sandbase-api/revisions/d40df2467ba2?raw)
