For the complete documentation index, see llms.txt. This page is also available as Markdown.

Chat

Chat Completions

post

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

Authorizations
Otari-KeystringRequired

Enter your API key here (sent as Otari-Key header).

Header parameters
Idempotency-Keystring · nullableOptional

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.

Otari-Tagsstring · nullableOptional

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.

Body

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.

frequency_penaltynumber · nullableOptional
logprobsboolean · nullableOptional
max_completion_tokensinteger · nullableOptional

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.

max_tokensinteger · nullableOptional
max_tool_iterationsinteger · min: 1 · max: 25 · nullableOptional
mcp_server_idsstring · uuid[] · max: 50 · nullableOptional
modelstringRequired
ninteger · nullableOptional
parallel_tool_callsboolean · nullableOptional
presence_penaltynumber · nullableOptional
prompt_cache_keystring · nullableOptional
reasoning_effortstring · enum · nullableOptionalDefault: autoPossible values:
safety_identifierstring · nullableOptional

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.

seedinteger · nullableOptional
service_tierstring · nullableOptional
session_labelstring · max: 255 · nullableOptional

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.

stopany of · nullableOptional
stringOptional
or
string[]Optional
streambooleanOptionalDefault: false
temperaturenumber · nullableOptional
tool_choiceany of · nullableOptional
stringOptional
or
tools_headerstring · max: 4000 · nullableOptional

Optional 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.

top_logprobsinteger · nullableOptional
top_pnumber · nullableOptional
userstring · nullableOptional
Responses
200

Successful Response

application/json
anyOptional
post/api/v1/chat/completions
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?