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_KEYquery parameterx-goog-api-key: YOUR_API_KEYheaderAuthorization: Bearer YOUR_API_KEYheader
Request Body
array
required
Conversation contents.Each content object contains:
role(string):userormodelparts(array): Content parts. AI Sonar supports:- text parts:
{ "text": "..." } - inline media parts:
inlineData/inline_data - URL-based file parts:
fileData/file_data
- text parts:
object
System instruction for the model.
object
Generation configuration:
temperature(number): Sampling temperaturetopP(number): Nucleus sampling probabilitytopK(integer): Top-K samplingmaxOutputTokens(integer): Maximum output tokensstopSequences(array): Stop sequencescandidateCount(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 astext/plainorapplication/json.responseSchema(object): JSON schema for structured output whenresponseMimeTyperequests JSON.thinkingConfig/thinking_config(object): Thinking budget options for compatible models.
array
Safety filter settings.
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 insidecontents[].parts[] using either inline bytes or URL-based file references.
Supported media categories in the public Gemini contract:
- image
- audio
- video
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.