Skip to main content
POST
Create Message
Authenticate with your Perplexity API key. Both 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.
Honored: 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 use the Anthropic envelope:
An overloaded model returns HTTP 429 with type overloaded_error and a Retry-After header. Requests that fail before producing output are not billed.

Authorizations

Authorization
string
header
required

Your Perplexity API key.

Body

application/json

Request body for POST /router/v1/messages.

model
string
required

Public model slug, e.g. anthropic/claude-sonnet-4-5.

max_tokens
integer
required

Maximum number of tokens to generate. Required by the Messages API.

Required range: 1 <= x <= 2147483647
messages
object[]
required
system

System prompt as plain text or an array of text blocks.

temperature
number<float>
Required range: 0 <= x <= 1
top_p
number<float>
Required range: 0 <= x <= 1
stop_sequences
string[]
stream
boolean

When true, respond with server-sent events.

tools
object[]
tool_choice
object
metadata
object
thinking
object

Accepted by the spec, rejected by validation (no budget mapping).

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.

id
string
required
type
enum<string>
required
Available options:
message
role
enum<string>
required
Available options:
assistant
model
string
required
content
object[]
required
stop_reason
enum<string> | null
required
Available options:
end_turn,
max_tokens,
stop_sequence,
tool_use,
pause_turn,
refusal,
model_context_window_exceeded
stop_sequence
string | null
required
usage
object
required