Chat completions.
POST · /v1/chat/completions — full OpenAI-compatible chat endpoint. Streaming, vision, tool calling, batching, and the Anoman response annotations all on a single route.
Quick example
Make your first request
Identical request shape to the OpenAI /v1/chat/completions. The only difference is the base URL.
Request body
Parameters
| Field | Type | Req? | Description |
|---|---|---|---|
model | string | ✓ | Model slug from our catalog. See GET /v1/models. |
messages | array | ✓ | Conversation history. Each item has role (system / user / assistant / tool) and content (string or array for vision). |
max_tokens | integer | — | Cap on completion tokens. Default = the model context budget. |
temperature | number | — | Sampling temperature (0–2). Default 1.0. Set 0 for deterministic-ish output. |
top_p | number | — | Nucleus sampling (0–1). Use with or instead of temperature. |
stream | boolean | — | Stream tokens via SSE. See streaming guide. |
tools | array | — | Function definitions the model may call. Same shape as OpenAI. |
tool_choice | string / object | — | "auto" (default), "none", or a specific function. |
response_format | object | — | {"type": "json_object"} for JSON mode. |
seed | integer | — | Deterministic sampling seed. Not all upstream providers honor it. |
stop | string / array | — | Up to 4 stop sequences. |
presence_penalty | number | — | −2 to 2. Encourages new topics. |
frequency_penalty | number | — | −2 to 2. Discourages repetition. |
user | string | — | Opaque end-user identifier — surfaces in traces for per-user attribution. |
metadata | object | — | Free-form key/value tags (max 16 keys) attached to the trace. |
Anoman request headers
Optional headers
| Header | Values | Effect |
|---|---|---|
x-anoman-realtime | 1 / true | Force realtime even if the customer key prefers batch. |
x-anoman-prefer-batch | 1 / true | Opt this request into batch routing (cheaper, longer SLA). |
x-anoman-no-cache | 1 / true / yes | Skip the response cache for this request. |
anoman-session-id | string | Group requests into an agent session — surfaces in the dashboard Sessions view. |
anoman-agent-id | string | Identifier for the agent making the call (e.g. support-bot-v2). |
200 response
Response body
Identical to the OpenAI response shape, plus an _anoman extension with our guardrail results, routing decisions, cache status, and cost accounting.
Want to use a strict OpenAI SDK that rejects unknown fields? Set request header x-anoman-strip-extension: 1 and the _anoman block is removed from the body (data still reaches headers + traces).
Response headers
What every 200 carries
| Header | Example | Description |
|---|---|---|
x-anoman-region | ID | Region that processed the request. |
x-anoman-cache | none / provider / response | Cache hit type. |
x-anoman-guardrail-injection | pass score=0.02 | Prompt injection scan result. |
x-anoman-guardrail-pii | pass redacted 2 entities | PII detector result. |
x-anoman-rate-limit-rpm | 120 | RPM burst-guard cap for your tier. |
x-anoman-rate-remaining-rpm | 86 | Requests left in the current minute. |
x-anoman-burst-active | true / (absent) | Whether a burst credit is currently multiplying your limits. |
See rate limits for the full list of rate headers.
Vision
Image input
Wrap user content as an array with type: text and type: image_url entries. The URL can be public or a base64-encoded data URL. Only vision-capable models accept image input — see the residency badge + /models Modality filter to find them.
Data URLs. Max 5 MB per image. PNG, JPEG, and WebP accepted. Animated GIFs are downsampled to a single frame.
Tool calling
Functions / tools
Pass tool definitions and the model may emit a tool_calls message instead of free text. The Anoman policy enforcement can deny specific tool names per API key — see the policies page in the dashboard.
Batch routing
Opt into batch (cheaper, longer SLA)
Set x-anoman-prefer-batch: true and the same endpoint returns a 202 with a poll_url. Batch jobs cost ~50% less for non-interactive workloads (data analysis, overnight extraction, eval runs).
Full batch lifecycle in /v1/batch endpoint reference.
Streaming
Set stream:true
Full wire format + mid-stream error handling in the streaming guide.
Errors
Possible non-200 responses
- 400 —
model_not_found,context_length_exceeded,vision_not_supported - 401/403 — auth failures (see authentication) or guardrail blocks (
prompt_injection,tool_denied,content_violation) - 402 —
budget_exceeded - 429 — rate-limit or inflight cap (see rate limits)
- 503/504 — provider issues (retryable)
Full reference at /docs/errors.
Try it from the playground.
3-pane compare with live streaming output.