Skip to main content

Request Body

string
required
ID of the model to use. See Models for available options.
array
required
A list of messages comprising the conversation.Each message object contains:
  • role (string): system, user, or assistant
  • content (string | array): The message content
When content is an array, AI Sonar supports structured multimodal blocks for compatible models:
  • text: { "type": "text", "text": "..." }
  • image: { "type": "image_url", "image_url": { "url": "https://..." } }
  • video: { "type": "video_url", "video_url": { "url": "https://..." } }
  • audio: { "type": "audio_url", "audio_url": { "url": "https://..." } }
For multimodal production traffic, prefer public https URLs. AI Sonar will translate these media blocks into the provider-specific request shape required by the selected model.
number
default:"1"
Sampling temperature between 0 and 2. Higher values make output more random.
integer
Maximum number of tokens to generate.
boolean
default:"false"
If true, partial message deltas will be sent as SSE events.
object
Options for streaming. Set include_usage: true to receive token usage in stream chunks.
number
default:"1"
Nucleus sampling parameter. We recommend altering this or temperature, not both.
number
default:"0"
Number between -2.0 and 2.0. Positive values penalize repeated tokens.
number
default:"0"
Number between -2.0 and 2.0. Positive values penalize tokens already in the text.
string | array
Up to 4 sequences where the API will stop generating tokens.
array
A list of tools the model may call (function calling).
string | object
Controls how the model uses tools. Options: auto, none, required, or a specific tool object.
boolean
default:"true"
Whether to enable parallel function calling. Set to false to call functions sequentially.
integer
Maximum tokens for the completion. Alternative to max_tokens, useful for newer reasoning-enabled model families.
string
Reasoning effort for reasoning-enabled models. Options: low, medium, high.
integer
Random seed for deterministic sampling.
integer
default:"1"
Number of completions to generate (1-128).
boolean
Whether to return log probabilities.
integer
Number of top log probabilities to return (0-20). Requires logprobs: true.
integer
Top-K sampling parameter (for Anthropic/Gemini models).
object
Response format specification. Use {"type": "json_object"} for JSON mode. Treat {"type": "json_schema", "json_schema": {...}} as a best-effort path that depends on the selected model and routed behavior.
object
Modify the likelihood of specified tokens appearing. Map token IDs (as strings) to bias values from -100 to 100.
string
A unique identifier representing your end-user for abuse monitoring.

Response

string
Unique identifier for the completion.
string
Always chat.completion.
integer
Unix timestamp of when the completion was created.
string
The model used for completion.
array
List of completion choices.Each choice contains:
  • index (integer): Index of the choice
  • message (object): The generated message
  • finish_reason (string): Why the model stopped (stop, length, tool_calls)
object
Token usage statistics.
  • prompt_tokens (integer): Tokens in the prompt
  • completion_tokens (integer): Tokens in the completion
  • total_tokens (integer): Total tokens used

Multimodal Example