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.
Next Step
Fix now, then reduce repeat incidents
If this issue keeps coming back, validate your setup in Doctor first, then harden your config.
Jump to Fix
The Error
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:
{
"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:
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:
# 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:
"provider": "openai", "model": "claude-sonnet-4-5"
"provider": "claude", "model": "claude-sonnet-4-5"
"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):
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.
openclaw config --path
Don't Have an Anthropic Key?
Get one from the Anthropic console:
- 1. Go to console.anthropic.com and sign in (or create an account)
- 2. Click API Keys in the left sidebar
- 3. Click Create Key
- 4. Copy the key โ it starts with
sk-ant- - 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
Checks API key presence, provider config, and validates the key format automatically.
Related Issues
Other API key and provider errors:
Fix It Faster With Our Tools
Config Wizard
Generate a production-ready clawhub.json in 30 seconds.
Local Doctor
Diagnose Node.js, permissions, and config issues instantly.
Cost Simulator
Calculate your agent burn rate before you get surprised.
Gateway Monitor
Detect token spikes and gateway incidents before users complain.
Skill Finder
Describe your use case and find the right Claude Code skill instantly.
Did this guide solve your problem?