Migrate from OpenRouter
Drop in for OpenRouter. Same OpenAI-compatible API, broader catalog (video / audio / music / 3D), lower platform fee on top-ups, evals + sub-accounts included.
CLI automation for OpenRouter is shipping: `aig migrate openrouter` walks the working tree and rewrites every match.
TL;DR — three lines
# 1. set your AIgateway key export AIGATEWAY_API_KEY="sk-aig-..." # 2. change the base URL base_url="https://api.aigateway.sh/v1" # was https://openrouter.ai/api/v1 # 3. aig migrate openrouter # or rewrite by hand
Automated: aig migrate openrouter
Walks the current directory tree (ignoring node_modules, build outputs, lockfiles), shows you a preview of every change, and applies them after a y/N confirmation. Leaves *.aig-migrate.bak backups alongside each rewritten file unless you pass --no-backup.
# install once npm i -g aigateway-cli # preview without writing aig migrate openrouter --dry-run # apply (with backups) aig migrate openrouter # CI-friendly: skip the prompt aig migrate openrouter --yes --no-backup
What changes, line-by-line
The table below is what aig migrate openrouter rewrites. If you're doing it by hand, do these in order.
| Thing | OpenRouter | AIgateway |
|---|---|---|
| Base URL | https://openrouter.ai/api/v1 | https://api.aigateway.sh/v1 |
| API key env var | OPENROUTER_API_KEY | AIGATEWAY_API_KEY |
| Auth header | Authorization: Bearer … | Authorization: Bearer … |
| Model slug format | anthropic/claude-opus-4.7 | anthropic/claude-opus-4.7 |
| Streaming format | OpenAI SSE | OpenAI SSE |
| Platform fee | 5.5% at top-up | 5% per call (no top-up fee beyond Stripe) |
| BYOK fee | 5% (after 1M free/mo) | 0% on BYOK traffic |
| Cost-attribution headers | — | x-aig-tag (any string) |
Before / after — Python (OpenAI SDK)
from openai import OpenAI
client = OpenAI(
base_url="https://openrouter.ai/api/v1",
api_key=os.environ["OPENROUTER_API_KEY"],
)
r = client.chat.completions.create(
model="anthropic/claude-opus-4.7",
messages=[{"role": "user", "content": "Hi"}],
)from openai import OpenAI
client = OpenAI(
base_url="https://api.aigateway.sh/v1",
api_key=os.environ["AIGATEWAY_API_KEY"],
)
r = client.chat.completions.create(
model="anthropic/claude-opus-4.7",
messages=[{"role": "user", "content": "Hi"}],
)Behavioral notes
- Model slugs are 1:1 compatible — no model-name rewrites needed.
- OpenRouter's x-or-* headers (route, fallbacks) map to AIgateway routing rules in the dashboard.
- Cache discount: AIgateway gives 50% off cached requests automatically (not in OpenRouter).
Credit match
Email your last invoice from OpenRouter to switch@aigateway.sh and we match the credit up to $1,000 (24-hour turnaround). Or read the full pitch at /switch/openrouter.
What to read next
- BYOK — bring your existing OpenRouter provider keys; pay 0% on those routes.
- Sub-accounts — per-customer keys with spend caps; the closest analogue to workspace-isolated keys.
- All migration guides — same docs for OpenRouter, Portkey, Helicone, LiteLLM, Together, Replicate, Fireworks, Requesty.