Setup guide
Connect OpenClaw
OpenClaw is an open-source, self-hosted personal AI agent. You add CheapTokens as a custom model provider in openclaw.json.
Before you start
- A CheapTokens account with some balance. Create one if you haven't.
- Your API key from Dashboard → API key. It starts with
ct_live_. - Any text model from the models page. They all work over the OpenAI Chat Completions format.
The snippets below use claude-sonnet-5-5. Pick another model to update them.
Windows
-
Install OpenClaw. The installer also sets up Node.js if it is missing, then walks you through onboarding.PowerShell
iwr -useb https://openclaw.ai/install.ps1 | iex
-
Save your key as an environment variable. Close PowerShell and open it again so the new variables load.PowerShell
setx CHEAPTOKENS_API_KEY "YOUR_API_KEY"
-
Open
%USERPROFILE%\.openclaw\openclaw.jsonand add the provider and default model. If the file already hasagentsormodelssections, merge these keys into them.openclaw.json{ agents: { defaults: { model: { primary: "cheaptokens/claude-sonnet-5-5" }, }, }, models: { mode: "merge", providers: { cheaptokens: { baseUrl: "https://cheaptokens.pw/v1", apiKey: "${CHEAPTOKENS_API_KEY}", api: "openai-completions", models: [ { id: "claude-sonnet-5-5", name: "claude-sonnet-5-5", contextWindow: 200000, maxTokens: 8192 }, ], }, }, }, } -
Restart the gateway and check that the model is listed.PowerShell
openclaw gateway restart openclaw models list
-
Send your agent a message. To switch model later, run
openclaw models set cheaptokens/claude-sonnet-5-5or type/modelin a chat.
macOS
-
Install OpenClaw. The installer also sets up Node.js if it is missing, then walks you through onboarding.Terminal
curl -fsSL https://openclaw.ai/install.sh | bash
-
Save your key as an environment variable. The last line reloads your shell settings, so the variables work straight away.Terminal
echo 'export CHEAPTOKENS_API_KEY="YOUR_API_KEY"' >> ~/.zshrc source ~/.zshrc
-
Open
~/.openclaw/openclaw.jsonand add the provider and default model. If the file already hasagentsormodelssections, merge these keys into them.openclaw.json{ agents: { defaults: { model: { primary: "cheaptokens/claude-sonnet-5-5" }, }, }, models: { mode: "merge", providers: { cheaptokens: { baseUrl: "https://cheaptokens.pw/v1", apiKey: "${CHEAPTOKENS_API_KEY}", api: "openai-completions", models: [ { id: "claude-sonnet-5-5", name: "claude-sonnet-5-5", contextWindow: 200000, maxTokens: 8192 }, ], }, }, }, } -
Restart the gateway and check that the model is listed.Terminal
openclaw gateway restart openclaw models list
-
Send your agent a message. To switch model later, run
openclaw models set cheaptokens/claude-sonnet-5-5or type/modelin a chat.
Linux
-
Install OpenClaw. The installer also sets up Node.js if it is missing, then walks you through onboarding.Terminal
curl -fsSL https://openclaw.ai/install.sh | bash
-
Save your key as an environment variable. The last line reloads your shell settings, so the variables work straight away.Terminal
echo 'export CHEAPTOKENS_API_KEY="YOUR_API_KEY"' >> ~/.bashrc source ~/.bashrc
-
Open
~/.openclaw/openclaw.jsonand add the provider and default model. If the file already hasagentsormodelssections, merge these keys into them.openclaw.json{ agents: { defaults: { model: { primary: "cheaptokens/claude-sonnet-5-5" }, }, }, models: { mode: "merge", providers: { cheaptokens: { baseUrl: "https://cheaptokens.pw/v1", apiKey: "${CHEAPTOKENS_API_KEY}", api: "openai-completions", models: [ { id: "claude-sonnet-5-5", name: "claude-sonnet-5-5", contextWindow: 200000, maxTokens: 8192 }, ], }, }, }, } -
Restart the gateway and check that the model is listed.Terminal
openclaw gateway restart openclaw models list
-
Send your agent a message. To switch model later, run
openclaw models set cheaptokens/claude-sonnet-5-5or type/modelin a chat.
Check that it works
Send a short message in OpenClaw, then open Dashboard → Usage. The request appears there within a few seconds, with its model, tokens and cost.
Good to know
- The default model only works if the same model ID is also listed under the provider's
models. openclaw models statusshows which model and provider are active.openclaw doctorchecks the whole install.
If something goes wrong
| What you see | What to do |
|---|---|
401 or invalid_api_key | The key is wrong, disabled or has extra spaces. Create a new key and paste it again. |
402 or insufficient_quota | Your balance is empty. Top up under Billing. |
404 or model_not_found | The model ID has a typo. Copy it from the models page. |
| 404 on every request | The base URL is wrong. Check whether this tool needs the /v1 ending (see the steps above). |
| 429 | Too many requests per minute. Wait a few seconds and retry. |
Prefer a guided version? Open the setup wizard →