Quick integration
TokenHub is OpenAI-compatible — swap the BaseURL and call every model. Native Anthropic / Claude Code protocol, Gemini protocol and OpenAI Responses are supported too.
Quick start
Get an API key
Sign up and create a key (sk-...) on the console API keys page. The full key is shown only once at creation — store it safely.
Open consoleSwap the BaseURL
Point your request base URL at our gateway; everything else stays identical to the OpenAI API:
https://api.tokenhub.example/v1Make a call
Replace sk-... in the examples below with your own key and send your first request.
Code examples
Three common endpoints: OpenAI Chat Completions, OpenAI Responses and Anthropic Messages.
curl https://api.tokenhub.example/v1/chat/completions \
-H "Authorization: Bearer sk-..." \
-d '{
"model": "openai/gpt-4o",
"messages": [{"role": "user", "content": "Hello!"}]
}'curl https://api.tokenhub.example/v1/responses \
-H "Authorization: Bearer sk-..." \
-d '{
"model": "openai/gpt-4o",
"input": "Write a haiku about APIs."
}'curl https://api.tokenhub.example/v1/messages \
-H "x-api-key: sk-..." \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "anthropic/claude-sonnet-4",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello!"}]
}'OpenAI SDK
Official SDKs only need a base_url override; model names keep the vendor/model format.
from openai import OpenAI
client = OpenAI(
api_key="sk-...",
base_url="https://api.tokenhub.example/v1",
)
resp = client.chat.completions.create(
model="openai/gpt-4o",
messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-...",
baseURL: "https://api.tokenhub.example/v1",
});
const resp = await client.chat.completions.create({
model: "openai/gpt-4o",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(resp.choices[0].message.content);Claude Code / native Anthropic protocol
We serve the native Anthropic /v1/messages protocol. Claude Code needs two environment variables:
export ANTHROPIC_BASE_URL="https://api.tokenhub.example" export ANTHROPIC_AUTH_TOKEN="sk-..."
Or call /messages directly:
curl https://api.tokenhub.example/v1/messages \
-H "x-api-key: sk-..." \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "anthropic/claude-sonnet-4",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello!"}]
}'Model names
Model IDs use the vendor/model format, e.g. openai/gpt-4o, anthropic/claude-sonnet-4, google/gemini-2.5-pro. See the model catalog for the full list with live prices.
Browse the model catalogCommon errors
| Status | Meaning | How to fix |
|---|---|---|
| 401 | Key invalid or deleted | Check the Authorization header is Bearer sk-..., or create a new key in the console |
| 402 | Insufficient balance | Top up in the console wallet, or subscribe to a plan for discounted rates |
| 429 | Rate limited | Lower concurrency or retry later; plan subscribers get higher limits |
Documentation
All integration docs, grouped by topic.
5 groups · 28 documents