Fix API Key Problems in OpenClaw
Security Warning
Never share your clawhub.json or API keys in public Discord channels or GitHub issues.
API key errors are the #1 reason why OpenClaw agents fail to start. This guide covers how to identify and fix permission, quota, and synchronization issues.
Top 3 Common Errors
Invalid key or expired session. Check for leading/trailing spaces.
Zero balance or tier limits. Check provider dashboard.
Key doesn't have access to specific model (e.g. GPT-4o).
Step-by-Step Fix
1. Check for Spaces
Copy-pasting keys often includes a hidden space at the end. Open your clawhub.json and ensure the key is exactly between the quotes.
2. Verify Environment Variables
If you are using Docker, ensure variables are passed correctly in docker-compose.yml.
3. Use the Config Wizard
Still Failing?
Run our diagnostic tool to see if the issue is with the key itself or your network connectivity to the provider.
npx clawkit-doctor@latestSeeing Other Errors Too?
API issues often come with these related problems: