Get an API Key
An API Key is the only credential for calling TokenRoute. Which flow you follow depends on your role.
| Your role | What you need |
|---|---|
| Member / department admin | Go straight to Create an API Key |
| Enterprise admin (first-time setup) | Start from Initialize your enterprise |
Enterprise accounts are provisioned by GSS; self-signup is not supported.
Create an API Key
After signing in at console:
- Open Quota & API Keys in the left menu
- Confirm you have quota — a key created with zero quota cannot make calls
- Click create, then copy and save the key
Save the key after creation. Keys that your account is permitted to reveal, and whose state allows it, can be copied again from Quota & API Keys. Availability depends on permissions and key state. Never commit a key to a repository, screenshot it, or paste it into chat.
Options you can set at creation time:
| Option | Recommendation |
|---|---|
| Name | Name by purpose, e.g. "local dev" or "production service", to make usage tracing easier later |
| Allowed models | Defaults to every model your administrator has granted you; can be narrowed further by vendor or model, and calls outside that set are rejected. If you are told no models are available, the models you were granted have been retired — ask your administrator to reconfigure |
| Quota | One-off quota, monthly quota, or unlimited. The key stops responding once exhausted; adjustable at any time |
| Expiry | For keys shared with external partners, set 30–90 days and rotate regularly |
You can set expiry at creation. After creation, the editable options are those offered by the current interface.
Where the key goes
You only need two things: your API Key and a Base URL.
Base URL depends on how the client appends the endpoint path:
| What you're setting up | Base URL | Notes |
|---|---|---|
| Chatbox, Cherry Studio | https://api.smartwan.com | The tool appends /v1 itself |
| Cline, Codex CLI | https://api.smartwan.com/v1 | OpenAI-compatible protocol |
| Claude Code | https://api.smartwan.com | Anthropic protocol — no /v1 |
| OpenAI Python SDK | https://api.smartwan.com/v1 | See examples below |
| Anthropic Python SDK | https://api.smartwan.com | The SDK appends /v1/messages |
| Google GenAI Python SDK | https://api.smartwan.com | Set api_version="v1beta" |
A missing or duplicate version path can break a request. See Authentication & Base URL for SDK-specific behavior, and use the error response to diagnose a 404.
Verify the key first
Before running the Bash examples below, set export TOKENROUTE_API_KEY="sk-your-token" in that terminal.
The catalog request below reads the key set in your current terminal:
curl https://api.smartwan.com/v1/models \
-H "Authorization: Bearer ${TOKENROUTE_API_KEY}"
A returned list proves that this catalog request passed, not that every model can perform inference. Diagnose failures using the status, error.code/type/message and key permissions.
Using it in code
- curl
- Python
- Node.js
- Environment variables
curl https://api.smartwan.com/v1/chat/completions \
-H "Authorization: Bearer ${TOKENROUTE_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-flash",
"messages": [{"role": "user", "content": "Hello"}]
}'
from openai import OpenAI
client = OpenAI(
api_key="sk-your-token",
base_url="https://api.smartwan.com/v1",
)
resp = client.chat.completions.create(
model="deepseek-v4-flash",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'sk-your-token',
baseURL: 'https://api.smartwan.com/v1',
});
const resp = await client.chat.completions.create({
model: 'deepseek-v4-flash',
messages: [{ role: 'user', content: 'Hello' }],
});
console.log(resp.choices[0].message.content);
Most CLI tools read environment variables. Add them to ~/.zshrc or ~/.bashrc to persist:
# OpenAI-compatible clients that read these variables
export OPENAI_API_KEY="sk-your-token"
export OPENAI_BASE_URL="https://api.smartwan.com/v1"
# Anthropic protocol (Claude Code)
export ANTHROPIC_AUTH_TOKEN="sk-your-token"
export ANTHROPIC_BASE_URL="https://api.smartwan.com"
For Codex CLI, use the verified TOKENROUTE_API_KEY + env_key configuration described in Codex CLI.
On Windows PowerShell: $env:OPENAI_API_KEY="sk-your-token".
Copy model names from the model list — case and hyphens must match exactly.
Read keys from environment variables or a secrets manager in production. If a key leaks, delete and recreate it in the console.
Initialize your enterprise (admins)
Only needed the first time an enterprise admin sets things up.
1. Complete enterprise details
Sign in with the admin account GSS issued, open Enterprise Center, enter your company name and bind the company email domain. That domain determines which email addresses members can register with.
2. Create departments
Go to Account Management → Create Department and mirror your org structure. Departments are the basic unit for quota allocation and usage reporting.
3. Invite members
In Enterprise Center, generate a department-specific registration link and send it to the people joining. Anyone registering through that link is automatically assigned to that department.
Promote someone to department admin and they can take over member invitations and quota sub-allocation for that department, so the enterprise admin doesn't have to handle every request.
4. Allocate quota
Open Quota & API Keys and allocate quota to departments or individual members.
Quota cascades down: enterprise → department → member → individual key. A level with no allocation from above has nothing to spend, and a key's quota can never exceed the available quota of the member who owns it.
If a member's account has no quota, their key will fail even though it was created successfully. When opening a new department, push the quota down first.
Common situations
A member can't create a key — usually their department hasn't been allocated quota yet. Allocate it under "Quota & API Keys".
A key was lost — check whether Quota & API Keys offers Copy again. If its permissions or state prevent this, contact your administrator. Rotate a potentially exposed key and update its consumers.
Who spent what — the console's "Usage Center" breaks spend down by department, member, key and model, with CSV export.
Next steps
- All Tools — detailed setup for each client and CLI
- First Call — full examples for Anthropic, Gemini and other protocols
- FAQ — start here when something errors out