Skip to main content

Get an API Key

An API Key is the only credential for calling TokenRoute. Which flow you follow depends on your role.

Your roleWhat you need
Member / department adminGo 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:

  1. Open Quota & API Keys in the left menu
  2. Confirm you have quota — a key created with zero quota cannot make calls
  3. Click create, then copy and save the key
Store your key securely

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:

OptionRecommendation
NameName by purpose, e.g. "local dev" or "production service", to make usage tracing easier later
Allowed modelsDefaults 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
QuotaOne-off quota, monthly quota, or unlimited. The key stops responding once exhausted; adjustable at any time
ExpiryFor 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 upBase URLNotes
Chatbox, Cherry Studiohttps://api.smartwan.comThe tool appends /v1 itself
Cline, Codex CLIhttps://api.smartwan.com/v1OpenAI-compatible protocol
Claude Codehttps://api.smartwan.comAnthropic protocol — no /v1
OpenAI Python SDKhttps://api.smartwan.com/v1See examples below
Anthropic Python SDKhttps://api.smartwan.comThe SDK appends /v1/messages
Google GenAI Python SDKhttps://api.smartwan.comSet api_version="v1beta"
Check the complete path

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 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"}]
}'

Copy model names from the model list — case and hyphens must match exactly.

Never commit keys to a repo

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.

Allocate quota before creating keys

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