Chat
OpenAI-compatible chat completions endpoint.
Supports both streaming and non-streaming responses. Handles reasoning content from otari providers.
Authentication modes:
Master key + user field: Use specified user (must exist)
API key + user field: Use specified user (must exist)
API key without user field: Use the shared "default" user
Enter your API key here (sent as Otari-Key header).
A unique value, such as a UUID, that makes a non-streaming request safe to retry. A retry with the same key and body returns the original response, request ID and cost without calling the provider or billing again. A retry while the original is still running is answered 409 with Retry-After. Reusing a key for a different body is refused with 422. Ignored for streaming requests and on a deployment without OTARI_SECRET_KEY, which encrypts the stored response.
Tags for cost attribution, as comma-separated key=value pairs (agent=bug-fix,run=1234), for a client that cannot set the body's metadata. Keys and values are percent-decoded, so either may carry an encoded , or =, and a non-ASCII character must be encoded. Whitespace around a pair is ignored, and a repeated header is read as one list. The bounds are the body's: up to 16 pairs, keys up to 64 characters and values up to 512, counted after merging with the body's tags, which win on the same key. Never forwarded to the provider.
OpenAI-compatible chat completion request.
The completion-param fields are derived from any-llm's CompletionParams
(see _schema_derive) so the schema cannot silently drop a param any-llm
forwards. Fields below either tighten a derived field (messages,
response_format), add gateway-internal behavior (mcp_servers,
mcp_server_ids, guardrails, tools_header,
max_tool_iterations) that is stripped before the request is forwarded
upstream, or restate a derived field unchanged to document it
(max_completion_tokens), which is only worth doing where the wire
contract is not guessable from the field itself.
Upper bound on generated tokens. OpenAI's current name for the cap max_tokens used to carry; either field is accepted, and this one wins when a request sends both.
autoPossible values: A stable identifier for the end user behind the request, used as the tag the provider's end-user identifier is derived from. Wins over user for that, and is never sent upstream. The dashboard's Playground ignores it.
Optional caller-supplied label for a run, experiment or conversation, which names the session the request's trace is grouped under. Stripped before the request is forwarded upstream to the provider.
falseOptional override for the lead-in that the gateway prepends before the per-tool hint block in the system message. Useful for expressing global tool-selection policy (e.g. 'prefer MCP tools over code_execution'). Falls back to OTARI_TOOLS_HEADER env, then to the built-in default.
Successful Response
Validation Error
POST /api/v1/chat/completions HTTP/1.1
Otari-Key: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 1082
{
"frequency_penalty": 1,
"guardrails": [
{
"mode": "monitor",
"on": [
"input"
],
"on_unavailable": "block",
"profile": "text",
"url": "text",
"validate_kwargs": {
"ANY_ADDITIONAL_PROPERTY": "anything"
}
}
],
"logit_bias": {
"ANY_ADDITIONAL_PROPERTY": 1
},
"logprobs": true,
"max_completion_tokens": 1,
"max_tokens": 1,
"max_tool_iterations": 1,
"mcp_server_ids": [
"123e4567-e89b-12d3-a456-426614174000"
],
"mcp_servers": [
{
"allowed_tools": [
"text"
],
"authorization_token": "text",
"name": "text",
"purpose_hint": "text",
"url": "text"
}
],
"messages": [
{
"ANY_ADDITIONAL_PROPERTY": "anything"
}
],
"metadata": {
"ANY_ADDITIONAL_PROPERTY": "anything"
},
"model": "text",
"n": 1,
"parallel_tool_calls": true,
"presence_penalty": 1,
"prompt_cache_key": "text",
"reasoning_effort": "auto",
"response_format": {
"ANY_ADDITIONAL_PROPERTY": "anything"
},
"safety_identifier": "text",
"seed": 1,
"service_tier": "text",
"session_label": "text",
"stop": "text",
"stream": false,
"stream_options": {
"ANY_ADDITIONAL_PROPERTY": "anything"
},
"temperature": 1,
"tool_choice": "text",
"tools": [
{
"ANY_ADDITIONAL_PROPERTY": "anything"
}
],
"tools_header": "text",
"top_logprobs": 1,
"top_p": 1,
"user": "text"
}No content
Last updated
Was this helpful?
