Skip to content

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:

SourceExample modelWhy add it
Z-AI subscription or API keyz-ai/glm-4.7-flashStrong multilingual coding and low-cost daily work
Moonshot Kimi accountmoonshotai/kimi-k2.5Long-context code review and Chinese-English work
Anthropic or Claude-compatible keyanthropic/claude-sonnet-4.6High-signal agent and refactor tasks
OpenAI accountopenai/gpt-5.4-miniFast fallback and OpenAI-compatible tooling
AnyRouter creditsAny supported modelLast-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:

FieldValue
NameCoding stack
Slugcoding-stack
Modefallback for predictable order, or weighted for traffic sharing
Model selectionauto
Paid fallbackOn, 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.

SourceWhat to add
Z-AIYour Z-AI key for GLM models
Moonshot AIYour Kimi key
AnthropicYour Claude-compatible key or token
OpenAIYour OpenAI key
AnyRouter creditsEnable paid fallback for backup capacity

When adding a provider account:

  1. Pick the provider from the row's Source menu.
  2. Paste the provider key or token.
  3. Add a clear alias, such as zai-personal, kimi-pro, or openai-work.
  4. 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.