Skip to main content
POST
Create Chat Completion
The Orchestrator API accepts the OpenAI Chat Completions schema, with a defined subset of parameters. Requests using an unsupported parameter fail with a 400 naming the parameter.
Honored: model, routing (only with model: "perplexity/auto"), messages, stream, stream_options.include_usage, max_completion_tokens, max_tokens, temperature, top_p, stop, reasoning_effort, service_tier (auto, default, flex, priority), response_format (text, json_schema, json_object), tools, tool_choice (including allowed_tools), parallel_tool_calls, prompt_cache_key, prompt_cache_options, and message-part prompt_cache_breakpoint fields.Accepted but not forwarded to the model: user, safety_identifier, metadata.Accepted only at their default values: n (1), logprobs (false), store (false), presence_penalty (0), frequency_penalty (0).Rejected with a 400: seed, logit_bias, top_logprobs, functions (use tools), function_call (use tool_choice), modalities, audio, prediction, web_search_options, moderation, verbosity, prompt_cache_retention (use prompt_cache_options.ttl), stream_options.include_obfuscation set to true, plus any unrecognized top-level field.Notes: When reasoning_effort is omitted, the model’s default applies; supported values and defaults vary by model. response_format.json_schema always runs in strict mode. Assistant messages and streamed deltas can include reasoning_content; replay it in an assistant message to preserve reasoning context across requests. A tool’s description is optional. temperature accepts 0 to 1 on Anthropic models and 0 to 2 on other models. prompt_cache_options.ttl accepts 30m or 1h; 1h works on Anthropic models only.
Set stream: true to receive chat.completion.chunk objects as server-sent events. A successful stream ends with data: [DONE]. With stream_options: {"include_usage": true}, the last chunk before [DONE] has an empty choices array and reports usage for the whole request.Errors detected before streaming begins, such as an unavailable model, return a normal JSON error response with the matching HTTP status.
Errors use the OpenAI envelope:
type is invalid_request_error for validation errors (400) and for an unavailable model (404), invalid_api_key for a missing or invalid API key (401), rate_limit_error for 429 (rate limited or model overloaded; retry after the Retry-After interval), and server_error for 5xx. Requests that fail before producing output are not billed.

Authorizations

Authorization
string
header
required

Your Perplexity API key.

Body

application/json
messages
(Developer message · object | System message · object | User message · object | Assistant message · object | Tool message · object | Function message · object)[]
required

The conversation so far, as an array of message objects with role and content. The leading system or developer message is applied as the system prompt.

Minimum array length: 1
model
string
required

A model id from the Orchestrator catalog, or perplexity/auto to select a model for each request. With Auto, omit routing to use the default policy or provide an inline routing object.

Example:

"perplexity/kimi-k3"

metadata
object | null

Accepted for SDK compatibility; not forwarded to the model.

temperature
number | null
default:1

Controls randomness in token selection. Anthropic models accept 0 to 1; other models accept 0 to 2. Higher values produce more varied output. Some models reject requests that set both temperature and top_p.

Required range: 0 <= x <= 2
Example:

1

top_p
number | null
default:1

Cumulative probability cutoff for nucleus sampling, 0 to 1. Some models reject requests that set both top_p and temperature.

Required range: 0 <= x <= 1
Example:

1

user
string
deprecated

Accepted for SDK compatibility; not forwarded to the model.

Example:

"user-1234"

safety_identifier
string | null

Accepted for SDK compatibility; not forwarded to the model.

Maximum string length: 64
Example:

"safety-identifier-1234"

prompt_cache_key
string | null

Stable key grouping related requests to improve prompt-cache hit rates.

Example:

"prompt-cache-key-1234"

service_tier
enum<string> | null
default:auto

Processing tier for the request. flex halves token rates on supported models; auto and default are equivalent.

Available options:
auto,
default,
flex,
priority
prompt_cache_options
Prompt cache options · object

Prompt-cache settings. ttl accepts 30m or 1h; 1h works on Anthropic models only.

reasoning_effort
enum<string> | null

How much reasoning the model performs before answering, on models that support it. Supported values and the default vary by model, and an unsupported value returns a 400.

Available options:
none,
minimal,
low,
medium,
high,
xhigh,
max
max_completion_tokens
integer | null

Upper bound on generated tokens for this request, including reasoning tokens. Some Anthropic models with reasoning can report more completion tokens than this value.

response_format
Text · object

Output format. Use type json_schema for strict structured output or json_object for JSON mode.

stream
boolean | null
default:false

When true, tokens are sent as server-sent events as they are generated, terminated by data: [DONE].

stop
default:<|endoftext|>

One stop string, or an array of at most 4. On models that honor stop sequences, output ends at the first match. Some models accept the field without applying it.

Example:

"\n"

max_tokens
integer | null
deprecated

Legacy alias of max_completion_tokens.

stream_options
object | null

Streaming options. Only allowed when stream is true.

tools
(Function tool · object | Custom tool · object)[]

Function definitions the model can invoke. A tool's description is optional.

tool_choice

Controls whether the model may call tools, requires a specific tool, or limits selection with allowed_tools.

Available options:
none,
auto,
required
parallel_tool_calls
boolean
default:true

Set to false to allow at most one tool call per turn. Defaults to true, which allows, but does not require, several calls.

routing
object

Inline routing for model: "perplexity/auto" only. Omit this field or set it to null to use the default policy. The serialized routing object must be at most 16384 bytes. Models must be available in the Orchestrator catalog. Routes incompatible with the request are excluded; if the default model is incompatible, the first compatible route model becomes the default. The request fails if no model is compatible.

Response

Successful response. JSON for non-streaming requests; a text/event-stream of chat completion chunks terminated by data: [DONE] when stream is true.

id
string
required

Identifier of this completion.

choices
object[]
required

The completion. Contains exactly one choice.

created
integer<unixtime>
required

Creation time as a Unix timestamp in seconds.

model
string
required

The model that served the request. With perplexity/auto, this is the selected model, not perplexity/auto. Billing uses the served model's rates.

object
enum<string>
required

Always "chat.completion".

Available options:
chat.completion
service_tier
enum<string> | null
default:auto

The processing tier that served the request, or null when none is reported.

Available options:
auto,
default,
flex,
priority
system_fingerprint
string
deprecated
usage
object

Token accounting for the request.

moderation
object