Chat completions
OpenAI-compatible chat completions, streamed or buffered, with RouteShift's routing applied transparently — fail over, balance load, and bill back savings.
The chat-completions endpoint is a drop-in replacement for https://api.openai.com/v1/chat/completions. The wire format is identical; the routing, logging, and cost accounting happens server-side.
Endpoint
POST https://api.routeshift.io/v1/chat/completions
Authorization: Bearer sk-proxy-…
Content-Type: application/jsonRequest body
Standard OpenAI shape — model, messages, temperature, max_tokens, stream, tools, etc. RouteShift adds two optional extension fields under metadata:
| Field | Type | Effect |
|---|---|---|
metadata.route_hint | string | Overrides the rule chain and pins this request to the named alias. |
metadata.session_id | string | Forces session stitching to use this ID instead of inferring one. Useful when you already have a conversation ID upstream. |
Anything else under metadata is preserved into request_logs.metadata for downstream analytics.
Requests can also opt in to the web search plugin by appending :online to the model name or adding a web entry to a top-level plugins array — RouteShift resolves the plugin, injects labeled search context into the system prompt, and forwards a clean payload upstream.
Streaming
Set "stream": true to receive Server-Sent Events. The format matches OpenAI's data: { ... }\n\n chunks. RouteShift relays chunks as they arrive from upstream — no extra buffering — and writes the request log when the stream closes.
Examples
curl https://api.routeshift.io/v1/chat/completions \
-H "Authorization: Bearer sk-proxy-…" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [
{"role": "system", "content": "You are concise."},
{"role": "user", "content": "What is 2 + 2?"}
]
}'Response headers
Beyond the standard OpenAI response, RouteShift adds:
X-RouteShift-Resolved-Model— the upstream model that actually served the request (after aliases and rule chain).X-RouteShift-Provider— provider name.X-RouteShift-Cost-Microcents— actual cost in microcents.X-RouteShift-Session-Id— session ID this request was stitched into.
These mirror the values written to request_logs so you can correlate client-side observability with the dashboard.
API overview
Use RouteShift's OpenAI-compatible client API at api.routeshift.io for chat completions, embeddings, and model discovery.
Admin API
Operator-facing RouteShift endpoints for key lifecycle, usage, routing artifacts, and cache invalidation, with explicit unrestricted and scoped-token boundaries.