Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Diagnose and fix Anthropic API errors — authentication, rate limits, Use when working with common-errors patterns. overloaded, context length, and content policy issues. Trigger with "anthropic error", "claude 429", "claude overloaded", "anthropic not working", "debug claude api".
.claude/skills/jeremylongshore-clade-common-errors/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 37% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 53% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 51% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 0% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 126% | 0% |
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.
authentication_error (401)json{"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}
Cause: API key is missing, malformed, or revoked. Fix:
bash# 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"}]}'
rate_limit_error (429)json{"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:
typescript// 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) | 50 | 40,000 | 8,000 | | Tier 2 ($40+) | 1,000 | 80,000 | 16,000 | | Tier 3 ($200+) | 2,000 | 160,000 | 32,000 | | Tier 4 ($400+) | 4,000 | 400,000 | 80,000 |
overloaded_error (529)json{"type":"error","error":{"type":"overloaded_error","message":"Overloaded"}}
Cause: Anthropic API is temporarily at capacity. This is NOT a rate limit — it's server load. Fix:
typescript// SDK retries 529s automatically. Increase retries if needed: const client = new Anthropic({ maxRetries: 5 }); // For critical paths, implement fallback: try { return await client.messages.create({ model: 'claude-sonnet-4-20250514', ... }); } catch (err) { if (err instanceof Anthropic.APIError && err.status === 529) { // Fall back to a different model or provider return await client.messages.create({ model: 'claude-haiku-4-5-20251001', ... }); } throw err; }
invalid_request_error (400)json{"type":"error","error":{"type":"invalid_request_error","message":"messages: roles must alternate between \"user\" and \"assistant\", but found multiple \"user\" roles in a row"}}
Common causes:
max_tokens missing or exceeds model limitmodel IDFix: Validate messages before sending:
typescriptfunction validateMessages(messages: Anthropic.MessageParam[]) { for (let i = 1; i < messages.length; i++) { if (messages[i].role === messages[i - 1].role) { throw new Error(`Messages must alternate roles. Index ${i} has same role as ${i-1}`); } } if (messages[0]?.role !== 'user') { throw new Error('First message must be from user'); } }
not_found_error (404)json{"type":"error","error":{"type":"not_found_error","message":"model: model_not_found"}}
Cause: Invalid model ID or model not available on your plan. Fix: Use exact model IDs:
claude-opus-4-20250514claude-sonnet-4-20250514claude-haiku-4-5-20251001json{"type":"error","error":{"type":"invalid_request_error","message":"prompt is too long: 204521 tokens > 200000 maximum"}}
Fix:
typescript// Count tokens before sending (use Anthropic's token counting) const count = await client.messages.countTokens({ model: 'claude-sonnet-4-20250514', messages, }); console.log(`Input tokens: ${count.input_tokens}`); if (count.input_tokens > 180000) { // Truncate conversation history, keeping system + last N messages messages = [messages[0], ...messages.slice(-10)]; }
bash# Check API status curl -s https://status.anthropic.com/api/v2/status.json | jq '.status.description' # Verify API key works curl -s 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":"ping"}]}' | jq '.content[0].text' # Check current usage/limits # (No API for this — check console.anthropic.com/settings/limits)
| Error | Cause | Solution | |-------|-------|----------| | API Error | Check error type and status code | See clade-common-errors |
Each error section above includes the exact JSON error response, cause analysis, and fix code. See Quick Diagnostic section for curl commands to test connectivity.
For deeper debugging, see clade-debug-bundle.
@claude-ai/sdk or anthropic)| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 16,200 | 10,774 | -33% | 1 | 1 | 0% | 3,038 | 4,162 | +37% | 0 | 0 | — |
case-02 | fail→pass | 11,730 | 9,104 | -22% | 1 | 1 | 0% | 2,429 | 3,721 | +53% | 0 | 0 | — |
case-03 | fail→pass | 11,662 | 6,222 | -47% | 1 | 1 | 0% | 2,118 | 3,204 | +51% | 0 | 0 | — |
case-04 | fail→pass | 15,571 | 5,921 | -62% | 1 | 1 | 0% | 3,109 | 3,103 | -0% | 0 | 0 | — |
case-05 | pass→pass | 10,681 | 1,781 | -83% | 1 | 1 | 0% | 2,067 | 2,216 | +7% | 0 | 0 | — |
case-06 | pass→pass | 13,771 | 2,040 | -85% | 1 | 1 | 0% | 1,579 | 2,307 | +46% | 0 | 0 | — |
case-07 | pass→pass | 9,946 | 1,904 | -81% | 1 | 1 | 0% | 1,857 | 2,206 | +19% | 0 | 0 | — |
case-22 | pass→pass | 11,205 | 11,526 | +3% | 1 | 1 | 0% | 2,334 | 4,251 | +82% | 0 | 0 | — |
case-08 | pass→pass | 9,307 | 1,944 | -79% | 1 | 1 | 0% | 1,731 | 2,238 | +29% | 0 | 0 | — |
case-09 | fail→fail | 3,611 | 3,236 | -10% | 1 | 1 | 0% | 645 | 2,520 | +291% | 0 | 0 | — |
case-10 | fail→pass | 4,825 | 1,777 | -63% | 1 | 1 | 0% | 959 | 2,165 | +126% | 0 | 0 | — |
case-11 | fail→pass | 2,837 | 2,538 | -11% | 1 | 1 | 0% | 399 | 2,350 | +489% | 0 | 0 | — |
case-12 | fail→pass | 13,554 | 9,567 | -29% | 1 | 1 | 0% | 2,489 | 3,809 | +53% | 0 | 0 | — |
case-13 | fail→fail | 4,427 | 4,800 | +8% | 1 | 1 | 0% | 816 | 2,801 | +243% | 0 | 0 | — |
case-14 | fail→pass | 4,913 | 4,859 | -1% | 1 | 1 | 0% | 918 | 2,766 | +201% | 0 | 0 | — |
case-15 | pass→pass | 14,027 | 7,517 | -46% | 1 | 1 | 0% | 2,391 | 3,294 | +38% | 0 | 0 | — |
case-16 | fail→pass | 14,111 | 5,383 | -62% | 1 | 1 | 0% | 1,811 | 3,015 | +66% | 0 | 0 | — |
case-17 | fail→pass | 6,960 | 2,336 | -66% | 1 | 1 | 0% | 1,217 | 2,251 | +85% | 0 | 0 | — |
case-18 | pass→pass | 7,559 | 3,419 | -55% | 1 | 1 | 0% | 1,260 | 2,398 | +90% | 0 | 0 | — |
case-19 | fail→pass | 9,094 | 2,806 | -69% | 1 | 1 | 0% | 1,686 | 2,386 | +42% | 0 | 0 | — |
case-20 | pass→pass | 9,358 | 5,893 | -37% | 1 | 1 | 0% | 1,621 | 2,836 | +75% | 0 | 0 | — |
case-21 | pass→pass | 10,736 | 13,498 | +26% | 1 | 1 | 0% | 1,681 | 3,324 | +98% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +50 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.