Chat

Create a chat completion

Changed on

OpenAI-compatible chat completions. Supports:

  • Streaming (stream: true, SSE)
  • Tool / function calling (tools, tool_choice)
  • Structured outputs (response_format)
  • Multimodal — send images via content: [{type: "image_url", ...}] (see ChatMessageContentPart schema below). https:// URLs work against every vision-capable model; OrcaRouter's translation layer adapts the content part for each upstream (OpenAI, Anthropic, Google, xAI Grok).
  • OrcaRouter fallback chains via extra_body.models.

Use provider-prefixed model names (openai/gpt-4o-mini, anthropic/claude-sonnet-4.6, google/gemini-2.5-flash), plain bare-name aliases when available, or named routers (orcarouter/auto).

post/chat/completions

Request

  • Base URL
    https://api.orcarouter.ai/v1
  • URL
    https://api.orcarouter.ai/v1/chat/completions
  • Auth
    HTTP bearer

Headers

X-OrcaRouter-Include-Coststring
Example:true

Opt in to per-request cost reporting. When true (or 1, case-insensitive), the billed cost of the call is added to the response's usage object — usage.cost_usd on the OpenAI and Anthropic formats, usageMetadata.costUsd on the Gemini format. On streams it rides the frame carrying final usage (send stream_options: {"include_usage": true} on the OpenAI format). Absent or any other value means off. See Per-request cost.

Request body

modelstring required

Model ID. Supports three forms:

  • Provider-prefixed (default): openai/gpt-4o-mini, anthropic/claude-sonnet-4.6, google/gemini-2.5-flash
  • Plain alias: gpt-4o-mini (when a bare-name alias is available)
  • Named router: orcarouter/{name} (resolves to a model at request time; orcarouter/auto is seeded on signup for every account and picks the cheapest live chat model)
streamboolean

When true, response is streamed as server-sent events.

parallel_tool_callsboolean
temperaturenumber
top_pnumber
max_tokensinteger
max_completion_tokensinteger

Preferred over max_tokens for reasoning models.

ninteger
seedinteger

For deterministic sampling.

logprobsboolean
top_logprobsinteger
presence_penaltynumber
frequency_penaltynumber
logit_biasobject
userstring
reasoning_effort'low' | 'medium' | 'high'

For OpenAI reasoning models (o1, o3*, o4*, gpt-5*-pro, etc.). Anthropic Claude uses the thinking field instead; Gemini uses provider-specific configuration.

web_searchunknown

Example request

{
  "model": "gpt-4o",
  "messages": [
    {
      "content": [
        {
          "image_url": {
            "url": "https://example.com/photo.jpg"
          }
        }
      ]
    }
  ],
  "extra_body": {
    "models": [
      "openai/gpt-4o",
      "anthropic/claude-haiku-4.5",
      "google/gemini-2.5-pro"
    ]
  }
}

Response

Successful completion. Streaming responses use SSE (text/event-stream).

idstring
object'chat.completion'
createdinteger
modelstring

Example response

{
  "choices": [
    {
      "message": {
        "content": [
          {
            "image_url": {
              "url": "https://example.com/photo.jpg"
            }
          }
        ]
      }
    }
  ]
}

Changes