> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tokenlab.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# TokenLab Provider Setup

> Configure TokenLab as a custom provider in OpenClaw using OpenAI, Responses, Anthropic, and Gemini-compatible routes

<Note>
  This guide is for **self-hosted OpenClaw** users who want to connect TokenLab as their AI provider.
</Note>

## Recommended: install the plugin

For standard OpenClaw agent execution, install the TokenLab provider plugin:

```bash theme={null}
openclaw plugins install @tokenlabai/openclaw-provider
openclaw onboard --tokenlab-api-key "$TOKENLAB_API_KEY"
```

The plugin discovers TokenLab's live chat-model catalog and keeps 18 fallback models for offline discovery. Models use the `tokenlab/<model-id>` format.

[npm package](https://www.npmjs.com/package/@tokenlabai/openclaw-provider) · [ClawHub listing](https://clawhub.ai/tokenlabai/plugins/openclaw-provider) · [Source code](https://github.com/hedging8563/tokenlab-openclaw-provider)

## Manual provider configuration

Use manual `models.providers` entries when you explicitly need separate **Responses API**, **Claude native**, **Gemini native**, or **MiniMax native** routes.

If you choose manual configuration, configuring `tokenlab` alone is enough. Add the other providers only when you explicitly need **Responses API**, **Claude native**, **Gemini native**, or **MiniMax native** behavior.

| 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`    |

<Warning>
  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.
</Warning>

## Prerequisites

* A self-hosted OpenClaw instance
* A TokenLab API Key — [Get one here](https://tokenlab.sh/dashboard)

## Configuration

Edit your OpenClaw config:

* **Self-hosted**: `~/.openclaw/openclaw.json`

Add TokenLab providers under `models.providers`:

```json5 theme={null}
{
  agents: {
    defaults: {
      model: {
        primary: "tokenlab-claude/claude-sonnet-4-6"
      }
    }
  },
  models: {
    mode: "merge",
    providers: {
      tokenlab: {
        api: "openai-completions",
        baseUrl: "https://api.tokenlab.sh/v1",
        apiKey: "sk-your-tokenlab-key",
        models: [
          { id: "gpt-4o", name: "GPT-4o" },
          { id: "deepseek-r1", name: "DeepSeek R1" },
          { id: "qwen3-coder-flash", name: "Qwen 3 Coder Flash" }
        ]
      },
      "tokenlab-responses": {
        api: "openai-responses",
        baseUrl: "https://api.tokenlab.sh/v1",
        apiKey: "sk-your-tokenlab-key",
        models: [
          { id: "gpt-4o", name: "GPT-4o (Responses)" },
          { id: "gpt-5.2", name: "GPT-5.2 (Responses)" }
        ]
      },
      "tokenlab-claude": {
        api: "anthropic-messages",
        baseUrl: "https://api.tokenlab.sh",
        apiKey: "sk-your-tokenlab-key",
        models: [
          { id: "claude-sonnet-4-6", name: "Claude Sonnet 4.6" },
          { id: "claude-opus-4-6", name: "Claude Opus 4.6" }
        ]
      },
      "tokenlab-gemini": {
        api: "google-generative-ai",
        baseUrl: "https://api.tokenlab.sh",
        apiKey: "sk-your-tokenlab-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: "sk-your-tokenlab-key",
        models: [
          { id: "minimax-m3", name: "MiniMax M3" }
        ]
      }
    }
  }
}
```

<Info>
  All 5 providers use the **same API Key**. You only need one TokenLab account.
</Info>

<Info>
  The `models` arrays above only show common examples. Add more model IDs to each provider as needed.
</Info>

## Using Models

OpenClaw still references models with the `provider/model` format:

```json5 theme={null}
{
  agents: {
    defaults: {
      model: {
        primary: "tokenlab-gemini/gemini-3.5-flash"
      }
    }
  }
}
```

### Model Examples

| Provider             | Model reference                     | Description                  |
| -------------------- | ----------------------------------- | ---------------------------- |
| `tokenlab`           | `tokenlab/gpt-4o`                   | OpenAI-compatible route      |
| `tokenlab`           | `tokenlab/deepseek-r1`              | DeepSeek reasoning model     |
| `tokenlab-responses` | `tokenlab-responses/gpt-4o`         | Responses API route          |
| `tokenlab-claude`    | `tokenlab-claude/claude-sonnet-4-6` | 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](https://tokenlab.sh/en/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

<AccordionGroup>
  <Accordion title="Still using the old top-level providers array">
    Current OpenClaw docs use `models.providers`. If you keep the older top-level `providers` array format, OpenClaw may ignore the config or fail to resolve the provider prefixes as expected.
  </Accordion>

  <Accordion title="Forgetting /v1 on tokenlab-responses">
    `openai-responses` maps to TokenLab's `/v1/responses` path, so `tokenlab-responses` must use `https://api.tokenlab.sh/v1`.
  </Accordion>

  <Accordion title="Adding /v1 to tokenlab-claude, tokenlab-gemini, or tokenlab-minimax">
    `anthropic-messages` and `google-generative-ai` should use `https://api.tokenlab.sh` without `/v1`. Adding `/v1` can produce incorrect request paths.
  </Accordion>

  <Accordion title="Does OpenClaw still support native Gemini?">
    Yes. Current OpenClaw documentation still includes the built-in `google` provider and also supports custom providers using `api: "google-generative-ai"`. So `tokenlab-gemini` remains a valid native Gemini route for OpenClaw users.
  </Accordion>
</AccordionGroup>

## Verify Setup

After saving the config, restart your OpenClaw instance and test with a simple message. If you see a response, the provider is configured correctly.

```bash theme={null}
# Self-hosted: restart the service
systemctl --user restart openclaw    # Linux
launchctl stop cc.tokenlab.openclaw && launchctl start cc.tokenlab.openclaw  # macOS
```

## Next Steps

Once OpenClaw is connected, these guides help you use TokenLab more effectively:

* [API Formats](/guides/api-formats) — understand the differences between OpenAI, Responses, Anthropic, and Gemini routes
* [IDE / SDK Compatibility](/guides/ide-sdk-compatibility) — see when `/v1/responses` is the better fit
* [Error Handling](/guides/error-handling) — learn common failure modes and recovery patterns
* [Models Overview](https://tokenlab.sh/en/models) — browse model IDs before wiring them into agents
