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
contentswithpartsinstead of OpenAImessagesor Anthropicmessages. - You need Gemini-style
generationConfig, JSON mode or response schema fields.
Endpoints
POST
/v1/models/{model}:generateContentGemini generateContent v1
Gemini-compatible non-streaming generation. The {model} path segment is the Prismatic public model ID.
POST
/v1beta/models/{model}:generateContentGemini generateContent v1beta
Beta-version Gemini-compatible non-streaming generation for clients that target the v1beta Gemini surface.
POST
/v1/models/{model}:streamGenerateContentGemini streamGenerateContent v1
Gemini-compatible SSE streaming. Do not set stream: true on generateContent; use this endpoint instead.
POST
/v1beta/models/{model}:streamGenerateContentGemini 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 byGET /v1/models.contents(array, required) — Conversation turns with Geminiroleandparts.generationConfig(object, optional) — Supports fields such asmaxOutputTokens,temperature,topP,stopSequences,responseMimeType,responseSchemaand_responseJsonSchemawhen the selected provider route supports them.stream: trueis not valid ongenerateContent; callstreamGenerateContentfor streaming.
Authentication
- Gemini routes accept
Authorization: Bearer pa_YOUR_KEY. - They also accept
x-api-key: pa_YOUR_KEYandx-goog-api-key: pa_YOUR_KEYfor Gemini-style clients. - Use your Prismatic customer API key; never expose upstream provider keys.
Streaming
streamGenerateContentreturns server-sent events withdata: {GenerateContentResponse}chunks.- Clients should consume the stream to completion so final usage metadata can be captured for billing.
- Final chunks include Gemini-style
usageMetadatawhen upstream usage is available.
JSON mode and structured outputs
- Set
generationConfig.responseMimeTypetoapplication/jsonfor JSON mode. - Use
generationConfig.responseSchemaor_responseJsonSchemafor structured outputs. - Prismatic validates schemas before upstream routing; a field listed in
requiredmust also exist inproperties. - Invalid schemas return
invalid_response_format_schema; unsupported provider routes returnunsupported_response_formatbefore 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.