Chat completions

POST /v1/chat/completions — streaming and non-streaming.

Fully OpenAI-compatible chat completions endpoint. Supports tools, JSON mode, and streaming.

Non-streaming
POST https://gateway.relixr.com/v1/chat/completions
Authorization: Bearer nf_live_...

{
  "model": "claude-sonnet-4-5",
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Summarize edge routing in one sentence."}
  ],
  "temperature": 0.7,
  "max_tokens": 512
}
Streaming
POST https://gateway.relixr.com/v1/chat/completions
Authorization: Bearer nf_live_...

{
  "model": "gpt-4o-mini",
  "messages": [{"role": "user", "content": "Hello"}],
  "stream": true
}

# Response: text/event-stream
# Final chunk + headers include X-Relixr-Route and cost estimate

Streaming reliability

  • SSE streams emit `: keepalive` comments every 15 seconds during upstream silence.
  • If your client disconnects, the gateway aborts the upstream provider request and finalises billing for tokens received so far.
  • Connection resume (`Last-Event-ID`) is not supported in v1 — open a new request with a fresh `request_id`.

Error responses follow the gateway contract: 402 insufficient_balance, 403 policy_violation, 429 rate_limited.