Free Starter Credits for Claude Code & OpenCode: 2-Minute AgentRouter Setup
AgentRouter is a unified LLM gateway: one API key, one balance, and both
OpenAI-compatible (/v1/chat/completions, /v1/responses) and
Anthropic-compatible (/v1/messages) endpoints. The same account drops
straight into Claude Code, OpenCode, Codex, Cline - any agent client that
sends one of the supported User-Agents (see Step 4) - with no provider
juggling and no per-provider billing.
New accounts include a starter credit balance, and a daily check-in keeps
adding credit, so you can wire up your agent stack and test real workloads
before paying anything.
Step 1: Claim Starter Credits & Generate an API Key (AgentRouter)
- Create the account (email signup, no card needed at registration as of this writing): https://agentrouter.org/register?aff=U1iX
- Console -> API Keys -> Create API Key. Keys look like
sk-...orar-...and are shown exactly once - copy immediately. - Export it:
export AGENTROUTER_API_KEY="sk-xxxxxxxxxxxxxxxx" Step 2: Claude Code (Anthropic surface - no /v1)
Create ~/.claude/settings.local.json:
{ "env": { "ANTHROPIC_BASE_URL": "https://agentrouter.org", "ANTHROPIC_AUTH_TOKEN": "sk-xxxxxxxxxxxxxxxx", "ANTHROPIC_MODEL": "deepseek-v4.1-flash" } } The base URL has NO /v1 suffix. The Anthropic-compatible surface lives
at the bare domain; appending /v1 returns 404. ANTHROPIC_AUTH_TOKEN takes
the same key as the OpenAI surface (one key covers both; quota is shared).
ANTHROPIC_MODEL is supply-driven and availability is per-account-group.
deepseek-v4.1-flash is the verified default - it is served on both surfaces
and is what AgentRouter itself recommends when the Claude/GPT daily budget
pools exhaust. If your account group exposes GLM-5.3-Flash, the
glm-5.3-flash-max variant is the pick for long coding-agent loops; always
cross-check the console's model list before pinning.
Step 3: OpenCode (OpenAI-compatible surface - with /v1)
Add a provider to ~/.config/opencode/opencode.json:
{ "$schema": "https://opencode.ai/config.json", "provider": { "agentrouter": { "npm": "@ai-sdk/openai-compatible", "name": "AgentRouter", "options": { "baseURL": "https://agentrouter.org/v1", "apiKey": "{env:AGENTROUTER_API_KEY}" }, "models": { "deepseek-v4.1-flash": { "name": "DeepSeek V4.1 Flash" }, // "glm-5.3-flash-max": { "name": "GLM-5.3 Flash (max)" } <- add if your account group exposes it } } } } The OpenAI-compatible surface requires the /v1 suffix - the two
surfaces use mirrored conventions, so do not mix them. List the model IDs
your console currently shows under models. Note: the gpt-6.2-* family is
Responses-only (/v1/responses) - if your client only speaks
/v1/chat/completions, stick to models served there
(deepseek-v4.1-flash is verified; glm-5.3-flash-max if your account
group exposes it).
Step 4: 60-second smoke test
AgentRouter gates on the client User-Agent - plain curl's default UA is
rejected with 401 unauthorized client detected, so send a known client UA
(the suffix matters; shortened variants are still rejected):
curl -sS https://agentrouter.org/v1/chat/completions \ -H "User-Agent: claude-cli/2.0.0 (external, cli)" \ -H "Authorization: Bearer $AGENTROUTER_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model":"deepseek-v4.1-flash","messages":[{"role":"user","content":"ping"}],"max_tokens":16}' A JSON completion (or an upstream-availability message) proves the key and
the surface are wired correctly.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
404 on /v1/messages | Mixed surfaces | Anthropic base URL must have no /v1; OpenAI base URL must have /v1 |
401 unauthorized client detected | Client User-Agent gated | Send a known client UA verbatim, e.g. -H "User-Agent: claude-cli/2.0.0 (external, cli)" (curl's default UA and shortened variants are rejected) |
400 ... does not support /v1/chat/completions ... use /v1/responses | gpt-6.2 family is Responses-only | Point a Responses-capable client at /v1/responses, or use a chat-completions model like deepseek-v4.1-flash |
model not found / no available channel / 503 无可用渠道 | Model ID rotated, supply-limited, or your account group lacks a channel for it | Re-check the console model list; supply notices also land on the status endpoint |
insufficient_user_quota | Credits exhausted or model not covered by your plan | Check the wallet balance in the console; run the daily check-in |
401 / other auth errors | Key missing or invalid | Re-copy the key from the console; one key covers both surfaces (Authorization: Bearer, or x-api-key on the Anthropic surface) |
| Hangs on long reasoning | Client timeouts too tight | Raise header/chunk timeouts to 120-180s |
Model supply changes daily; announcements land on
https://agentrouter.org/api/status.
Raw copy-pasteable version of every config in this guide: https://gist.github.com/adzkii-git/fd0fef30931adf57c5b4c8a6512c1158