How to Unify AI Subscriptions with AnyRouter
Bring Z-AI, Kimi, OpenAI, Anthropic, and other provider accounts into one AnyRouter preset, then launch Claude Code through one CLI wrapper.
If you already pay for several AI providers, AnyRouter can turn those separate accounts into one routing layer. Create one preset, add each provider account inside it, then call that preset from your app or from Claude Code — one model name for everything you use every day.
The idea
You give your tools a single model name (coding-stack), and AnyRouter handles provider choice, fallback, logs, rate limits, and cost visibility behind it. This guide builds a coding preset that layers your provider accounts, with AnyRouter credits as a last-resort backup.
flowchart LR
subgraph tools["Your tools"]
direction TB
cc["Claude Code"]
apps["Apps and API clients"]
end
subgraph anyrouter["AnyRouter (all your subs)"]
direction LR
subgraph preset["One preset: @preset/coding-stack"]
direction TB
model["Model name callers use"]
subgraph sources["Sources added inside this preset"]
direction TB
zai["Z-AI key"]
kimi["Kimi key"]
claude["Claude key"]
openai["OpenAI key"]
credits["AnyRouter credits"]
end
route["Fallback or weighted routing"]
end
end
cc --> model
apps --> model
model --> route
zai --> route
kimi --> route
claude --> route
openai --> route
credits --> route
How it works
The preset named coding-stack layers several sources in priority order:
| Source | Example model | Why add it |
|---|---|---|
| Z-AI subscription or API key | z-ai/glm-4.7-flash | Strong multilingual coding and low-cost daily work |
| Moonshot Kimi account | moonshotai/kimi-k2.5 | Long-context code review and Chinese-English work |
| Anthropic or Claude-compatible key | anthropic/claude-sonnet-4.6 | High-signal agent and refactor tasks |
| OpenAI account | openai/gpt-5.4-mini | Fast fallback and OpenAI-compatible tooling |
| AnyRouter credits | Any supported model | Last-resort fallback when your own accounts are out of quota |
With model selection set to auto, AnyRouter chooses the highest-priority healthy model in the preset. If your Z-AI source is healthy, auto selects z-ai/glm-4.7-flash first; if it's unavailable, it moves to Kimi, Claude, OpenAI, or paid fallback according to the preset order.
Implementation
Create an AnyRouter key
Open Dashboard → Keys and create an AnyRouter API key. It starts with sk-ar-. This is the only key your local tools need — provider keys stay stored in AnyRouter as BYOK credentials.
Create one preset
Open Dashboard → Presets and create a preset:
| Field | Value |
|---|---|
| Name | Coding stack |
| Slug | coding-stack |
| Mode | fallback for predictable order, or weighted for traffic sharing |
| Model selection | auto |
| Paid fallback | On, if you want AnyRouter credits to cover outages or exhausted BYOK quota |
Add the models in the order you want AnyRouter to try them:
{
"models": [
"z-ai/glm-4.7-flash",
"moonshotai/kimi-k2.5",
"anthropic/claude-sonnet-4.6",
"openai/gpt-5.4-mini"
],
"temperature": 0.2,
"provider": {
"allow_fallbacks": true
}
}
Save the preset. You now have one model name for your tools: coding-stack. The explicit form @preset/coding-stack also works.
Add provider accounts inside the preset
Stay on the preset page. For each model row, choose an existing source or click Add provider account inline.
| Source | What to add |
|---|---|
| Z-AI | Your Z-AI key for GLM models |
| Moonshot AI | Your Kimi key |
| Anthropic | Your Claude-compatible key or token |
| OpenAI | Your OpenAI key |
| AnyRouter credits | Enable paid fallback for backup capacity |
When adding a provider account:
- Pick the provider from the row's Source menu.
- Paste the provider key or token.
- Add a clear alias, such as
zai-personal,kimi-pro, oropenai-work. - Save and validate the key.
AnyRouter saves the provider account as a BYOK source, attaches it to this preset, and encrypts the key before storing it. Your clients can now use the preset as the model:
curl https://anyrouter.dev/api/v1/chat/completions \
-H "Authorization: Bearer sk-ar-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "coding-stack",
"messages": [{"role": "user", "content": "Review this patch"}]
}'
The request resolves to the first healthy BYOK-backed model that matches the preset. If that source is rate-limited, unhealthy, or out of quota, AnyRouter tries the next branch.
Launch Claude Code through AnyRouter
Install the native CLI, then run:
curl -fsSL https://anyrouter.dev/setup.sh | bash
anyr claude
The first run sets you up once. Choose either option:
- Paste an API key — the
sk-ar-key from the first step. - Log in at anyrouter.dev — opens your browser; after you approve, a key is generated and sent back to your terminal automatically.
Your profile is saved to ~/.anyrouter/config.yaml and reused on every later run, so you go straight into Claude Code.
Reuse the same key for Codex, OpenCode, and more
One stored key drives every tool. Launch Codex or OpenCode with the same config:
anyr codex
anyr opencode
The pinned @preset/coding-stack and auto model selection apply by default, so you usually don't need --model. Override per session when you want to:
anyr claude --model "anthropic/claude-sonnet-4.6"
anyr claude --model auto --effort high
anyr codex --effort xhigh
auto means "pick the best valid model from the pinned preset." Concrete model ids bypass auto selection for that one session. --effort tunes reasoning depth (low–max). Anything after -- is forwarded to the underlying tool. See the AnyRouter CLI reference for every command, flag, and the config.yaml schema.
BYOK or AnyRouter credits? Use BYOK when you already have provider credits, subscriptions, enterprise contracts, preview access, or special limits. Use AnyRouter credits when you want a simple backup source without managing another provider account. Most teams use both: BYOK first so existing provider spend is used, AnyRouter paid fallback second so tools keep working when a provider account is exhausted, and the usage explorer for the full picture across both paths.
Related
- BYOK — attach and manage provider credentials
- Presets — one model name over many sources
- Smart Routing — how AnyRouter chooses a branch
- Claude Code — use Claude Code with AnyRouter
- OpenCode — use OpenCode with AnyRouter
- Provider Routing — the full
providerblock reference