---
title: "Chat Completions"
method: POST
path: "/v1/chat/completions"
tags: ["chat"]
---

# Chat Completions

`POST /v1/chat/completions`

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

## Request body

- ChatCompletionRequest — 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``), declare an OpenAI wire param ``CompletionParams`` does not model (``service_tier``, forwarded as an any-llm ``**kwargs`` param), or add gateway-internal behavior (``mcp_servers``, ``mcp_server_ids``, ``guardrails``, ``tools_header``, ``max_tool_iterations``) that is stripped before the request is forwarded upstream.
  - `frequency_penalty` number, nullable
  - `guardrails` GuardrailConfig[], nullable
    - `mode` 'block' | 'monitor'
    - `on` string[]
    - `on_unavailable` 'block' | 'monitor'
    - `profile` string, required
    - `url` string, nullable
    - `validate_kwargs` object
  - `logit_bias` object, nullable
  - `logprobs` boolean, nullable
  - `max_completion_tokens` integer, nullable
  - `max_tokens` integer, nullable
  - `max_tool_iterations` integer, nullable
  - `mcp_server_ids` string[], nullable
  - `mcp_servers` McpServerConfig[], nullable
    - `allowed_tools` string[], nullable
    - `authorization_token` string, nullable
    - `name` string, required
    - `purpose_hint` string, nullable
    - `url` string, required
  - `messages` object[], required
  - `model` string, required
  - `n` integer, nullable
  - `parallel_tool_calls` boolean, nullable
  - `presence_penalty` number, nullable
  - `reasoning_effort` 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'auto', nullable
  - `response_format` object, nullable
  - `seed` integer, nullable
  - `service_tier` string, nullable
  - `session_label` string, nullable — Optional caller-supplied label for cost attribution (per run, experiment, or conversation). In hybrid mode it is forwarded onto the platform usage report so spend can be sliced by session without standing up OpenTelemetry. Stripped before the request is forwarded upstream to the provider. Has no effect in standalone mode, where there is no platform to report it to.
  - `stop` union
    - string
    - string[]
  - `stream` boolean
  - `stream_options` object, nullable
  - `temperature` number, nullable
  - `tool_choice` union
    - string
    - object
  - `tools` union[], nullable
    - union
      - object
      - unknown
  - `tools_header` string, nullable — 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_logprobs` integer, nullable
  - `top_p` number, nullable
  - `user` string, nullable

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/mozilla-ai/apis/otari.md) · [All operations](https://skmtc.net/mozilla-ai/apis/otari/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/mozilla-ai/otari/revisions/3f47ecc61aff/schema)
