Overview
This endpoint provides native Anthropic Messages API compatibility. Use this for Claude models with features like extended thinking. This endpoint keeps the native Anthropic contract.messages must be an array of user / assistant messages, system belongs in the top-level system field, and max_tokens is required. If your payload uses OpenAI roles such as system, developer, or tool inside messages, send it to /v1/chat/completions instead.
Base URL for Anthropic SDK:
https://api.aisonar.dev (no /v1 suffix)Request Headers
string
required
Your AI Sonar API key. Alternative to Bearer token.
string
required
Anthropic API version. Use
2023-06-01.Request Body
string
required
Claude model ID (e.g.,
claude-sonnet-4-6 or claude-opus-4-6).array
required
Array of message objects with
role and content.For Claude models with vision support, content can be either a plain string or an array of content blocks. To send images, use structured content blocks rather than placing image URLs or Base64 strings directly into plain text.Example content blocks:- text block:
{ "type": "text", "text": "Describe this image" } - image block via URL:
{ "type": "image", "source": { "type": "url", "url": "https://example.com/image.jpg" } } - image block via Base64:
{ "type": "image", "source": { "type": "base64", "media_type": "image/png", "data": "iVBORw0KGgoAAA..." } }
integer
required
Maximum tokens to generate.
string
System prompt (separate from messages array).
number
default:"1"
Sampling temperature (0-1).
boolean
default:"false"
Enable streaming responses.
object
Extended thinking configuration (Claude Opus 4.5).
type(string):"enabled"to enablebudget_tokens(integer): Token budget for thinking
array
Available tools for the model.
object
How the model should use tools. Options:
auto, any, tool (specific tool).number
Nucleus sampling parameter. Use either temperature or top_p, not both.
integer
Only sample from the top K options for each token.
array
Custom stop sequences that will cause the model to stop generating.
object
Metadata to attach to the request for tracking purposes.
Response
string
Unique message identifier.
string
Always
message.string
Always
assistant.array
Array of content blocks (text, thinking, tool_use).
string
Model used.
string
Why generation stopped (
end_turn, max_tokens, tool_use).object
Token usage with
input_tokens and output_tokens.Vision Input Example
For Claude models with vision support, place images insidemessages[].content as structured image blocks.
Extended Thinking Example
Anthropic Message Batches
AI Sonar now exposes the native Anthropic Message Batches flow alongside/v1/messages.
Available routes:
POST /v1/messages/batchesGET /v1/messages/batchesGET /v1/messages/batches/:message_batch_idGET /v1/messages/batches/:message_batch_id/resultsPOST /v1/messages/batches/:message_batch_id/cancelDELETE /v1/messages/batches/:message_batch_id
- Use the same AI Sonar API key plus Anthropic-native headers.
- If batch items reference
file_id, also includeanthropic-beta: files-api-2025-04-14. - Batch jobs keep Anthropic-native request/response shapes while AI Sonar tracks billing status for reconciliation.