Troubleshooting
Troubleshooting
Common problems and solutions for AI coding agent setups.
API Key Issues
Missing API Key
Error: API key not found or Authentication required
Fix:
- Confirm the environment variable is set:
Terminal window echo $GEMINI_API_KEY - If empty, export it:
Terminal window export GEMINI_API_KEY="your-key" - Persist it by adding to your shell profile:
Terminal window echo 'export GEMINI_API_KEY="your-key"' >> ~/.bashrcsource ~/.bashrc - Restart your terminal or agent after setting the variable.
Invalid API Key
Error: 401 Unauthorized or Invalid API key
Fix:
- Verify the key hasn’t been revoked in the provider’s dashboard.
- Check for extra whitespace or newlines:
Terminal window echo "$GEMINI_API_KEY" | cat -A - Regenerate a new key in the provider console and update the environment variable.
- Ensure you’re using the correct key for the correct provider.
Key in Config File Not Loading
Error: Provider loads but key seems ignored
Fix:
- If using
${ENV_VAR}syntax in your config, the variable must be exported in the same shell session. - Verify the variable name matches exactly (case-sensitive).
- For OpenCode, check your
opencode.jsonuses the correct format.
Rate Limiting
429 Too Many Requests
Error: Rate limit exceeded or 429 status code
Fix:
- Wait — most rate limits reset after 60 seconds.
- Switch providers — move to a provider with higher limits or a free tier you haven’t exhausted:
- Groq free tier: generous limits
- Gemini free tier: good for light use
- DeepSeek: very low cost if you need to pay
- Upgrade your plan — paid tiers on most providers have higher rate limits.
- Add retry logic — some agents handle retries automatically. Check your agent’s configuration.
Tokens Per Minute (TPM) Limit
Error: Token rate limit exceeded
Fix:
- Reduce
maxTokensin your config:{ "maxTokens": 2048 } - Break large tasks into smaller requests.
- Switch to a model with higher TPM limits on your account.
Connection Timeouts
Request Timeout
Error: Connection timed out or ETIMEDOUT
Fix:
- Check your internet connection:
Terminal window curl -I https://generativelanguage.googleapis.com - Check if the provider’s API is down — visit the provider’s status page.
- Increase timeout settings if your agent supports it:
{ “timeout”: 60000 }
4. **Use a faster model** — switch from a large model (e.g., GPT-4o) to a smaller one (e.g., GPT-4o-mini) for quicker responses.5. **Proxy/firewall issues** — if you're behind a corporate proxy, ensure API domains are allowed.
### SSL/Certificate Errors
**Error:** `SSL certificate error` or `CERTIFICATE_VERIFY_FAILED`
**Fix:**1. Update your system's CA certificates: ```bash sudo apt update && sudo apt install ca-certificates- If behind a proxy, configure your environment to trust the proxy’s certificate.
Common Error Messages
model_not_found
Cause: The model name in your config doesn’t match what the provider expects.
Fix:
- Check the exact model name in the provider’s documentation.
- Common mistakes:
- Using
claude-3-sonnetinstead ofclaude-sonnet-4-20250514 - Using
gpt4instead ofgpt-4o - Using
gemini-proinstead ofgemini-2.0-flash
- Using
insufficient_quota
Cause: You’ve exceeded your billing quota or free tier credits.
Fix:
- Check usage in the provider’s dashboard.
- Add a payment method or upgrade your plan.
- Switch to a provider with remaining credits.
context_length_exceeded
Cause: Your input exceeds the model’s context window.
Fix:
- Reduce the size of your input (code files, prompts).
- Use a model with a larger context window:
- Gemini: up to 1M tokens
- Claude: up to 200K tokens
- Summarize or chunk large inputs before sending.
invalid_request_error
Cause: Malformed request or unsupported parameter.
Fix:
- Verify your config JSON is valid:
Terminal window cat opencode.json | python3 -m json.tool - Check that
maxTokensand other parameters are within the model’s supported range. - Remove any unsupported fields from your config.
network_error / ECONNREFUSED
Cause: Cannot reach the provider’s API endpoint.
Fix:
- Check DNS resolution:
Terminal window nslookup api.openai.com - Test connectivity:
Terminal window curl https://api.openai.com/v1/models - Disable VPN or proxy temporarily to isolate the issue.
- Check firewall rules allow outbound HTTPS (port 443).
Still Having Issues?
- Check the Provider Overview for provider-specific setup guides.
- Review your agent integration configuration.
- Consult your provider’s official documentation and status page.