Base URL and authentication

URL differences for OpenAI and Anthropic clients.

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.

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.

Verify available models

List models available to your key first, then copy data[].id exactly into requests. Names, case and aliases come from this response. The public plaza hides unpriced models; backend availability is unchanged.

Request example
curl "https://api.hanrouter.ai/v1/models" \
  -H "Authorization: Bearer $HANROUTER_API_KEY"

Related articles

Use the OpenAI SDK ›