Coding Tools
TokenLab Provider Setup
Connect a self-hosted OpenClaw instance to TokenLab
Let my agent set this up
Copy this task to an agent already running on your computer:
Read this guide and help me connect OpenClaw to TokenLab:
https://tokenlab.sh/docs/en/guides/tokenlab-provider
Check my installed version and active configuration first.
Preserve existing accounts, providers, permissions and other settings.
Back up local files and show proposed changes.
Have me enter any API key locally; never ask for, print or paste it in chat.
Check configuration loading first.
Explain any paid request test separately before running it.This guide is for self-hosted OpenClaw. The TokenLab plugin is the shortest setup; manual configuration is available when you need a specific API format.
Install the plugin
Optional: install the published provider plugin 0.1.0. Supply TOKENLAB_API_KEY through the same Gateway environment described below and use session-only model selection. The plugin onboarding wizard changes the default model, so this guide does not run openclaw onboard. Keep existing plugin entries and permissions. Check the installed plugin and model list before making a request.
Review the capabilities requested by the installer and follow the client’s confirmation prompts. Do not grant unrelated permissions or change the permissions of existing plugins.
openclaw plugins install @tokenlabai/openclaw-provider@0.1.0
openclaw plugins list
openclaw models list --provider tokenlab/model tokenlab/claude-sonnet-5 -s
/model default -sConfigure providers manually
Use models.providers only when OpenClaw needs Responses, Claude Messages, Gemini, or MiniMax formats separately. For ordinary chat, the tokenlab entry is enough.
| Provider | OpenClaw api | Best for | baseUrl |
|---|---|---|---|
tokenlab | openai-completions | GPT, DeepSeek, Qwen, and most OpenAI-compatible calls | https://api.tokenlab.sh/v1 |
tokenlab-responses | openai-responses | OpenAI Responses workflows that expect /v1/responses semantics | https://api.tokenlab.sh/v1 |
tokenlab-claude | anthropic-messages | Native Claude Messages API | https://api.tokenlab.sh |
tokenlab-gemini | google-generative-ai | Native Gemini API format | https://api.tokenlab.sh |
tokenlab-minimax | anthropic-messages | Native MiniMax routing | https://api.tokenlab.sh |
Use the /v1 suffix only for openai-completions and openai-responses.
Native providers such as anthropic-messages and google-generative-ai should use https://api.tokenlab.sh without /v1, otherwise OpenClaw may construct the wrong provider path.
Prerequisites
- A self-hosted OpenClaw instance
- For OpenClaw 2026.9.4, use Node.js
>=24.16.0 <25 || >=26.1.0(version requirements). For other OpenClaw releases, check that release's requirements. - A TokenLab API Key — Get one here
Configuration
Edit your OpenClaw config:
- Self-hosted:
~/.openclaw/openclaw.json
Add TokenLab providers under models.providers:
Use the same profile, OPENCLAW_STATE_DIR and OPENCLAW_CONFIG_PATH as the running Gateway. Back up the active configuration before merging. Put TOKENLAB_API_KEY in that instance’s trusted global .env or service environment; a terminal export or project .env alone may not reach the background Gateway. See environment handling.
Back up the active configuration. Add only the TokenLab entry and preserve existing providers, accounts, default-model selection and permissions. If the name is already used, choose another name and update the commands. To undo setup, remove only your added entry or restore its previous backup.
{
models: {
mode: "merge",
providers: {
tokenlab: {
api: "openai-completions",
baseUrl: "https://api.tokenlab.sh/v1",
apiKey: "${TOKENLAB_API_KEY}",
models: [
{ id: "gpt-5.6-terra", name: "GPT-5.6 Terra" },
{ id: "deepseek-reasoner", name: "DeepSeek Reasoner" },
{ id: "qwen3-coder-flash", name: "Qwen 3 Coder Flash" }
]
},
"tokenlab-responses": {
api: "openai-responses",
baseUrl: "https://api.tokenlab.sh/v1",
apiKey: "${TOKENLAB_API_KEY}",
models: [
{ id: "gpt-5.6-terra", name: "GPT-5.6 Terra (Responses)" },
{ id: "gpt-5.2", name: "GPT-5.2 (Responses)" }
]
},
"tokenlab-claude": {
api: "anthropic-messages",
baseUrl: "https://api.tokenlab.sh",
apiKey: "${TOKENLAB_API_KEY}",
models: [
{ id: "claude-sonnet-5", name: "Claude Sonnet 5" },
{ id: "claude-opus-5", name: "Claude Opus 5" }
]
},
"tokenlab-gemini": {
api: "google-generative-ai",
baseUrl: "https://api.tokenlab.sh",
apiKey: "${TOKENLAB_API_KEY}",
models: [
{ id: "gemini-3.5-flash", name: "Gemini 3.5 Flash" },
{ id: "gemini-2.5-pro", name: "Gemini 2.5 Pro" }
]
},
"tokenlab-minimax": {
api: "anthropic-messages",
baseUrl: "https://api.tokenlab.sh",
apiKey: "${TOKENLAB_API_KEY}",
models: [
{ id: "minimax-m3", name: "MiniMax M3" }
]
}
}
}
}All 5 providers use the same API Key. You only need one TokenLab account.
The models arrays above only show common examples. Add more model IDs to each provider as needed.
Using Models
OpenClaw still references models with the provider/model format:
For OpenClaw 2026.9.4, select the model only for the current session with -s. Keep agents.defaults.model, agent defaults and permissions unchanged. Use /model default -s to return this session to its configured default.
/model tokenlab-claude/claude-sonnet-5 -s
/model default -sModel Examples
| Provider | Model reference | Description |
|---|---|---|
tokenlab | tokenlab/gpt-5.6-terra | OpenAI-compatible route |
tokenlab-responses | tokenlab-responses/gpt-5.6-terra | Responses API route |
tokenlab-claude | tokenlab-claude/claude-sonnet-5 | Native Claude Messages route |
tokenlab-gemini | tokenlab-gemini/gemini-3.5-flash | Native Gemini route |
tokenlab-minimax | tokenlab-minimax/minimax-m3 | Native MiniMax route |
Browse all available models at tokenlab.sh/models.
When to Use Which Provider
tokenlab: default choice for most general-purpose agent and chat use cases.tokenlab-responses: use when your OpenClaw workflow explicitly depends on OpenAI Responses semantics.tokenlab-claude: use when you want Claude's native Messages behavior.tokenlab-gemini: use when you want Gemini-native request/response formatting or existing Gemini-style integrations.tokenlab-minimax: use when you want MiniMax on its native route.
If you do not need Gemini-native behavior, you can still call Gemini models through tokenlab/gemini-* on the OpenAI-compatible route.
Common Mistakes
Verify Setup
Restart that instance, then inspect its selected model and provider. models status without --probe does not make a model-call test. A live --probe or a chat message can consume tokens. Check a real reply against the matching TokenLab request before declaring the setup working. To restore, choose the previous model and remove only the TokenLab entries you added.
openclaw gateway restart
openclaw models statusNext Steps
Once OpenClaw is connected, these guides help you use TokenLab more effectively:
- API Formats — understand the differences between OpenAI, Responses, Anthropic, and Gemini routes
- IDE / SDK Compatibility — see when
/v1/responsesis the better fit - Error Handling — learn common failure modes and recovery patterns
- Models Overview — browse model IDs before wiring them into agents