AI Gateway
One key, every model, with a hard budget — in one command.
AI/LLM: this page is available in plain markdown at /docs/resources/ai-gateway.md
npx extraorbital add ai --max-budget 10✓ Provisioned openrouter/default ($10.00 budget)
✓ Wrote 2 variables to .env
OPENROUTER_BASE_URL, OPENROUTER_API_KEYOne key reaches every model on the gateway — Anthropic, OpenAI, Google, Meta,
Mistral, DeepSeek, Qwen and the rest, 400-odd in
total. A project that mentions any AI
provider's key gets this from extraorbital provision. Name a budget and it is a
hard ceiling; leave it out and the key is uncapped on a paid plan, or
held to whatever is left of your allowance on Prototype.
What it writes
| Variable | Example |
|---|---|
OPENROUTER_BASE_URL | https://openrouter.ai/api/v1 |
OPENROUTER_API_KEY | sk-or-v1-9c4e17b2… |
The key is a real OpenRouter credential, used directly against openrouter.ai.
Nothing is proxied through us, so your inference never depends on our uptime —
and the budget is enforced by OpenRouter itself rather than by a control loop
somewhere that has to still be running.
Model ids
Every model is named author/slug:
anthropic/claude-opus-5
openai/gpt-5.2
google/gemini-3-proAppend :free for a free variant where one exists, and ~author/…-latest for
an alias that follows the newest release. The model
list has all of them with current prices.
Options
npx extraorbital add ai [--slug <name>] [--max-budget <usd>] [--model-tier <tier>]| Flag | Default | Description |
|---|---|---|
--slug | default | A second key with its own budget |
--max-budget | none | Hard cap in USD. Requests past it fail on budget, not on auth |
--model-tier | full | small restricts the key to the cheapest models |
There is no default budget on a paid plan: an unasked-for ceiling would only stop
a working agent at an arbitrary number. Set --max-budget when you want a hard
per-key stop, and set an account-wide cap from the dashboard when
you want one number to bound everything at once.
Separate slugs give separate budgets, which is how you keep an experimental agent from eating a production one's allowance:
npx extraorbital add ai --slug experiments --max-budget 2--max-budget 0 stops the spend without revoking the key. Requests fail on
budget rather than breaking with an auth error nobody can interpret, and raising
the ceiling brings the same key back.
Prototype allowance
The first $5.00 of small models is on us, granted once per account rather than every month. A Prototype key is minted for the cheap models only and cannot spend past the allowance, whatever budget the agent asks for. On a paid plan a key reaches every model and meters at the model's list price with nothing added.
This is the one resource that meters per request, so the ledger shows real numbers from the first call rather than a provisioning entry at $0.00.
Use it
The gateway speaks the OpenAI API, so most clients need no adapter:
import OpenAI from "openai";
// Reads OPENROUTER_API_KEY and OPENROUTER_BASE_URL from the environment.
const client = new OpenAI({
apiKey: process.env.OPENROUTER_API_KEY,
baseURL: process.env.OPENROUTER_BASE_URL,
});
const response = await client.chat.completions.create({
model: "anthropic/claude-opus-5",
messages: [{ role: "user", content: "Draft a status report from these logs." }],
});It also speaks the Anthropic Messages API, which is what lets Claude Code point
at it. SDK recipes has both, plus the Vercel
AI SDK, LangChain, Hermes and raw curl.
If you asked for a provider key
extraorbital add openai does not mint an OpenAI key — nobody but OpenAI can.
It provisions the gateway, points OPENAI_BASE_URL at it so your existing code
runs unchanged, explains what happened, and exits 8. Everything else in the
same command still gets provisioned first.
Providers and keys lists every variable name this applies to and what gets written for each.
Next
- Providers and keys — every key we recognise
- Models — the full list, with prices
- SDK recipes — how to call it from anything
- Pricing — plans, allowances and rates