Create Message
Send a conversation to any Gateway model using the Anthropic Messages schema. Set stream: true to receive server-sent events. Authenticate with your Perplexity API key — both Authorization: Bearer and the Anthropic SDK’s default x-api-key header are accepted.
Authorization: Bearer and the Anthropic SDK’s default x-api-key header are accepted, so the stock SDK api_key parameter works unchanged. No anthropic-version header is required.Parameter support
Parameter support
model, max_tokens (required), messages, system, stream, temperature, top_p, stop_sequences, thinking (only {"type": "disabled"}), tools, tool_choice.Accepted but not forwarded to the model: metadata.Rejected with a 400: top_k, service_tier, thinking with {"type": "enabled"}, cache_control on content blocks or tools, plus any unrecognized top-level field. Tools require a non-empty description.Errors
Errors
429 with type overloaded_error and a Retry-After header. Requests that fail before producing output are not billed.Authorizations
Your Perplexity API key.
Body
Request body for POST /router/v1/messages.
Public model slug, e.g. anthropic/claude-sonnet-4-5.
Maximum number of tokens to generate. Required by the Messages API.
1 <= x <= 2147483647System prompt as plain text or an array of text blocks.
0 <= x <= 10 <= x <= 1When true, respond with server-sent events.
- Option 1
- Option 2
- Option 3
- Option 4
Accepted by the spec, rejected by validation (no budget mapping).
- Option 1
- Option 2
Response
Successful response. JSON for non-streaming requests; a text/event-stream of typed events (message_start through message_stop) when stream is true.
Non-streaming response body and the message_start payload.
message assistant - Option 1
- Option 2
- Option 3
end_turn, max_tokens, stop_sequence, tool_use, pause_turn, refusal, model_context_window_exceeded