Skip to content

Google Gemini GenerateContent

POST/v1beta/models/{model}:generateContent

Send a native Gemini request and receive a Gemini-compatible response. Use streamGenerateContent for streaming.

Path parameters

stringmodelrequired

Bare Google model name, such as gemini-3.5-flash. SandBase resolves it as google/{model}.

Request body

Optional<array>contents

Gemini conversation contents made of role and parts.

Optional<object>systemInstruction

Text system instruction in Gemini Content form.

Optional<object>generationConfig

Sampling, output length, structured output, and thinking settings.

Optional<array>tools

Function declarations or supported Gemini built-in tool configuration.

Optional<object>toolConfig

Gemini function-calling policy.

Optional<array>safetySettings

Gemini safety categories and thresholds.

Optional<string>cachedContent

Gemini cached-content resource passed through when supported.

Authentication ​

Google-compatible requests can carry the SandBase API key in x-goog-api-key, Authorization: Bearer …, or the key query parameter, in that priority order. Prefer a header: query-string credentials can appear in proxy logs and browser history.

Streaming ​

Replace the method suffix with :streamGenerateContent. Without a query parameter, SandBase returns Google-compatible response objects as a streamed JSON array. Add ?alt=sse for Server-Sent Events:

bash
curl -N -X POST \
  "https://api.sandbase.ai/v1beta/models/gemini-3.5-flash:streamGenerateContent?alt=sse" \
  -H "x-goog-api-key: $SANDBASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contents":[{"role":"user","parts":[{"text":"Write a short greeting."}]}]}'

Native image generation ​

These image models have dedicated native GenerateContent mappings:

For these mappings, SandBase forwards the request and response payloads without converting them through Chat Completions. This preserves image parts, response modalities, and provider-defined fields. Use the bare model name in the URL; for example, google/gemini-3.1-flash-image becomes gemini-3.1-flash-image in the path.

Routing and translation boundaries ​

SandBase selects only providers that support the requested native Gemini protocol. If the selected model has no compatible native mapping, the request fails instead of falling back to a provider with a different protocol.

Models that use the translated GenerateContent path support text, function calls and responses, inline image/* data, and public HTTP(S) image references. That translated path rejects unsupported inline MIME types, private Google Files or gs:// references, multiple candidates, and unsupported response modalities with a Google-style 400 INVALID_ARGUMENT response. The image-generation mappings listed above use raw passthrough and are not subject to those translation-only limits; validate the returned media fields according to the selected provider's response.