Chat completions

POST /v1/chat/completions — a fully OpenAI-compatible endpoint with streaming, tools, and JSON mode.

POST ${GATEWAY_URL}/v1/chat/completions is the core endpoint. It supports tool calls, JSON mode, and both streaming and non-streaming responses — the same surface as OpenAI's chat completions API.

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 Reliability

  • SSE streams emit : keepalive comments every 15 seconds during upstream silence, so long-lived connections don't get killed by idle timeouts.
  • If your client disconnects, the gateway aborts the upstream provider request and finalizes billing for the tokens received so far — you're never charged for tokens you never got.
  • Connection resume via Last-Event-ID isn't supported in v1. Open a new request with a fresh request_id instead.
Tip:

If you stream to a browser or a flaky mobile connection, keep your own reconnect logic simple: on disconnect, just retry the whole request. The keepalive comments mean a hung connection is rare, not something you need to work around.

RequestRoute headersX-Relixr-RouteToken chunks…Final chunksettled cost
Every streamed request emits routing headers up front, then token chunks, then a final chunk with the settled cost.

Error responses follow the gateway's shared error contract — see Errors for the full list of status codes.

Next steps
Embeddings
POST /v1/embeddings
Model routing
Read the relixr extension in the response.
Supported modelsEmbeddings