How to Connect Claude to OpenClaw

OpenClaw works with Anthropic's Claude models in two ways: an Anthropic API key with pay-as-you-go billing, or your existing Claude Code sign-in. This guide shows which route to choose, the exact setup commands, how to pick Opus, Sonnet or Fable, and how to tune thinking, caching and cost.

Quick answer

Create a key in the Anthropic Console, then run openclaw onboard --anthropic-api-key "$ANTHROPIC_API_KEY". Choose a model with openclaw models set anthropic/claude-opus-5-5 and check it with openclaw models list --provider anthropic. Already use Claude Code? Run openclaw onboard and choose Claude CLI.

Two routes

API key or Claude CLI: which should you use?

Both routes give OpenClaw the same Claude models. The difference is how you pay and where OpenClaw can run.

recommended for production

Anthropic API key

  • Pay-as-you-go billing, separate from any Claude plan
  • Works anywhere: VPS, Docker, Podman, Raspberry Pi
  • Unlocks prompt caching, fast mode, server-side compaction and usage reports
  • You pay for every token, so set a spending limit
uses your Claude plan

Claude CLI (Claude Code sign-in)

  • No separate API key. Reuses your Claude Code login.
  • Claude Code manages the login and token refresh
  • Uses your subscription's usage limits
  • OpenClaw must run on the same machine as the Claude login
What the official docs recommend

OpenClaw's docs call API-key auth "the safer recommended path" for Anthropic in production. Claude CLI reuse is supported, but Anthropic can change how plan usage is counted without an OpenClaw release. Check Anthropic's support pages for your plan before relying on it.

Route picker

Which Claude route fits your setup?

Where does OpenClaw run?
How do you want to pay?
Who uses it?
Recommendation
    Go to API key setup
    Route 1

    Set up Claude with an Anthropic API key

    1

    Create a key in the Anthropic Console

    Sign in at console.anthropic.com, create an API key, and set a monthly spend limit for your workspace. Use a separate key for OpenClaw so you can revoke it on its own.

    2

    Run onboarding

    Choose Anthropic API key in the wizard, or pass the key directly:

    Terminal
    export ANTHROPIC_API_KEY="sk-ant-..."
    openclaw onboard --anthropic-api-key "$ANTHROPIC_API_KEY"

    Prefer a file? Put ANTHROPIC_API_KEY=sk-ant-... in ~/.openclaw/.env so the background gateway can read it after restarts.

    3

    Pick a model and verify

    Terminal
    openclaw models list --provider anthropic
    openclaw models set anthropic/claude-opus-5-5
    openclaw models status --probe

    With an API key, OpenClaw refreshes the Claude catalog from Anthropic, so new snapshots of supported models appear without an OpenClaw update.

    Route 2

    Set up Claude with your Claude Code sign-in

    OpenClaw runs the installed Claude Code program for each turn. It never reads, stores or refreshes your Claude login tokens. Claude Code keeps control of them.

    1

    Check Claude Code is installed and signed in

    Run these as the same user that runs the OpenClaw gateway:

    Terminal
    claude --version
    claude auth status --text
    claude auth login     # only if you're not signed in
    claude update         # if OpenClaw says the build is incompatible
    2

    Run onboarding and choose Claude CLI

    Terminal
    openclaw onboard
    # choose: Claude CLI
    3

    Keep the Anthropic model, set the CLI runtime

    New configs keep the normal anthropic/* model and add a runtime override:

    ~/.openclaw/openclaw.json (JSON5)
    {
      agents: {
        defaults: {
          model: { primary: "anthropic/claude-opus-5-5" },
          models: {
            "anthropic/claude-opus-5-5": {
              agentRuntime: { id: "claude-cli" },
            },
          },
        },
      },
    }

    Older claude-cli/… model refs still work, but the format above is the current one.

    Same machine only

    Claude CLI reuse needs OpenClaw on the same host as the Claude login. Docker installs can sign in to Claude Code inside the container's saved home folder (see the Docker guide). Podman and other containers don't see your ~/.claude, so use an API key there. If the Claude program can't run, OpenClaw fails the turn. It does not silently switch to paid API billing.

    Headless option

    Use a Claude setup token

    On any machine with Claude Code, claude setup-token prints a long-lived token starting with sk-ant-oat01-. Store it in OpenClaw:

    Terminal
    claude setup-token
    openclaw models auth login --provider anthropic --method setup-token

    In the macOS app, choose Anthropic setup-token under Connect with an API key or token. Setup tokens are still supported, but OpenClaw prefers Claude CLI reuse when it's available. Tokens can expire or be revoked, so for new setups the docs suggest an API key.

    Models

    Choose a Claude model

    Use the full reference, or one of the short aliases, with openclaw models set. Fresh setups default to Opus 5.5.

    ModelReferenceAliasThinking defaultAPI price in / out*
    Claude Opus 5.5 defaultanthropic/claude-opus-5-5opusmedium$4 / $20
    Claude Sonnet 5.5anthropic/claude-sonnet-5-5sonnethigh$2 / $10
    Claude Fable 5.1anthropic/claude-fable-5-1fablemedium$10 / $50
    Claude Opus 5anthropic/claude-opus-5opus-5high$5 / $25
    Claude Sonnet 5anthropic/claude-sonnet-5sonnet-5high$2 / $10

    *US dollars per million tokens for API-key billing, as listed in OpenClaw's model catalog. Check Anthropic's pricing page for current rates. All five models have a 1,000,000-token context window and up to 128,000 output tokens.

    Aliases move, pinned versions don't

    opus, sonnet and fable always point to the newest model in that family, so an OpenClaw update can move them. To stay on one version, use a versioned name such as sonnet-5 or anthropic/claude-opus-5.

    Make it yours

    Claude config builder

    Build your Claude settings

    Pick your route, model and options. Copy the result into ~/.openclaw/openclaw.json, then run openclaw gateway restart.

    ~/.openclaw/openclaw.json (JSON5)
    Reasoning

    Control how hard Claude thinks

    Current Claude models use adaptive thinking: they decide how much to reason, guided by an effort level. Change it from any chat:

    In a chat with your assistant
    /think low       # faster and cheaper
    /think high      # harder problems
    /think default   # back to the model's default
    • Sonnet 5.5 also accepts /think off, which turns off up-front thinking.
    • Opus 5.5 and Fable can't turn thinking off. A saved off setting becomes low.
    • Changing the model or thinking level mid-session can drop Claude's earlier reasoning. Pick both when you start a session if continuity matters.
    Spend less

    Prompt caching and cost tracking

    With an API key, OpenClaw caches the repeated part of each prompt automatically. Cache reads cost a fraction of normal input.

    cacheRetentionCache lastsUse when
    short default5 minutesNormal chat
    long1 hourLong sessions with pauses between messages
    noneNo cacheBursty agents that rarely repeat a prompt
    ~/.openclaw/openclaw.json (JSON5)
    {
      agents: {
        defaults: {
          models: {
            "anthropic/claude-opus-5-5": {
              params: { cacheRetention: "long" },
            },
          },
        },
      },
    }
    See real spend in the Control UI

    Add an Anthropic Admin API key as ANTHROPIC_ADMIN_KEY. The Usage page then shows 30 days of actual cost from Anthropic: daily spend, token and cache totals, and top models. More: OpenClaw running costs.

    Advanced

    Fast mode, compaction and refusal fallback

    For Opus 5.5, Opus 5 and Opus 4.8 with an API key, /fast on uses Anthropic's fast mode (a research preview, up to 2.5x faster output). It costs more: $8 / $40 per million tokens on Opus 5.5. Your account needs fast-mode access. Sonnet models don't support it.

    In a chat
    /fast on
    /fast off
    Troubleshooting

    Fix common Claude connection errors

    Claude CLI session expired

    As the gateway user, run claude auth status --text, then claude auth login, then openclaw gateway restart. Don't copy OAuth tokens into OpenClaw.

    401 / token suddenly invalid

    Setup tokens can expire or be revoked. Switch to an Anthropic API key for a stable setup.

    No API key found for provider "anthropic"

    Check that agent with openclaw models status --agent <id>. Add an API key on the gateway host, or set up auth for that agent.

    No credentials for "anthropic:default"

    Run openclaw models status to see the active profile, then re-run openclaw onboard.

    All profiles in cooldown

    You hit rate limits. Check openclaw models status --json. Another Claude model may still work, or add a second profile or a fallback.

    Claude CLI doesn't work in Podman

    The container can't see your ~/.claude login. Use an API key in containers, or follow the Docker sign-in steps.

    More fixes: troubleshooting guide.

    FAQ

    Claude and OpenClaw questions

    Can I use my Claude subscription with OpenClaw?

    Yes, through the Claude CLI route, which reuses your Claude Code sign-in on the same machine. Usage counts against your plan's limits, and Anthropic can change those rules. For production and shared automation, OpenClaw recommends an Anthropic API key.

    Which Claude model should I use with OpenClaw?

    Fresh setups default to Claude Opus 5.5. Sonnet 5.5 costs less per token and suits everyday tasks. Fable 5.1 is the most expensive option. Set your choice with openclaw models set followed by the model reference.

    Where do I get an Anthropic API key?

    Create one in the Anthropic Console at console.anthropic.com, then set a monthly spend limit. Pass it to openclaw onboard with --anthropic-api-key or put ANTHROPIC_API_KEY in ~/.openclaw/.env.

    Does OpenClaw store my Claude Code login?

    No. On the Claude CLI route, OpenClaw runs the installed Claude Code program and never reads, stores or refreshes its login tokens. Claude Code manages the login.

    Why does my Claude model change after an update?

    The aliases opus, sonnet and fable point to the newest model in each family. Use a versioned name such as sonnet-5 or anthropic/claude-opus-5 to stay on one version.

    Can I use Claude through AWS Bedrock or Google Vertex?

    Yes. OpenClaw supports Claude on Bedrock, Vertex and Foundry through those providers. Some Anthropic-only features, such as fast mode and the refusal fallback, apply only to direct API-key requests to Anthropic.

    Related guides