ClawKit Logo
ClawKitReliability Toolkit

Fix: No API Key Found for Provider "anthropic"

Anthropic Provider Has No Key

OpenClaw is configured to use an Anthropic model (Claude), but the apiKey for the anthropic provider is missing or not being read. The gateway cannot make any LLM calls until this is set.

This error means exactly what it says: OpenClaw looked for an Anthropic API key and found nothing. It usually happens after a fresh install, after switching models, or when the config was reset. The fix takes about 2 minutes.

Related fallback regression: openclaw/openclaw#28927.

Next Step

Fix now, then reduce repeat incidents

If this issue keeps coming back, validate your setup in Doctor first, then harden your config.

The Error

Error: No API key found for provider "anthropic".
agent failed before reply: no api key found for provider "anthropic"
[llm] anthropic: missing apiKey โ€” cannot initialize provider

The second variant (agent failed before reply) means the agent started, tried to call Claude, and failed at the first LLM request. No response is delivered to your chat channel.

Fix A: Add apiKey to openclaw.json (Most Common)

Open your openclaw.json and make sure the llm section looks like this:

openclaw.json โ€” Anthropic provider with key
{
  "llm": {
    "provider": "anthropic",
    "apiKey": "sk-ant-YOUR-KEY-HERE",
    "model": "claude-sonnet-4-5"
  }
}

provider is "anthropic" (not "claude" or "claude-ai")

OpenClaw matches provider names exactly โ€” "claude" will not work

apiKey starts with sk-ant-

Anthropic keys always start with sk-ant-. If yours starts with sk- only, it may be an OpenAI key

No trailing spaces or line breaks in the key

Copy-paste from the Anthropic console directly, not from a text editor that may add formatting

After saving the config, restart the gateway:

Restart gateway
openclaw gateway restart

Fix B: Use Environment Variable Instead

If you prefer not to put the key directly in openclaw.json (e.g. the file is in a shared repo), set it as an environment variable:

Set via environment variable
# Add to your shell profile or .env file
export ANTHROPIC_API_KEY=sk-ant-YOUR-KEY-HERE

# Then start or restart the gateway
openclaw gateway restart

OpenClaw reads ANTHROPIC_API_KEY automatically when no apiKey is set in the config. If both are set, the config value takes precedence.

In Docker, pass the env var via -e ANTHROPIC_API_KEY=sk-ant-... or in your docker-compose.yml under environment:. The variable must be available to the gateway process at startup.

Fix C: Wrong Provider Name

A common mistake is specifying a Claude model name in the model field while leaving provider as something else (or blank). OpenClaw does not infer the provider from the model name:

โŒ Wrong
"provider": "openai",
"model": "claude-sonnet-4-5"
โŒ Wrong
"provider": "claude",
"model": "claude-sonnet-4-5"
โœ… Correct
"provider": "anthropic",
"model": "claude-sonnet-4-5"

Fix D: Key Exists But Still Getting the Error

If you can see the key in openclaw.json but the error persists, the gateway may be reading a cached or stale config. Try a full stop and start (not just restart):

Full gateway stop and start
openclaw gateway stop
# wait 3 seconds
openclaw gateway start

Also check that you're editing the right file. OpenClaw looks for config at ~/.openclaw/openclaw.json by default. If you edited a different copy, the running gateway won't see it.

Find the actual config path
openclaw config --path

Don't Have an Anthropic Key?

Get one from the Anthropic console:

  1. 1. Go to console.anthropic.com and sign in (or create an account)
  2. 2. Click API Keys in the left sidebar
  3. 3. Click Create Key
  4. 4. Copy the key โ€” it starts with sk-ant-
  5. 5. Add billing under Plans & Billing if you hit 429 rate limit errors on the free tier

Want to use a different model instead?

OpenClaw supports OpenRouter, OpenAI, Ollama, and other providers. If you don't want an Anthropic key, change provider to your preferred provider and set the corresponding key. See the guides for provider-specific setup.

Run the Doctor

npx clawkit-doctor@latest

Checks API key presence, provider config, and validates the key format automatically.

Did this guide solve your problem?