Hyperouter API
Hyperouter exposes one OpenAI-compatible HTTP API in front of many model providers. You send a request naming a model; Hyperouter picks the provider (the venue) that serves it best, forwards the request, and bills your balance at that venue’s list price.
The API is in private beta. Request a key to get access.
Quickstart
- Request an API key. Keys start with
hr-. - Store it in an environment variable, e.g.
HYPEROUTER_API_KEY. - Point any OpenAI SDK at the base URL above and pick a model.
curl https://hyperouter.app/api/v1/chat/completions \ -H "Authorization: Bearer $HYPEROUTER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "anthropic/claude-sonnet-5", "messages": [{"role": "user", "content": "Hello"}] }'
import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://hyperouter.app/api/v1", apiKey: process.env.HYPEROUTER_API_KEY, }); const res = await client.chat.completions.create({ model: "anthropic/claude-sonnet-5", messages: [{ role: "user", content: "Hello" }], }); console.log(res.choices[0].message.content);
import os from openai import OpenAI client = OpenAI( base_url="https://hyperouter.app/api/v1", api_key=os.environ["HYPEROUTER_API_KEY"], ) res = client.chat.completions.create( model="anthropic/claude-sonnet-5", messages=[{"role": "user", "content": "Hello"}], ) print(res.choices[0].message.content)
Authentication
Send your key as a bearer token on every request:
Authorization: Bearer hr-...
Keys carry full access to your balance. Keep them server-side, never in browser or mobile code. To rotate or revoke a key, email account@hyperouter.app; a revoked key stops working immediately.
Chat completions
Accepts the OpenAI Chat Completions request body. Hyperouter adds the models and provider fields for routing.
Request body
| Field | Type | Description |
|---|---|---|
model | string | Model slug, e.g. openai/gpt-5. Required unless models is set. |
models | string[] | Ordered fallback list. The next model is tried if every venue for the previous one fails. |
messages | object[] | Conversation so far. Roles: system, user, assistant, tool. Content may include images where the model supports them. |
stream | boolean | Return server-sent events. See Streaming. |
max_tokens | integer | Upper bound on generated tokens. |
temperature, top_p | number | Sampling controls, passed through to the venue. |
stop | string | string[] | Sequences that end generation. |
tools, tool_choice | object[], string | object | Function calling, in OpenAI format. Translated for venues that use a different schema. |
response_format | object | {"type":"json_object"} or a JSON schema for structured output. |
provider | object | Routing preferences. See Routing. |
user | string | Your end-user ID, used for abuse monitoring and your usage export. |
Response
Identical to OpenAI’s, plus provider (the venue that filled the request) and usage.cost in USD.
{
"id": "gen-01J8Z6Q4X2",
"object": "chat.completion",
"model": "anthropic/claude-sonnet-5",
"provider": "anthropic",
"choices": [{
"index": 0,
"message": { "role": "assistant", "content": "Hello! How can I help?" },
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 8,
"total_tokens": 17,
"cost": 0.000147
}
}
Streaming
With "stream": true the response is a stream of server-sent events in the OpenAI chunk format, ending with data: [DONE]. The last chunk before [DONE] carries usage and provider.
Fallback happens only before the first token is sent. If a venue fails mid-stream, the stream ends with an error event and you are billed only for tokens already delivered.
Routing
By default Hyperouter sends each request to the healthy venue with the lowest price for that model, breaking ties by latency. A venue is considered unhealthy after elevated error rates or timeouts in the last few minutes and is skipped until it recovers.
Override the default with the provider object:
| Field | Type | Description |
|---|---|---|
sort | string | "price" (default), "latency" or "throughput". |
order | string[] | Venues to try first, in order, e.g. ["anthropic","bedrock"]. |
only | string[] | Only route to these venues. |
ignore | string[] | Never route to these venues. |
allow_fallbacks | boolean | Default true. Set false to fail instead of trying another venue. |
data_collection | string | "deny" limits routing to venues that do not retain or train on prompts. |
max_price | object | Ceiling in USD per 1M tokens, e.g. {"prompt":1,"completion":4}. Venues above it are skipped. |
{
"model": "deepseek/deepseek-v3.2",
"provider": {
"sort": "throughput",
"data_collection": "deny",
"max_price": { "prompt": 0.5, "completion": 1 }
},
"messages": [{ "role": "user", "content": "Hello" }]
}
Models
Lists every model you can call, with live prices per token in USD and the venues serving it. No authentication required.
{
"data": [{
"id": "anthropic/claude-sonnet-5",
"name": "Claude Sonnet 5",
"context_length": 200000,
"pricing": { "prompt": "0.000003", "completion": "0.000015" },
"venues": ["anthropic", "bedrock", "vertex"],
"modalities": ["text", "image"]
}]
}
Errors
Errors use standard HTTP status codes and an OpenAI-style body: {"error": {"code": 402, "message": "..."}}.
| Status | Meaning |
|---|---|
400 | Invalid request body or parameters. |
401 | Missing, invalid or revoked API key. |
402 | Balance too low for this request. Top up and retry. |
403 | Input was rejected by a venue’s content policy. |
404 | Unknown model, or no venue matches your provider constraints. |
408 | The request timed out on every venue tried. |
429 | Rate limited. Retry after the number of seconds in Retry-After. |
502 | Every eligible venue returned an error. Not billed. |
503 | Hyperouter is temporarily unavailable. Not billed. |
Billing & limits
- Requests are paid from a prepaid USD balance. Token prices match each venue’s list price; there is no markup.
- Top-ups by card carry a 3.0% fee; USDC and USDT top-ups carry 2.5%. Accounts above $50K per month can move to invoicing.
- Only successful requests are billed. Fallback attempts that fail cost nothing.
- Every response includes
usage.cost, so you can reconcile spend per request. - Rate limits scale with your balance and history. Current limits are returned in
X-RateLimit-Limit,X-RateLimit-RemainingandX-RateLimit-Resetheaders.
Support
Keys, billing and API questions: account@hyperouter.app. Chat product: chat@hyperouter.app. Please include the id from the response when reporting a specific request.