Documentation
Build against one endpoint
Everything you need to call every model through HanlinRouter — protocol compatibility, routing, billing and agent setup.
Overview
HanlinRouter is an AI API gateway. You call one endpoint with one API key; we route the request to the selected model provider, meter the tokens it reports, charge your balance and return the answer in the same protocol you sent it in.
OpenAI-compatible
https://hanlinrouter.site/v1
Anthropic-compatible
https://hanlinrouter.site/api
Gemini-compatible
https://hanlinrouter.site/v1beta
Quick start
- Create an account and an API key in Dashboard → API Keys.
- Add balance in Billing (minimum $5).
- Point your SDK at the gateway and send a request.
export HANLIN_API_KEY="hr_live_..."
curl https://hanlinrouter.site/v1/chat/completions \
-H "Authorization: Bearer $HANLIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.1",
"messages": [{"role": "user", "content": "Say hello in one sentence."}]
}'Authentication
Every request needs a key. Send it as Authorization: Bearer hr_live_…, as x-api-key (Anthropic style), or as ?key= for Gemini-compatible calls. Keys are stored as HMAC-SHA256 hashes and can be revoked at any time.
- Scoped by spend limit, model allowlist, IP allowlist and expiry.
- Requests that fail authentication return HTTP 401 and never reach a provider.
- Never ship a key in a browser bundle — proxy requests from your backend.
OpenAI compatibility
Base URL https://hanlinrouter.site/v1. Works with the official OpenAI SDKs, LangChain, Vercel AI SDK and any OpenAI-compatible client. Supported endpoints: POST /v1/chat/completions, GET /v1/models, GET /v1/models/{id}.
from openai import OpenAI
client = OpenAI(api_key= 0