Connect Claude Code

Anthropic protocol with a Base URL without /v1.

Prepare your API key

Sign in at /login, then create or copy a HanRouter API key at /keys. Your password and browser session token are not API keys. Check key validity, model group permissions and Dashboard balance.

Store the complete key in the server environment variable HANROUTER_API_KEY. Keep it out of browser code, public repositories and URL parameters.

URL and authentication

Use https://api.hanrouter.ai/v1 as the OpenAI-compatible Base URL and Authorization: Bearer $HANROUTER_API_KEY. Do not duplicate /v1. All manufacturers use your HanRouter key, not an upstream vendor key.

For the Anthropic SDK and Claude Code, use https://api.hanrouter.ai without /v1; the client appends /v1/messages. Use the OpenAI-compatible interface for Google models.

Environment variables

Set HANROUTER_MODEL to a Claude ID available to your key. The key group and channel must support Messages. Check usage at /usage.

Request example
export ANTHROPIC_BASE_URL="https://api.hanrouter.ai"
export ANTHROPIC_AUTH_TOKEN="$HANROUTER_API_KEY"
claude --model "$HANROUTER_MODEL"

Related articles

Connect Cline ›Connect Cursor ›Connect Kilo Code ›Connect Roo Code ›Connect Continue ›Connect Aider ›