Claude Code with AnyRouter — free models, one API key

Run Claude Code through AnyRouter with anyrouter/free or any model on one sk-ar- key.

Run Claude Code through AnyRouter with one sk-ar- key, request logs and no code changes. Flags, profiles and --dry-run are in the Claude Code CLI setup.

Set it up

bash
curl -fsSL https://anyrouter.dev/setup.sh | bash
anyr claude

First run: paste an sk-ar- key or log in at anyrouter.dev. The config is saved and also powers anyr codex.

Check request logs: the call appears within a second or two with model, tokens and cost.

Model ids

Model idWhat it does
anyrouter/freeBest free model available now, with fallback. No credits. Needs Go ($2/mo, or free when you donate one working provider key); no daily cap. See Free Tier.
anyrouter/autoTop models (free and paid) with health-aware failover. Paid members use credits.
z-ai/glm-5.2GLM-5.2: 1M context, 128K output, controllable reasoning.
bash
anyr claude --model anyrouter/free

Own provider keys (BYOK) are billed by your provider: see Use your own provider keys.

GLM-5.2 with your own Z-AI key

  1. Paste your Z-AI key (or Coding Plan key, routed to the Coding Plan endpoint automatically) in Settings → BYOK.
  2. Run anyr claude --model "z-ai/glm-5.2". With manual env vars: claude --model "z-ai/glm-5.2".
  3. Set reasoning with /effort or --effort. low/medium/high/max enable thinking; none/minimal disable it.
  4. For the full 1M window, set CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000 so Claude Code does not compact early.

MCP tools

anyr claude connects the AnyRouter MCP gateway when Auto-connect in coding agents is on in the dashboard. Turn it off with --no-mcp, anyr mcp auto off, or the dashboard.

Troubleshooting

SymptomFix
401 or 403Key inactive, or ANTHROPIC_API_KEY is not a valid sk-ar- key. Check Keys.
Model not foundUse an exact id from Messages-compatible models. For GLM-5.2, confirm the Z-AI key is saved under BYOK.
400 no_eligible_modelsPrivacy or routing settings (Zero Data Retention, blocked providers) excluded every candidate. Relax them or pick a specific model.
Long runs time outexport API_TIMEOUT_MS=3000000

AnyRouter routes requests to third-party models. Models and outputs are provided as is, with no warranty; you use them at your own risk. Disclaimer