API reference

Using the unified API

One endpoint, OpenAI-compatible in shape. Point an existing client at it by changing the base URL and the key.

Endpoint

POST /api/v1/chat/completions
Authorization: Bearer omr_live_xxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json

Request

model and policy are optional. Omit both and the environment's default policy decides.

{
  "messages": [
    { "role": "system", "content": "You are a support assistant." },
    { "role": "user", "content": "Draft a reply to this complaint." }
  ],
  "max_tokens": 400,
  "temperature": 0.7,
  "policy": "Balanced production"
}

Response

Standard fields plus a namespaced omnirouter block that OpenAI-shaped clients ignore.

{
  "id": "ed190580-fd01-44a3-9e46-eb20fe7f435e",
  "object": "chat.completion",
  "model": "astra-fast",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "…" },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 63,
    "total_tokens": 73
  },
  "omnirouter": {
    "correlation_id": "ed190580-…",
    "provider": "DEMO",
    "fallback_used": false,
    "attempts": 1,
    "estimated_cost": 0.000039,
    "latency_ms": 540,
    "policy": "Balanced production",
    "strategy": "BALANCED",
    "routing_reason": "Astra Fast scored highest against the
      configured scoring policy. 3 candidates were eligible."
  }
}

Response headers

Present on both success and failure, so a failed request is still traceable.

x-omnirouter-correlation-id: ed190580-fd01-44a3-9e46-eb20fe7f435e
x-omnirouter-fallback-used: false
x-omnirouter-attempts: 1
x-omnirouter-quota-warning: (only when a quota threshold is crossed)

Idempotency

Send an Idempotency-Key header to guarantee at-most-once execution per workspace. A replay returns 409 with the original correlation id.

Idempotency-Key: order-4821-summary

Errors

Provider error text is never forwarded — it can echo prompt content or internal endpoints.

API error codes
CodeHTTPMeaning
invalid_api_key401Missing, unknown, revoked or expired key.
invalid_request400The body failed schema validation.
invalid_json400The body was not parseable JSON.
payload_too_large413The body exceeded the size limit.
unknown_policy400The named policy does not exist in this workspace.
idempotency_replay409This Idempotency-Key was already processed.
quota_exceeded429A configured workspace quota rejected the request.
rate_limit429Every eligible provider rate limited the request.
timeout504No provider responded within the configured timeout.
provider_unavailable502Every eligible provider was unavailable.
context_limit400The request exceeds every eligible model’s context window.