generateContent REST
contract verbatim, so the google-generativeai Python SDK and the
@google/generative-ai JS SDK work unchanged — flip the base URL and
your apiKey. Cross-vendor models (Claude, GPT, DeepSeek, Doubao) are
translated to Gemini shape under the hood.
When to use
Pick this endpoint when you want:- Drop-in for
google-generativeai/ Gemini SDK clients - Gemini-only features like
responseSchemawith the Gemini-flavoured JSON schema, orsafetySettings - Code paths already structured around
contents[].parts[](different from OpenAI / Anthropicmessages)
/v1/messages; for OpenAI shape, /chat/completions.
Request
{model} in the path is the model slug (e.g. gemini-3-5-flash). For streaming, use the sibling :streamGenerateContent path — see Streaming below.
Headers
Body
Response
Response fields
Accounting headers
Same envelope as every other endpoint:Streaming
Use the sibling path:streamGenerateContent:
alt=sse) with each frame carrying a partial candidates payload:
alt=sse, the response is a JSON array of frames — the SDK default.)
Tool calling
Gemini’stools[].functionDeclarations[] shape. Round-trip via two requests:
Round 1 — tool offered
functionCall part:
args is a structured object here, not a JSON string (unlike OpenAI’s tool_calls.arguments).
Round 2 — tool result returned
Multimodal (image / audio parts)
Inline a base64-encoded image as a part on the user message:fileData.fileUri (the file must be publicly reachable over HTTPS). Audio (audio/wav, audio/mp3) and video (video/mp4) parts work the same way on multimodal-capable models.
Cross-model routing
The{model} path segment accepts any ByteSpike catalog model — the gateway translates the Gemini shape to each model’s native protocol:
responseSchemaconstraint requires the model to support structured outputs; otherwise returns 400unsupported_feature.safetySettingsare only honored on Gemini models — silently ignored on Claude / GPT / DeepSeek (those have their own safety stacks).usageMetadatafield names are Gemini-shape regardless of the model.
GET /v1/models. Pricing per model: bytespike.ai/pricing.
Errors
All non-2xx responses are free. Body shape matches Gemini’s error envelope:SDK example
google-generativeai Python SDK, base URL pointed at ByteSpike: