Prismatic API/Docs/Gemini generateContent
Documentation

Gemini generateContent

POST /v1/models/{model}:generateContent and POST /v1beta/models/{model}:generateContent expose a Gemini-compatible public API for clients that already send contents and generationConfig payloads.

Use it when

  • Your app or SDK already speaks the Gemini generateContent request shape.
  • You want to send contents with parts instead of OpenAI messages or Anthropic messages.
  • You need Gemini-style generationConfig, JSON mode or response schema fields.

Endpoints

POST/v1/models/{model}:generateContent
Gemini generateContent v1

Gemini-compatible non-streaming generation. The {model} path segment is the Prismatic public model ID.

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

Beta-version Gemini-compatible non-streaming generation for clients that target the v1beta Gemini surface.

POST/v1/models/{model}:streamGenerateContent
Gemini streamGenerateContent v1

Gemini-compatible SSE streaming. Do not set stream: true on generateContent; use this endpoint instead.

POST/v1beta/models/{model}:streamGenerateContent
Gemini streamGenerateContent v1beta

Beta-version Gemini-compatible SSE streaming for clients that target the v1beta Gemini surface.

Code examples

curl https://api.prismaticapi.com/v1/models/claude-sonnet-4-6:generateContent \
  -H "x-goog-api-key: $PRISMATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          { "text": "Write a one-line launch announcement." }
        ]
      }
    ],
    "generationConfig": {
      "maxOutputTokens": 120,
      "temperature": 0.2
    }
  }'
curl -N https://api.prismaticapi.com/v1beta/models/claude-sonnet-4-6:streamGenerateContent \
  -H "x-goog-api-key: $PRISMATIC_API_KEY" \
  -H "Accept: text/event-stream" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          { "text": "Stream a three-step deployment checklist." }
        ]
      }
    ],
    "generationConfig": {
      "maxOutputTokens": 240
    }
  }'
curl https://api.prismaticapi.com/v1/models/claude-sonnet-4-6:generateContent \
  -H "Authorization: Bearer $PRISMATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          { "text": "Return a JSON object with an answer and confidence." }
        ]
      }
    ],
    "generationConfig": {
      "responseMimeType": "application/json",
      "responseSchema": {
        "type": "object",
        "properties": {
          "answer": { "type": "string" },
          "confidence": { "type": "number" }
        },
        "required": ["answer", "confidence"]
      }
    }
  }'

Parameters

  • {model} path segment (required) — Public model ID returned by GET /v1/models.
  • contents (array, required) — Conversation turns with Gemini role and parts.
  • generationConfig (object, optional) — Supports fields such as maxOutputTokens, temperature, topP, stopSequences, responseMimeType, responseSchema and _responseJsonSchema when the selected provider route supports them.
  • stream: true is not valid on generateContent; call streamGenerateContent for streaming.

Authentication

  • Gemini routes accept Authorization: Bearer pa_YOUR_KEY.
  • They also accept x-api-key: pa_YOUR_KEY and x-goog-api-key: pa_YOUR_KEY for Gemini-style clients.
  • Use your Prismatic customer API key; never expose upstream provider keys.

Streaming

  • streamGenerateContent returns server-sent events with data: {GenerateContentResponse} chunks.
  • Clients should consume the stream to completion so final usage metadata can be captured for billing.
  • Final chunks include Gemini-style usageMetadata when upstream usage is available.

JSON mode and structured outputs

  • Set generationConfig.responseMimeType to application/json for JSON mode.
  • Use generationConfig.responseSchema or _responseJsonSchema for structured outputs.
  • Prismatic validates schemas before upstream routing; a field listed in required must also exist in properties.
  • Invalid schemas return invalid_response_format_schema; unsupported provider routes return unsupported_response_format before an upstream call is made.

Routing notes

  • Native Gemini provider routes receive the Gemini payload directly.
  • OpenAI-compatible or Anthropic-compatible providers can be used only when the Gemini request is transposable.
  • Requests that require native Gemini features without a compatible provider route return unsupported_gemini_feature.