OpenClaw

Add a custom Anthropic provider to OpenClaw.

OpenClaw is an open-source personal AI assistant that runs on your own machine and connects to chat apps. It accepts custom model providers in both the OpenAI-compatible and the Anthropic format.

  • Protocol: OpenAI-compatible or Anthropic
  • Base URL: https://tokenfunc.com/v1 for OpenAI-compatible, https://tokenfunc.com for Anthropic
  • Models: any, for example claude-sonnet-4-5

Option 1: setup wizard

  1. Run the wizard

    openclaw onboard

    Choose More… → Custom Provider.

    Screenshot pendingThe Custom Provider option in openclaw onboardtools/openclaw-onboard.png

  2. Enter the provider details

    PromptOpenAI-compatibleAnthropic
    Base URLhttps://tokenfunc.com/v1https://tokenfunc.com
    API keysk-xxxxxxxxxxxxxxxxsk-xxxxxxxxxxxxxxxx
    CompatibilityOpenAI-compatibleAnthropic-compatible
    Model IDclaude-sonnet-4-5claude-sonnet-4-5

    With OpenAI-compatible the wizard fetches this site's model list for you to pick from; with Anthropic you type the model ID. Before saving, the wizard makes a real call to confirm it gets a reply.

  3. Verify

    openclaw models list --provider tokenfunc

    If it lists this site's models, you are set. The wizard names the provider custom- plus the host by default; replace tokenfunc in the command with the actual name.

Option 2: one command

openclaw onboard --non-interactive --auth-choice custom-api-key \
  --custom-provider-id tokenfunc \
  --custom-base-url "https://tokenfunc.com/v1" \
  --custom-model-id "claude-sonnet-4-5" \
  --custom-api-key "sk-xxxxxxxxxxxxxxxx" \
  --custom-compatibility openai

Option 3: edit the config file

The config file is ~/.openclaw/openclaw.json (JSON5, comments allowed). Changes apply automatically:

~/.openclaw/openclaw.json
{
  agents: { defaults: { model: { primary: 'tokenfunc/claude-sonnet-4-5' } } },
  models: {
    mode: 'merge',
    providers: {
      tokenfunc: {
        baseUrl: 'https://tokenfunc.com/v1',
        apiKey: 'sk-xxxxxxxxxxxxxxxx',
        api: 'openai-completions',
        models: [
          {
            id: 'claude-sonnet-4-5',
            name: 'claude-sonnet-4-5',
            contextWindow: 200000,
            maxTokens: 8192,
          },
        ],
      },
    },
  },
}
  • For the Anthropic format, set baseUrl to https://tokenfunc.com and api to "anthropic-messages".
  • For image input, add input: ["text", "image"] to the model.
  • To change the default model: openclaw models set tokenfunc/claude-sonnet-4-5.

Troubleshooting

SymptomCause and fix
Model unavailable / not allowed by modelPolicyThe model is only listed under agents.defaults. It must also be in providers.tokenfunc.models
"returned no token usage"Add compat: { supportsUsageInStreaming: true } to the model
Upstream rejects reasoning_effortAdd compat: { supportsReasoningEffort: false } to the model
404The OpenAI-compatible baseUrl is missing /v1
Changes made with openclaw configure do nothingProviders are changed through openclaw onboard or the config file