# AnyRouter for AI coding agents
AnyRouter is one OpenAI-compatible and Anthropic-compatible gateway in front of many model providers. One key, one base URL.
## Connect
- Base URL: `https://anyrouter.cfd/api/v1`
- Auth: `Authorization: Bearer sk-ar-v1-...` (Anthropic clients may send `x-api-key` instead)
- Get a key at https://anyrouter.cfd/dashboard/keys (no card required). Keep it in `ANYROUTER_API_KEY`, never in source.
```bash
export ANYROUTER_API_KEY="sk-ar-v1-your-key"
curl https://anyrouter.cfd/api/v1/chat/completions \
-H "Authorization: Bearer $ANYROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"anyrouter/free","messages":[{"role":"user","content":"Hello"}]}'
```
## Endpoints
All paths are relative to the base URL.
| Endpoint | Compatible with |
|---|---|
| `POST /chat/completions` | OpenAI Chat Completions |
| `POST /messages` | Anthropic Messages |
| `POST /responses` | OpenAI Responses |
| `POST /embeddings` | OpenAI Embeddings |
| `GET /models` | Model list (JSON) |
For an OpenAI SDK set `base_url` / `baseURL` to `https://anyrouter.cfd/api/v1`. For an Anthropic SDK or Claude Code set `ANTHROPIC_BASE_URL` to `https://anyrouter.cfd/api`, because the SDK appends `/v1/messages`.
## Models
- Ids look like `owner/model`. Copy exact ids from the catalog, do not guess.
- `anyrouter/auto` routes to a suitable model for you. Add a context floor with `anyrouter/auto[500k]` or `anyrouter/auto[1m]`.
- `anyrouter/free` routes to the best free model available right now, with fallback. It uses no credits.
- List models as JSON with `GET https://anyrouter.cfd/api/v1/models`, or as markdown at https://anyrouter.cfd/models.md. Per-model pages are at `https://anyrouter.cfd/model/<owner>/<model>.md`.
## Free models
`anyrouter/free` and `:free` model variants cost no credits. The Free plan allows 10 requests per day. Paid plans allow 1,000 per day on free models. Paid models need credits and return `402 insufficient_balance` without them. See https://docs.anyrouter.cfd/features/free-tier.
## The `anyr` CLI
```bash
curl -fsSL https://anyrouter.cfd/setup.sh | bash
anyr auth login # browser, device code, or paste a key
anyr claude # launch Claude Code through AnyRouter
anyr claude --model anyrouter/auto
```
`anyr` sets the right environment variables for each tool before launching it. Add `--dry-run` to see them.
## Links
- Docs: https://docs.anyrouter.cfd
- Quickstart: https://docs.anyrouter.cfd/getting-started/quickstart
- Agent integration guide: https://docs.anyrouter.cfd/guides/ai-agent-integration
- Site overview for LLMs: https://anyrouter.cfd/llms.txt
- Full docs for LLMs: https://anyrouter.cfd/llms-full.txt