# Run Claude Code through AnyRouter

> Install the anyr CLI, then anyr claude — it injects the base URL, key, and model. Env vars are the fallback if you already run claude yourself.

One command sets the base URL, key and model

**Slug**: `claude-code`  
**URL**: https://anyrouter.dev/use-cases/claude-code  
**Markdown**: https://anyrouter.dev/use-cases/claude-code.md  
**Short link**: https://anyrouter.dev/u/claude-code  
**Other short links**: https://anyrouter.dev/u/cli, https://anyrouter.dev/u/claude  

## Why use this

Claude Code talks to Anthropic by default. To use other models, share billing across tools, or keep an audit log, you need a custom base URL without rewriting how the CLI works.

## Set it up

1. Install the anyr CLI with the curl | bash one-liner (native binary, no npm).
2. Run anyr claude. First run signs you in or pastes an sk-ar- key; later runs reuse ~/.anyrouter/config.yaml.
3. Pin a catalog model when you want one (anyr claude --model anyrouter/auto). Env vars remain the manual fallback.

## Code

### anyr CLI

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

### Env wrapper

```bash
export ANTHROPIC_BASE_URL="https://anyrouter.dev/api"
export ANTHROPIC_API_KEY="$ANYROUTER_API_KEY"
claude
```

## Related

- [grokbot](https://anyrouter.dev/use-cases/grokbot)
- [opencode](https://anyrouter.dev/use-cases/opencode)
- [coding-agents](https://anyrouter.dev/use-cases/coding-agents)
