API reference

Chat Completions

An OpenAI-compatible, stateless messages API for multi-turn text or image input, function calling and reasoning.

POST https://router.omnitools.ai/v1/chat/completions

Authentication

Authenticate every request with a Team API key.

Authorization: Bearer $PAI_API_KEY

Content-Type must be application/json. Query parameters are not accepted.

Create a chat completion

Send the full conversation history required for this turn.

curl https://router.omnitools.ai/v1/chat/completions \
  -H "Authorization: Bearer $PAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "claude-fable-5",
  "messages": [
    {
      "role": "user",
      "content": "Give one practical rule for reliable API clients."
    }
  ],
  "max_completion_tokens": 160
}'

Request parameters

Only the parameters below are accepted. Unsupported OpenAI fields return an error.

ParameterRequirementDescription
modelRequiredStable PAI model ID from the model catalog.
messagesRequiredNon-empty array of supported system, developer, user, assistant and tool messages. User content may contain image_url parts.
max_completion_tokensOptionalPositive output-token limit. Do not combine with max_tokens.
max_tokensOptionalSupported compatibility alias for max_completion_tokens.
temperatureOptionalNumber from 0 through 2.
top_pOptionalNumber from 0 through 1.
stopOptionalOne string or up to four strings. The selected model route must support stop sequences.
streamOptional · default falseReturns data-only server-sent event chunks when true.
stream_optionsOptionalWith streaming, accepts include_usage. include_obfuscation is not supported.
toolsOptionalUp to 128 unique function tools in the OpenAI function wrapper.
tool_choiceOptionalauto, none, required, or a named function object.
parallel_tool_callsOptional · default trueAllows multiple function calls in one assistant turn.
reasoning_effortOptionalnone, minimal, low, medium, high, xhigh or max, subject to model support.
thinkingOptional{ type: 'enabled' } or { type: 'disabled' }. Must not conflict with reasoning_effort.
nOptional · 1 onlyPAI returns exactly one choice.
storeOptional · false onlyPAI does not store conversation state.

Messages and tools

Text, images, reasoning and function calls can be replayed across turns. Image input uses only routes with verified image capability.

Instruction and user messages

System and developer messages are text-only and must form one leading instruction. User content accepts text plus image_url parts with URL/data URL and auto, low or high detail.

Assistant messages

Assistant content may be null when reasoning_content or tool_calls is present. refusal must be null and annotations must be empty.

Tool results

A tool message requires text content and tool_call_id. It must answer a pending assistant function call before the conversation continues.

Function schema

Each tool uses type function and a function object with a unique name, optional description, JSON-object parameters and optional strict.

Automatic routing

The stable model ID is the only routing input. Internal route selection is automatic.

Routing is automatic and private. Router first prefers native support for the requested protocol, then ranks compatible routes by recent availability and internal cost. Fallback does not change the public model ID or price.

Streaming chunks

With stream: true, each SSE data line contains a chat.completion.chunk object.

  • Delta chunks may contain assistant role, content, reasoning_content or incremental tool_calls.
  • A finish_reason of stop, length, content_filter or tool_calls closes the choice.
  • When stream_options.include_usage is true, a final usage chunk has no choices.
  • The stream terminates with data: [DONE].

Completion object

PAI returns exactly one choice and normalized cached-input and reasoning-token usage details.

Minimal response
{
  "id": "chatcmpl_…",
  "object": "chat.completion",
  "created": 1783900800,
  "model": "claude-fable-5",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "…",
        "refusal": null,
        "annotations": []
      },
      "finish_reason": "stop",
      "logprobs": null
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "prompt_tokens_details": {
      "cached_tokens": 0
    },
    "completion_tokens": 24,
    "completion_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 36
  }
}

Unsupported parameters

The following recognized Chat Completions fields are explicitly rejected.

audiofrequency_penaltyfunction_callfunctionslogit_biaslogprobsmetadatamodalitiespredictionpresence_penaltyprompt_cache_keyprompt_cache_retentionresponse_formatsafety_identifierseedservice_tiertop_logprobsuserverbosityweb_search_options

Any unlisted top-level field returns unknown_parameter. Message name, assistant audio and legacy function_call, text-part annotations and logprobs, and stream_options.include_obfuscation are explicitly unsupported. Audio parts, structured output and multiple choices are not supported; images are user-only and capability-gated.

Errors

Responses and Chat Completions return message, type, param and code with x-request-id. Messages maps the HTTP status to the Anthropic error shape, omits code and also includes request-id.

HTTPRouter codeDescription
400invalid_parameterThe JSON shape, parameter value, protocol header or requested feature is invalid.
401invalid_api_keyThe API key is missing, malformed, expired, revoked or unknown.
402insufficient_creditsThe Team has no available Credits for a new request.
404model_not_foundThe requested model is unavailable.
413payload_too_largeThe JSON request body exceeds 8 MiB.
429api_key_spend_limit_exceededThe API key reached one of its rolling spend limits.
502upstream_error / invalid_upstream_responseModel execution was rejected or returned an invalid response.
503upstream_unavailable / route_unavailableNo eligible route completed the request before the routing deadline.

Keep x-request-id (or request-id for Messages) when contacting support or inspecting the request in Console.