#⚠️ Agent failed before reply: No API key found for provider "anthropic". What happened?

1 messages · Page 1 of 1 (latest)

limpid crowBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

arctic marsh
#

⚠️ Agent failed before reply: No API key found for provider "anthropic".

What happened?

crude patrolBOT
#

Update (from the Mac crash / BlueBubbles setup):

We got it working. Two things were biting us:

  1. Gateway was crashing on startup because the BlueBubbles config had unsupported keys (host / port). Removing those stopped the crash loop.
  2. 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 provider anthropic”.

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:

  1. Gateway runs as a service (launchd/systemd) and doesn’t see your shell env

    • You set ANTHROPIC_API_KEY in your terminal, but the daemon doesn’t inherit it.
    • Fix: put the key in ~/.openclaw/.env on the gateway host or enable env.shellEnv.enabled, then openclaw gateway restart.
  2. 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.
  3. You’re using Claude subscription auth but never added a setup-token

    • You need a Claude setup-token (from claude setup-token), then openclaw models auth paste-token --provider anthropic (on the gateway host).

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:

arctic marsh
#

How do I get the API key?

crude patrolBOT
#

For Anthropic there are two different “credential” paths, depending on what you have:

A) You want an actual Anthropic API key (pay‑per‑token)

  1. Go to the Anthropic Console: https://console.anthropic.com/
  2. Open API Keys (usually under your account / developer settings)
  3. Create key → copy it (it’ll look like sk-ant-…)
  4. 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).

crude patrolBOT
#

Don’t post API keys in Discord — assume that key is compromised now.

Do this immediately:

  1. Delete that message (and any other place you pasted it).
  2. 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:

  1. Anthropic Console → API KeysRevoke that key and create a new one
  2. 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):

  1. Anthropic Console → API KeysRevoke that key, create a new one.

  2. Put the new key on the gateway host in ~/.openclaw/.env (don’t share it anywhere):

    ANTHROPIC_API_KEY=…

  3. 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.