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

The snippets below use claude-sonnet-5-5. Pick another model to update them.

Windows

  1. 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
  2. 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"
  3. Open %USERPROFILE%\.openclaw\openclaw.json and add the provider and default model. If the file already has agents or models sections, 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 },
            ],
          },
        },
      },
    }
  4. Restart the gateway and check that the model is listed.
    PowerShell
    openclaw gateway restart
    openclaw models list
  5. Send your agent a message. To switch model later, run openclaw models set cheaptokens/claude-sonnet-5-5 or type /model in a chat.

macOS

  1. 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
  2. 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
  3. Open ~/.openclaw/openclaw.json and add the provider and default model. If the file already has agents or models sections, 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 },
            ],
          },
        },
      },
    }
  4. Restart the gateway and check that the model is listed.
    Terminal
    openclaw gateway restart
    openclaw models list
  5. Send your agent a message. To switch model later, run openclaw models set cheaptokens/claude-sonnet-5-5 or type /model in a chat.

Linux

  1. 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
  2. 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
  3. Open ~/.openclaw/openclaw.json and add the provider and default model. If the file already has agents or models sections, 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 },
            ],
          },
        },
      },
    }
  4. Restart the gateway and check that the model is listed.
    Terminal
    openclaw gateway restart
    openclaw models list
  5. Send your agent a message. To switch model later, run openclaw models set cheaptokens/claude-sonnet-5-5 or type /model in 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

If something goes wrong

What you seeWhat to do
401 or invalid_api_keyThe key is wrong, disabled or has extra spaces. Create a new key and paste it again.
402 or insufficient_quotaYour balance is empty. Top up under Billing.
404 or model_not_foundThe model ID has a typo. Copy it from the models page.
404 on every requestThe base URL is wrong. Check whether this tool needs the /v1 ending (see the steps above).
429Too many requests per minute. Wait a few seconds and retry.

Prefer a guided version? Open the setup wizard →