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.
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
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
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.
Which Claude route fits your setup?
Set up Claude with an Anthropic API key
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.
Run onboarding
Choose Anthropic API key in the wizard, or pass the key directly:
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.
Pick a model and verify
openclaw models list --provider anthropic
openclaw models set anthropic/claude-opus-5-5
openclaw models status --probeWith an API key, OpenClaw refreshes the Claude catalog from Anthropic, so new snapshots of supported models appear without an OpenClaw update.
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.
Check Claude Code is installed and signed in
Run these as the same user that runs the OpenClaw gateway:
claude --version
claude auth status --text
claude auth login # only if you're not signed in
claude update # if OpenClaw says the build is incompatibleRun onboarding and choose Claude CLI
openclaw onboard
# choose: Claude CLIKeep the Anthropic model, set the CLI runtime
New configs keep the normal anthropic/* model and add a runtime override:
{
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.
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.
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:
claude setup-token
openclaw models auth login --provider anthropic --method setup-tokenIn 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.
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.
| Model | Reference | Alias | Thinking default | API price in / out* |
|---|---|---|---|---|
| Claude Opus 5.5 default | anthropic/claude-opus-5-5 | opus | medium | $4 / $20 |
| Claude Sonnet 5.5 | anthropic/claude-sonnet-5-5 | sonnet | high | $2 / $10 |
| Claude Fable 5.1 | anthropic/claude-fable-5-1 | fable | medium | $10 / $50 |
| Claude Opus 5 | anthropic/claude-opus-5 | opus-5 | high | $5 / $25 |
| Claude Sonnet 5 | anthropic/claude-sonnet-5 | sonnet-5 | high | $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.
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.
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.
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:
/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
offsetting becomeslow. - Changing the model or thinking level mid-session can drop Claude's earlier reasoning. Pick both when you start a session if continuity matters.
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.
cacheRetention | Cache lasts | Use when |
|---|---|---|
| short default | 5 minutes | Normal chat |
| long | 1 hour | Long sessions with pauses between messages |
| none | No cache | Bursty agents that rarely repeat a prompt |
{
agents: {
defaults: {
models: {
"anthropic/claude-opus-5-5": {
params: { cacheRetention: "long" },
},
},
},
},
}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.
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.
/fast on
/fast offAnthropic server-side compaction (beta) summarizes long histories on Anthropic's side. It's off by default and works only with an API key. Your full transcript stays local.
{
agents: {
defaults: {
models: {
"anthropic/claude-sonnet-5-5": {
params: { anthropicServerCompaction: true },
},
},
},
},
}With an API key, Opus 5.5, Opus 5, Sonnet 5.5 and Fable can hand a safety-classifier refusal to another Claude model that Anthropic recommends. That turn is billed at the rates of the model that answered. It doesn't apply to Claude CLI or setup tokens. If every turn must stay on the model you picked, don't use these models through the automatic fallback.
Add a backup from another provider so an Anthropic outage or rate limit doesn't stop your assistant:
openclaw models fallbacks add <provider/model>
openclaw models fallbacks listSee model setup for how fallbacks and key rotation work.
Fix common Claude connection errors
Claude CLI session expiredAs 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 invalidSetup 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 cooldownYou 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 PodmanThe container can't see your ~/.claude login. Use an API key in containers, or follow the Docker sign-in steps.
More fixes: troubleshooting guide.
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.