#Making my openclaw use claudecode instead of claude api.
1 messages · Page 1 of 1 (latest)
You can’t point OpenClaw at “Claude Code” as a model endpoint directly — OpenClaw still talks to the Anthropic provider. But you can use your $20 Claude subscription by authenticating Anthropic with a setup-token (generated by the Claude Code CLI), instead of an Anthropic API key.
Do this
- Generate a setup-token (on any machine where Claude Code is installed + you’re signed in):
claude setup-token
- Paste it on the machine running the OpenClaw Gateway:
openclaw models auth paste-token --provider anthropic
(If you have Claude Code installed on the gateway host too, you can also run:)
openclaw models auth setup-token --provider anthropic
- If you’re onboarding a new agent and want the wizard path:
openclaw onboard --auth-choice setup-token
- Verify:
openclaw models status
Docs:
Note: this is “works technically”, not a guarantee forever — Anthropic has blocked subscription usage outside Claude Code in the past. If you want the most stable production path, use an Anthropic API key.
HTTP 401 usually means “the credential OpenClaw is using is invalid / revoked / not the one you think it’s using”.
First: can you paste the exact error text that the Telegram bot replied with? (Redact any token strings.)
Then on the gateway host, run these and paste the output (again, redact secrets):
openclaw --version
openclaw models status
If you have multiple agents, the Telegram bot might be bound to a different one — then run:
openclaw agents bindings
openclaw models status --agent <thatAgentId>
Most common fix for Claude subscription (setup-token)
Re-generate a fresh setup-token and paste it again (they can expire / be revoked):
claude setup-token
openclaw models auth paste-token --provider anthropic
(If Claude Code is installed on the gateway host, you can also do:)
openclaw models auth setup-token --provider anthropic
Once you post openclaw models status + the exact 401 message, I can tell you whether it’s:
- Anthropic rejecting the token,
- the wrong agent/profile being used,
- or something else (like Telegram auth instead of Anthropic).
What did you get from the commands?
Please paste (redacted) output for:
openclaw --version
openclaw models status --probe-provider anthropic
Also: did you regenerate the token with claude setup-token and paste only the raw token string (no “setup token:” text, no quotes/spaces)?
Yep — authentication_error: invalid x-api-key means OpenClaw is sending something in the Anthropic API key header, and Anthropic is rejecting it.
Two things to check (no secrets needed):
- Are you accidentally using an OAuth access token (
sk-ant-oat-...) instead of a setup-token?
If the thing you pasted starts withsk-ant-oat-, that’s an OAuth-style token and Anthropic will reject it as anx-api-key. OpenClaw’s subscription path expects the value produced by exactly:
claude setup-token
…and you must copy only the raw token string (no “setup token:” prefix text, no quotes).
- Is OpenClaw actually using the credential you pasted (vs an env var / other profile)?
Please paste the output of this (redact anysk-ant-...strings if they appear):
openclaw --version
openclaw models status