Claude 4 API error, Claude 4 model not found, Claude 4 deprecated error, Claude 4 API shutdown, fix Claude 4 error, Claude 4 API broken, claude-4-opus error, claude-sonnet-4 error">
โ† Back to blog

Claude 4 API Errors After June 15: How to Fix Them

Getting model not found or deprecated model errors from the Claude API? Claude 4 Opus and Sonnet 4 retire on June 15, 2026. You have 13 days to fix them. Here's every error you'll see and exactly how to resolve each one.

--
Days Left
June 15
Deadline
5
Common Errors
~5min
Fix Time

TL;DR: Replace claude-4-opus with claude-opus-4-8 and claude-sonnet-4 with claude-sonnet-4-6 everywhere in your code. Same API key, same SDK, same endpoint โ€” just a model name change. Fix takes ~5 minutes.

Error #1: "Model Not Found" (404)

This is the most common error after June 15. The API can't find the model because the name has been retired.

Error Response
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "model 'claude-4-opus' not found"
  }
}

Why it happens: The model ID claude-4-opus no longer exists after June 15. The API returns a 404 because the model has been removed from Anthropic's infrastructure.

Fix

Replace the model name in your code:

Error-causing modelReplace with
claude-4-opusclaude-opus-4-8
claude-sonnet-4claude-sonnet-4-6

Python fix

# Before (causes error)
client.messages.create(
    model="claude-4-opus",
    messages=[{"role": "user", "content": "Hello"}]
)

# After (works)
client.messages.create(
    model="claude-opus-4-8",
    messages=[{"role": "user", "content": "Hello"}]
)

Node.js fix

// Before (causes error)
const response = await anthropic.messages.create({
    model: "claude-4-opus",
    messages: [{ role: "user", content: "Hello" }]
});

// After (works)
const response = await anthropic.messages.create({
    model: "claude-opus-4-8",
    messages: [{ role: "user", content: "Hello" }]
});

cURL fix

# Before (causes error)
curl https://api.anthropic.com/v1/messages \
  -d '{"model": "claude-4-opus", ...}'

# After (works)
curl https://api.anthropic.com/v1/messages \
  -d '{"model": "claude-opus-4-8", ...}'

Error #2: "Deprecated Model" (400)

During the deprecation window (before June 15), you may see a warning or error indicating the model is deprecated.

Error Response
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "model 'claude-sonnet-4' is deprecated. Use 'claude-sonnet-4-6' instead."
  }
}

Why it happens: Anthropic may return deprecation warnings even before June 15, especially if they accelerate the retirement timeline. Some API versions surface these as errors rather than warnings.

Fix

Same as Error #1 โ€” update the model name. The error message itself tells you the replacement. If you see "Use 'claude-sonnet-4-6' instead", that's exactly what you should do.

Error #3: "Invalid Model" in SDK Response

Some SDK versions validate model names client-side before sending the request. You may get a different error depending on your SDK version.

Error Response (Python SDK)
anthropic.BadRequestError: Error code: 400 - {
  "error": {
    "type": "invalid_request_error",
    "message": "Invalid model name: claude-4-opus"
  }
}
Error Response (Node.js SDK)
Anthropic.InvalidRequestError: Invalid model name: claude-sonnet-4
Fix

Update your SDK to the latest version and change the model name. Older SDK versions may have hardcoded model validation that rejects deprecated names before they even reach the API.

# Update Python SDK
pip install --upgrade anthropic

# Update Node.js SDK
npm update @anthropic-ai/sdk

Error #4: "Rate Limit" or "Quota Exceeded" on New Models

If you've just migrated and suddenly hit rate limits, it's not a migration bug โ€” it's a new rate limit bucket.

Error Response
{
  "type": "error",
  "error": {
    "type": "rate_limit_error",
    "message": "Rate limit exceeded. Please retry after 60 seconds."
  }
}

Why it happens: Each model has its own rate limit. When you switch from claude-4-opus to claude-opus-4-8, you're hitting a fresh rate limit bucket. If your app sends high volume, you may exhaust the new model's limits faster than expected.

Fix
  1. Add retry logic with exponential backoff
  2. Check your Anthropic dashboard for your rate limit on the new model
  3. Request a rate limit increase if needed
# Python โ€” simple retry with backoff
import time

def call_with_retry(fn, max_retries=3):
    for i in range(max_retries):
        try:
            return fn()
        except anthropic.RateLimitError:
            if i == max_retries - 1:
                raise
            time.sleep(2 ** i)  # 1s, 2s, 4s

Error #5: "Authentication Failed" (401)

If you're getting 401 errors after migration, the issue isn't the model name โ€” it's your API key or headers.

Error Response
{
  "type": "error",
  "error": {
    "type": "authentication_error",
    "message": "invalid x-api-key"
  }
}

Why it happens: This is usually a coincidence with the migration โ€” your API key may have been rotated, expired, or your environment variables aren't loading correctly. The model name change itself doesn't affect authentication.

Fix
  1. Verify your ANTHROPIC_API_KEY environment variable is set correctly
  2. Check that you're passing the key in the x-api-key header (not Authorization: Bearer)
  3. Generate a new key from the Anthropic Console if needed

Quick Diagnostic: Find All Deprecated Model References

Run these commands to find every reference to deprecated Claude 4 models in your codebase:

# Find all Claude 4 Opus references
grep -r "claude-4-opus" . --include="*.js" --include="*.py" --include="*.ts" \
  --include="*.json" --include="*.yaml" --include="*.yml" --include="*.env" \
  --include="*.toml" --include="*.cfg"

# Find all Claude Sonnet 4 references
grep -r "claude-sonnet-4" . --include="*.js" --include="*.py" --include="*.ts" \
  --include="*.json" --include="*.yaml" --include="*.yml" --include="*.env" \
  --include="*.toml" --include="*.cfg"

Also check these often-missed locations:

The Complete Fix: Model Name Mapping

Deprecated ModelReplacementPrice ChangeContext Window
claude-4-opus claude-opus-4-8 $15/$75 โ†’ $5/$25 (67% cheaper) 200K โ†’ 1M
claude-sonnet-4 claude-sonnet-4-6 $3/$15 โ†’ $3/$15 (same) 200K โ†’ 1M

Good news: Migrating doesn't just fix errors โ€” it saves money. Claude Opus 4.8 is 67% cheaper than Claude 4 Opus, with a 5x larger context window. You're not just fixing a bug; you're upgrading.

Calculate your savings after fixing the error

See exactly how much you'll save by switching from Claude 4 to the new models.

Deprecation Calculator โ†’ Migration Tool โ†’

๐Ÿšจ June 15 deadline: See all 34 alternatives, calculate your savings, and get migration code on our Claude 4 Deprecation Hub.

How to Prevent These Errors (If You Haven't Migrated Yet)

You have 13 days before the deadline. Here's the fastest path:

  1. Search your code โ€” Run the grep commands above. Find every claude-4-opus and claude-sonnet-4 reference.
  2. Replace model names โ€” Use the mapping table above. One-line change per file.
  3. Test โ€” Both old and new model names work until June 15, so run parallel tests now.
  4. Deploy โ€” Push to production. No infrastructure changes needed โ€” same API key, same SDK.

Need help? Our complete 8-step checklist walks through every detail. Our migration tool compares all 34 alternatives with your exact usage.

Related Resources

Don't wait for the errors โ€” migrate now

Fix the errors before they happen. Calculate savings, compare alternatives, and switch in under an hour.

Deprecation Calculator โ†’ Migration Tool โ†’ Get the Checklist โ†’