Quickstart
First call in three minutes — create an API key, verify with curl, then point your SDK's base_url at the gateway.
There are only three things to do: get a key, change the base URL, pick a model. There is no TokRouter-specific SDK or config file.
1. Create an API key
Sign in to the console and open the Tokens page, then click Create token. The token is shown in full only once — copy it somewhere safe immediately.
- Tokens look like
sk-xxxxxxxx - A token can carry a quota cap and an expiry; create one per project when you need isolation
- A lost token cannot be recovered — delete it and create a new one
Where to keep the key
Never put it in frontend code or commit it. Inject it as an environment variable such as
TOKROUTER_API_KEY.
2. Verify with curl
export TOKROUTER_API_KEY="sk-your-token"
curl https://api.tokrouter.dev/v1/chat/completions \
-H "Authorization: Bearer $TOKROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4-mini",
"messages": [{"role": "user", "content": "Reply with one word: ok"}]
}'The response body is the standard OpenAI Chat Completions shape (choices[0].message.content).
Getting a 401? Check these three
- Is the header
Bearer sk-…? A missingBearerprefix returns 401. - Is the token expired or disabled? The Tokens page shows its status.
- Did you use your console password as the key? They are not the same thing.
3. Point your SDK at the gateway
OpenAI Python:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["TOKROUTER_API_KEY"],
base_url="https://api.tokrouter.dev/v1",
)
resp = client.chat.completions.create(
model="claude-opus-5-5", # the OpenAI SDK can call Claude too
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)OpenAI Node:
import OpenAI from 'openai'
const client = new OpenAI({
apiKey: process.env.TOKROUTER_API_KEY,
baseURL: 'https://api.tokrouter.dev/v1',
})For the Anthropic SDK, Gemini and DashScope see Anthropic protocol and the SDK list.
4. Pick a model
Model ids use the vendor's own names. See Models for the list and prices. You can also list what is available to your token:
curl https://api.tokrouter.dev/v1/models \
-H "Authorization: Bearer $TOKROUTER_API_KEY"Next steps
- Authentication: key scope, rotation and security practice
- Billing and quota: per-component pricing, quota caps, whether failures are billed
- Streaming, tool calling, structured output
- API reference: endpoints, fields and errors