Your first request in 5 minutes

Sign in, create a key, list models and make a request.

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.

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"

Call a model

Install the openai package and set HANROUTER_MODEL to an ID returned by the previous endpoint.

Request example
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["HANROUTER_API_KEY"],
    base_url="https://api.hanrouter.ai/v1",
)
model_id = os.environ["HANROUTER_MODEL"]
result = client.chat.completions.create(
    model=model_id,
    messages=[{"role": "user", "content": "Hello"}],
)
print(result.choices[0].message.content)

Related articles

Create and manage API keys ›