SKILL.md
Anthropic Common Errors
Overview
Every Anthropic API error includes a type field and HTTP status code. Here are the real errors you'll hit and how to fix them.
Error Reference
Instructions
Step 1: authentication_error (401)
{"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}
Cause: API key is missing, malformed, or revoked. Fix:
# Verify key exists and starts with sk-ant-
echo $ANTHROPIC_API_KEY | head -c 10
# Should print: sk-ant-api
# Test directly
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "claude-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-sonnet-4-20250514","max_tokens":10,"messages":[{"role":"user","content":"hi"}]}'
Step 2: rate_limit_error (429)
{"type":"error","error":{"type":"rate_limit_error","message":"Number of request tokens has exceeded your per-minute rate limit"}}
Cause: Exceeded requests per minute (RPM) or tokens per minute (TPM). Fix:
// The SDK has built-in retries with backoff
const client = new Anthropic({
maxRetries: 3, // default is 2
});
// Or handle manually using the retry-after header
try {
const msg = await client.messages.create({ ... });
} catch (err) {
if (err instanceof Anthropic.RateLimitError) {
const retryAfter = err.headers?.['retry-after'];
await sleep(Number(retryAfter) * 1000 || 5000);
// retry...
}
}
Rate limit tiers (as of 2025):
| Tier | RPM | TPM (input) | TPM (output) |
|---|---|---|---|
| Tier 1 (free) |
