"Invalid API key" error
What to check when your provider key is rejected.
What this is
Your agent is showing or logging an error like "invalid API key", "auth error", "401", or "unauthorized". This means your AI provider (Anthropic, OpenAI, Gemini, OpenRouter) is rejecting the key Beach is sending on your behalf. Almost always this is a copy-paste mistake, a revoked key, or a billing problem on the provider's side — not a Beach issue.
Try these in order
- Re-copy the key from your provider's dashboard. The most common causes of a rejected key are mundane: trailing whitespace, a missed first character, or you copied the label of the key instead of the key value itself. Re-copy carefully, then paste into a plain text editor first to spot stray characters.
- Confirm the key isn't revoked. Open your provider's dashboard, find the key in their list, and confirm it's still active. If you (or someone with access to your account) revoked it, Beach won't be told — you'll only see the failure when the agent tries to use it.
- Confirm your provider account has billing set up. Anthropic and OpenAI both require a payment method on file before any key will work, even on free credits. Gemini and OpenRouter have their own thresholds. Check your provider's billing page.
- Update the key in Beach Settings → AI Provider. Re-paste the working key and save. Updates take effect immediately — you don't need to restart your instance.
- Test by messaging your bot. A fresh message after a key update should get a normal reply.
Note on the boundary
Beach stores your provider key securely and passes it to OpenClaw to use — Beach itself never validates the key with the provider. The only way to know if the key works is to use it. If the provider rejects it, the error originates with them, surfaces in OpenClaw, and shows up to you in the Control UI or in your channel as a missing/error reply.
Related
- Switching providers & rotating keys
- Anthropic (Claude)
- OpenAI
- Google Gemini
- OpenRouter
- Getting support
Still stuck?
Contact support — see Getting support.