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.
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.
{
"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.
Replace the model name in your code:
| Error-causing model | Replace with |
|---|---|
claude-4-opus | claude-opus-4-8 |
claude-sonnet-4 | claude-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.
{
"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.
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.
anthropic.BadRequestError: Error code: 400 - {
"error": {
"type": "invalid_request_error",
"message": "Invalid model name: claude-4-opus"
}
}
Anthropic.InvalidRequestError: Invalid model name: claude-sonnet-4
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.
{
"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.
- Add retry logic with exponential backoff
- Check your Anthropic dashboard for your rate limit on the new model
- 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.
{
"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.
- Verify your
ANTHROPIC_API_KEYenvironment variable is set correctly - Check that you're passing the key in the
x-api-keyheader (notAuthorization: Bearer) - 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:
- Environment variables โ
.env,.env.local,.env.production - Docker configs โ
docker-compose.yml,Dockerfile - CI/CD pipelines โ GitHub Actions, Vercel env vars, AWS Parameter Store
- Prompt templates โ any file that hardcodes a model name in a string
- Database records โ stored model preferences in your database
- Third-party libraries โ check if your AI framework has cached model names
The Complete Fix: Model Name Mapping
| Deprecated Model | Replacement | Price Change | Context 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:
- Search your code โ Run the grep commands above. Find every
claude-4-opusandclaude-sonnet-4reference. - Replace model names โ Use the mapping table above. One-line change per file.
- Test โ Both old and new model names work until June 15, so run parallel tests now.
- 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
- Claude 4 Stopped Working? โ Quick fix guide if your API calls are already failing
- Claude Deprecation Calculator โ Calculate your exact migration cost and savings
- Claude 4 Migration Tool โ Compare all 34 alternatives with your exact usage
- Claude 4 Deprecation Checklist โ Complete 8-step migration checklist
- Claude 4 Migration Guide โ Detailed code examples in Python, Node.js, and REST API
- Claude 4 Deprecation FAQ โ Every question answered about the deprecation
- Claude 4 Deprecation Countdown โ Live countdown and timeline
- Best Claude 4 Alternatives โ Detailed comparison of all replacement options
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 โ