Skip to content

OpenAI compatibility

Understand the supported OpenAI-style surface and the features that remain outside it.

Router supports a focused subset of the OpenAI chat-completions interface. Existing OpenAI clients can connect by changing the base URL and API key.

Supported today

CapabilitySupport
GET /v1/modelsModel edition discovery with Router limits and availability counts.
POST /v1/chat/completionsText messages with system, user, and assistant roles.
Non-streaming responsesAssistant text, finish reason, and provider-reported usage.
Streaming responsesOrdered content deltas, final finish reason and usage, then [DONE].
OpenAI Python and JavaScript clientsSupported through a custom base_url or baseURL.

Accepted chat parameters

Router accepts model, messages, stream, max_tokens, temperature, and the optional Router extensions provider_selection and slippage_tolerance (integer 0–100, default 30%). Omit provider_selection for Auto; use {offer_id,pricing_revision} to choose one public computer/model offer. See choosing a provider. Unknown properties are rejected, which helps catch code written for a broader API surface.

As with the OpenAI API, stream defaults to false. Long work must stream: a non-streaming request above 512 output tokens or about 24 KB of message text is rejected with stream_required, because a long silent response is cut off by network timeouts.

json
{  "model": "gemma3:1b",  "messages": [    { "role": "system", "content": "Answer briefly." },    { "role": "user", "content": "What is a neural network?" }  ],  "max_tokens": 200,  "temperature": 0.4,  "stream": false}

Outside the supported surface

Router does not currently support tool or function calls, image input, structured output, embeddings, audio, the Responses API, arbitrary message names, or automatic model fallback.

Migrate a basic client

typescript
import OpenAI from "openai";
const client = new OpenAI({  baseURL: process.env.ROUTER_BASE_URL,  apiKey: process.env.ROUTER_API_KEY,});

Use an environment base URL ending in /v1, then call client.models.list() or client.chat.completions.create(...).

Design for explicit failure

Router preserves your model and explicit provider choice and reports unavailable capacity. Manual selection does not silently fall back to Auto. If a selected price changes, review the new pricing revision before sending a new logical request. If your product wants a fallback model, make that choice in your application, tell the user when it happens, and validate the alternate model’s limits first.

Continue with the Python, TypeScript, or cURL recipe.