#⚠️ Agent failed before reply: No API key found for provider "anthropic". What happened?
1 messages · Page 1 of 1 (latest)
⚠️ Agent failed before reply: No API key found for provider "anthropic".
What happened?
Update (from the Mac crash / BlueBubbles setup):
We got it working. Two things were biting us:
- Gateway was crashing on startup because the BlueBubbles config had unsupported keys (
host/port). Removing those stopped the crash loop. - Auth mismatch: the token/API key the gateway process actually saw (launchd plist env) didn’t match what was in
openclaw.json, so it looked like “No API key found for provideranthropic”.
After aligning the env/config and restarting the gateway, it’s stable again.
If this unblocks you too, please right‑click the solution message → Apps → ✅ Mark Solution so Answer Overflow can index it.
That error is coming from the model/auth layer before the agent even starts, so you get “failed before reply” (no tokens spent). It simply means: the Gateway tried to use an Anthropic model, but it couldn’t find any Anthropic credential for the agent that’s running.
The 3 most common causes:
-
Gateway runs as a service (launchd/systemd) and doesn’t see your shell env
- You set
ANTHROPIC_API_KEYin your terminal, but the daemon doesn’t inherit it. - Fix: put the key in
~/.openclaw/.envon the gateway host or enableenv.shellEnv.enabled, thenopenclaw gateway restart.
- You set
-
You’re editing/using the wrong profile/agent
- Multi-agent = auth is stored per agent in
~/.openclaw/agents/<agentId>/agent/auth-profiles.json. - If you created a new agent, it won’t magically inherit the main agent’s keys.
- Multi-agent = auth is stored per agent in
-
You’re using Claude subscription auth but never added a setup-token
- You need a Claude setup-token (from
claude setup-token), thenopenclaw models auth paste-token --provider anthropic(on the gateway host).
- You need a Claude setup-token (from
To triage fast, can you paste the output of:
openclaw --version
openclaw status --all
openclaw models status
Those will usually make it obvious whether it’s “env missing in service”, “wrong config path”, or “no auth profile”.
Docs that cover this exact failure mode:
- https://docs.openclaw.ai/providers/anthropic
- https://docs.openclaw.ai/help/faq (see env vars + “I started the Gateway via the service and my env vars disappeared”)
How do I get the API key?
For Anthropic there are two different “credential” paths, depending on what you have:
A) You want an actual Anthropic API key (pay‑per‑token)
- Go to the Anthropic Console: https://console.anthropic.com/
- Open API Keys (usually under your account / developer settings)
- Create key → copy it (it’ll look like
sk-ant-…) - Put it on the gateway host (not just your laptop shell), e.g. in
~/.openclaw/.env:
ANTHROPIC_API_KEY=sk-ant-...
Then restart the gateway: openclaw gateway restart.
B) You have a Claude Pro/Max subscription (often no API key)
You usually won’t get an API key from the subscription UI. Instead use a setup-token:
claude setup-token
Then paste it into OpenClaw on the gateway host:
openclaw models auth paste-token --provider anthropic
Docs (official OpenClaw flow): https://docs.openclaw.ai/providers/anthropic
If you tell me whether you’re using API billing or Claude subscription, I can point you at the exact quickest setup path (wizard vs CLI).
Don’t post API keys in Discord — assume that key is compromised now.
Do this immediately:
- Delete that message (and any other place you pasted it).
- Go to the Anthropic Console → API Keys and revoke/rotate that key right now (create a new one).
Then set the new key on the gateway host (not in chat), e.g. in ~/.openclaw/.env:
ANTHROPIC_API_KEY=sk-ant-...
Restart + verify:
openclaw gateway restart
openclaw models status
If you paste the output of openclaw models status (it redacts secrets), I can sanity-check that the gateway is actually picking it up.
I deleted the most recent API key you posted (for your safety). If you pasted it anywhere else in this thread/history, delete those too.
Either way: assume the key is burned now.
Do this now:
- Anthropic Console → API Keys → Revoke that key and create a new one
- Put the new key on the gateway host in
~/.openclaw/.env(never in Discord), then:
openclaw gateway restart
openclaw models status
Paste only the output of openclaw models status here (it redacts secrets) and we’ll confirm it’s picked up.
⚠️ ✉️ Message: 1482863880110866512 failed
Stop pasting the key — every time it’s posted, it’s effectively public.
Good news: I’m not seeing that key string show up in the thread search anymore, so it may already be removed. Bad news: you still need to treat it as compromised and revoke/rotate it in the Anthropic Console.
What to do (again, but in the safe order):
-
Anthropic Console → API Keys → Revoke that key, create a new one.
-
Put the new key on the gateway host in
~/.openclaw/.env(don’t share it anywhere):ANTHROPIC_API_KEY=… -
Restart + verify:
openclaw gateway restart
openclaw models status
Paste only the openclaw models status output here (it redacts secrets). That’s the right way to confirm it’s fixed without leaking credentials.