Model providers

Using Anthropic Claude with OpenClaw

3 min read

Browse more in Model providers.

All model providers guides →

This guide walks you through configuring Anthropic Claude as a model provider in OpenClaw using an Anthropic API key. 6 as your default model, and enable features like fast mode, prompt caching, and 1M context where your account allows it.

By the end, your OpenClaw agents will call Anthropic’s Claude models in a way that matches your billing and performance needs.

Prerequisites

  • An Anthropic account with access to the Claude API and the ability to create an API key in the Anthropic Console.
  • OpenClaw installed on your machine or gateway host with the `openclaw` CLI available in your shell.
  • At least one OpenClaw agent configured so you can point it at Anthropic Claude models.

Steps

  1. 1

    Onboard Anthropic with an API key

    com`. Use the interactive onboarding if you want prompts, or the non-interactive flag if you already exported `ANTHROPIC_API_KEY` in your shell.

    bash
    openclaw onboard
    # choose: Anthropic API key
    
    # or non-interactive
    openclaw onboard --anthropic-api-key "$ANTHROPIC_API_KEY"
  2. 2

    Set Anthropic Claude as the default model

    6 model. This keeps your agent definitions clean and ensures new agents automatically use Claude unless you override them.

    json
    {
      env: { ANTHROPIC_API_KEY: "sk-ant-..." },
      agents: { defaults: { model: { primary: "anthropic/claude-opus-4-6" } } },
    }
  3. 3

    Enable fast mode for Anthropic Claude

    com` traffic. This config sets `fastMode: true` for `anthropic/claude-sonnet-4-6`, mapping `/fast on` to `service_tier: "auto"` and `/fast off` to `service_tier: "standard_only"`.

    json
    {
      agents: {
        defaults: {
          models: {
            "anthropic/claude-sonnet-4-6": {
              params: { fastMode: true },
            },
          },
        },
      },
    }
  4. 4

    Configure Anthropic prompt caching

    Tune Anthropic’s prompt caching per model using `cacheRetention`. This is API-only and works best when you want to reuse large prompts while controlling cache duration and write costs.

    json
    {
      agents: {
        defaults: {
          models: {
            "anthropic/claude-opus-4-6": {
              params: { cacheRetention: "long" },
            },
          },
        },
      },
    }
  5. 5

    Override cacheRetention per agent

    Use per-agent params when different agents need different cache behavior on the same Claude model. This pattern keeps a shared baseline while letting specific agents disable caching or shorten it.

    json
    {
      agents: {
        defaults: {
          model: { primary: "anthropic/claude-opus-4-6" },
          models: {
            "anthropic/claude-opus-4-6": {
              params: { cacheRetention: "long" }, // baseline for most agents
            },
          },
        },
        list: [
          { id: "research", default: true },
          { id: "alerts", params: { cacheRetention: "none" } }, // override for this agent only
        ],
      },
    }
  6. 6

    Enable 1M context window for supported Claude models

    context1m: true`. OpenClaw maps this to `anthropic-beta: context-1m-2025-08-07` and falls back gracefully if your auth mode does not support it.

    json
    {
      agents: {
        defaults: {
          models: {
            "anthropic/claude-opus-4-6": {
              params: { context1m: true },
            },
          },
        },
      },
    }

Configuration

OptionDescriptionExample
ANTHROPIC_API_KEYAnthropic API key used by OpenClaw to authenticate requests to Claude models.sk-ant-...
agents.defaults.model.primarySets the default primary model for all agents, here pointing to an Anthropic Claude 4.6 model.anthropic/claude-opus-4-6
agents.defaults.models["anthropic/claude-sonnet-4-6"].params.fastModeEnables OpenClaw’s `/fast` toggle mapping to Anthropic `service_tier` for the specified Claude model.
agents.defaults.models["anthropic/claude-opus-4-6"].params.cacheRetentionControls Anthropic prompt caching duration for the Claude Opus 4.6 model.long
agents.list[].params.cacheRetentionOverrides the cacheRetention setting for a specific agent using an Anthropic Claude model.none
agents.defaults.models["anthropic/claude-opus-4-6"].params.context1mEnables Anthropic’s 1M context window beta for the Claude Opus 4.6 model when your credential allows it.

Troubleshooting

401 errors / token suddenly invalid

Anthropic token auth can expire or be revoked, which surfaces as 401 errors. For new setup, migrate to an Anthropic API key and re-run onboarding so OpenClaw uses the fresh key.

No API key found for provider “anthropic”

Auth is per agent, so new agents do not inherit keys automatically. Re-run onboarding for that agent, or configure an API key on the gateway host, then verify the provider status.

bash
openclaw models status

No credentials found for profile `anthropic:default`

This means the expected Anthropic auth profile is missing or not configured. Check which auth profile is active, then re-run onboarding or add an API key for that profile path.

bash
openclaw models status

No available auth profile (all in cooldown/unavailable)

Anthropic rate-limit cooldowns can mark all profiles unusable for a given model. Inspect unusable profiles in JSON output, then either add another Anthropic profile or wait for the cooldown to expire.

bash
openclaw models status --json

Frequently asked questions

Powered by Mem0

Add persistent memory to OpenClaw

Official Mem0 plugin for OpenClaw keeps context across chats and tools. Smaller prompts, lower cost, better continuity for your agents.

More in Model providers