DOCUMENTATION

Quickstart

DX Router is an OpenAI-compatible API. If your code works with the OpenAI SDK, it works with DX Router.

Authentication

Create a key for your app in the console, then send it as a bearer token. Keys belong to an app, so usage is tracked per key and per app.

Base URL: https://api.dxairouter.com/v1

headerHTTP
Authorization: Bearer YOUR_DX_ROUTER_KEY

Keep keys on your server. Never ship them in browser or mobile code.

Chat completions

curl

terminalPOST /v1/chat/completions
curl https://api.dxairouter.com/v1/chat/completions \
  -H "Authorization: Bearer $DX_ROUTER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-4o-mini",
       "messages": [{"role": "user", "content": "Hello!"}]}'

Python

app.pyopenai
from openai import OpenAI
client = OpenAI(base_url="https://api.dxairouter.com/v1", api_key="YOUR_DX_ROUTER_KEY")
reply = client.chat.completions.create(
    model="claude-sonnet-4-5",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(reply.choices[0].message.content)

Node.js

app.mjsopenai
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.dxairouter.com/v1", apiKey: process.env.DX_ROUTER_KEY });
const reply = await client.chat.completions.create({
  model: "gemini-2.5-pro",
  messages: [{ role: "user", content: "Hello!" }],
});
console.log(reply.choices[0].message.content);

Streaming

Set stream: true to receive tokens as server-sent events, exactly as with the OpenAI API.

stream.pystream=True
stream = client.chat.completions.create(
    model="gpt-4o", messages=messages, stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

Fallbacks

Pass a fallbacks list in the request body. If the primary model errors, times out or is rate-limited, DX Router tries each fallback in order and returns the first successful response.

request.jsonbody
{
  "model": "claude-sonnet-4-5",
  "messages": [{ "role": "user", "content": "Summarise this ticket" }],
  "fallbacks": ["gpt-4o", "gemini-2.5-pro"]
}

With the OpenAI Python SDK, send it through extra_body={"fallbacks": [...]}.

Models

List the models available to your key. Use any returned id as the model value.

terminalGET /v1/models
curl https://api.dxairouter.com/v1/models -H "Authorization: Bearer $DX_ROUTER_KEY"

Embeddings

embed.pyPOST /v1/embeddings
vectors = client.embeddings.create(
    model="text-embedding-3-small",
    input=["first document", "second document"],
)

Errors

Errors use the OpenAI error format, so existing error handling keeps working.

  • 401 — the key is missing, invalid or revoked.
  • 400 — the request is malformed, or the model isn't available to your key.
  • 429 — a rate or budget limit was reached. Retry with backoff, or add fallbacks.
  • 5xx — every model in the request failed. Safe to retry.

Usage and billing

Every request is metered with its model, token counts and cost, and recorded against the key and app that made it. In the console you can review the usage ledger, see charges by app or key, update the card on file and set up new apps.

Questions about your account? Contact us.