Skip to main content
AI Sonar supports the native Google Gemini API shape when the model details advertise Gemini requests and a same-protocol route is currently available. A model or provider name alone does not imply that this route is available, and native Gemini requests never fall back through Chat Completions. Google ProtoJSON accepts both lowerCamelCase JSON names and original proto snake_case field names. AI Sonar preserves camelCase, snake_case, and mixed requests without normalizing them. If both spellings of one field are present, AI Sonar forwards both without merging them or assigning a local precedence. Unknown fields are also forwarded best-effort; the selected service decides whether they are supported.

Path Parameters

string
required
Model name (e.g., gemini-2.5-pro, gemini-3.5-flash).

Query Parameters

string
API key (alternative to header authentication).

Authentication

Gemini endpoints support multiple authentication methods:
  • ?key=YOUR_API_KEY query parameter
  • x-goog-api-key: YOUR_API_KEY header
  • Authorization: Bearer YOUR_API_KEY header

Request Body

array
required
Conversation contents.Each content object contains:
  • role (string): user or model
  • parts (array): Content parts. AI Sonar supports:
    • text parts: { "text": "..." }
    • inline media parts: inlineData / inline_data
    • URL-based file parts: fileData / file_data
AI Sonar does not lowercase roles, infer MIME types, rewrite Base64 data, inject image configuration, or apply a local Gemini tool whitelist. AI Sonar-owned File and Cache resource IDs are the exception: they are ownership-checked and resolved to the service resource created for the same API key.
object
System instruction for the model.
object
Generation configuration:
  • temperature (number): Sampling temperature
  • topP (number): Nucleus sampling probability
  • topK (integer): Top-K sampling
  • maxOutputTokens (integer): Maximum output tokens
  • stopSequences (array): Stop sequences
  • candidateCount (integer): Requested candidate count; support is determined by the selected service.
  • responseModalities (array): Requested output modalities for compatible native routes.
  • responseMimeType (string): Output MIME type such as text/plain or application/json.
  • responseSchema (object): JSON schema for structured output when responseMimeType requests JSON.
  • thinkingConfig / thinking_config (object): Thinking budget options for compatible models.
array
Safety filter settings.
Every lowerCamelCase field shown above may also use its official proto snake_case spelling, for example system_instruction, generation_config, safety_settings, tool_config, cached_content, file_data.file_uri, and inline_data.mime_type.

Supported native methods

The current legacy Gemini surface includes model list/get, generateContent, streamGenerateContent, countTokens, embedContent, and batchEmbedContents. Gemini Interactions and Live are not currently exposed.

Response

array
Generated content candidates.
object
Token usage information.

Vision Input Example

For Gemini multimodal requests, place media inside contents[].parts[] using either inline bytes or URL-based file references. Supported media categories in the public Gemini contract:
  • image
  • audio
  • video
For inline media, use either inlineData or inline_data and pass Base64-encoded file bytes. For URL-based media, use either fileData or file_data and pass a public https URL.

Video Input Example

Audio Input Example

Image Input Example

Use inline image bytes:
Use an image URL:

Audio Input Example

Use an audio URL:

Video Input Example

Use a video URL: