Blog / Migration Guide Jun 4, 2026 12 min read

Claude 4 Deprecated: Complete Migration Guide for Developers

Deadline: June 15, 2026. Claude 4 Opus and Claude Sonnet 4 are being retired. API calls using these model IDs will return errors after this date. You have 11 days to migrate.

Anthropic is retiring Claude 4 Opus and Claude Sonnet 4 on June 15, 2026. If your code uses claude-4-opus or claude-sonnet-4 as the model name, it will break after the deadline.

The good news: migration is a one-line change per model reference, and the direct replacements are 67% cheaper. This guide covers exactly what changed, how to migrate, and which alternative models save you the most money.

What's Changing

Anthropic is deprecating two model IDs:

Retiring ModelReplacementPrice ChangeContext
claude-4-opus claude-opus-4-8 (Claude Opus 4.8) $15/$75 → $5/$25 -67% 200K → 1M tokens
claude-sonnet-4 claude-sonnet-4-6 (Claude Sonnet 4.6) $3/$15 → $3/$15 200K → 1M tokens

Your Anthropic API key, SDK, and endpoint stay the same. Only the model string changes.

How to Migrate (Step by Step)

Step 1: Find model references in your code

Search your codebase for the deprecated model strings:

# Find all references to deprecated models
grep -r "claude-4-opus\|claude-sonnet-4" ./src/

Step 2: Update the model string

Replace the deprecated model ID with the new one:

# Before (deprecated)
model = "claude-4-opus"

# After
model = "claude-opus-4-8"  # Claude Opus 4.8 — 67% cheaper, 5x context

For Sonnet:

# Before (deprecated)
model = "claude-sonnet-4"

# After
model = "claude-sonnet-4-6"  # Claude Sonnet 4.6 — same price, 5x context

Step 3: Test your integration

Run your existing test suite. The API behavior is identical — only the model string changes. No SDK updates, no API key changes, no endpoint changes.

Step 4: Update environment variables

If you store model names in environment variables or config files:

# .env or config
ANTHROPIC_MODEL=claude-opus-4-8      # was claude-4-opus
ANTHROPIC_MODEL_SONNET=claude-sonnet-4-6  # was claude-sonnet-4
That's it. Migration is a one-line change per model reference. No paid upgrade, no new API key, no SDK update required.

Top 5 Claude 4 Alternatives Compared

If you want to migrate to a cheaper model (not just the direct replacement), here are the top 5 alternatives ranked by cost savings:

ModelProviderInput/1MOutput/1MContextSavings vs Claude 4 Opus
DeepSeek V4 Flash DeepSeek $0.14 $0.28 1M -98%
Gemini 2.0 Flash Google $0.10 $0.40 1M -98%
DeepSeek V4 Pro DeepSeek $0.435 $0.87 1M -95%
GPT-5 mini OpenAI $0.25 $2.00 272K -95%
Claude Opus 4.8 Anthropic $5.00 $25.00 1M -67%

Need more options? Use the Provider Switch Calculator to compare all 34 models side by side.

Code Examples: Migration by Language

Python (Anthropic SDK)

# Before
import anthropic
client = anthropic.Anthropic()
message = client.messages.create(
    model="claude-4-opus",  # DEPRECATED
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}]
)

# After
message = client.messages.create(
    model="claude-opus-4-8",  # Claude Opus 4.8
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}]
)

Node.js (Anthropic SDK)

// Before
const message = await anthropic.messages.create({
    model: 'claude-4-opus',  // DEPRECATED
    max_tokens: 1024,
    messages: [{ role: 'user', content: 'Hello' }]
});

// After
const message = await anthropic.messages.create({
    model: 'claude-opus-4-8',  // Claude Opus 4.8
    max_tokens: 1024,
    messages: [{ role: 'user', content: 'Hello' }]
});

cURL

# Before
curl https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -d '{"model": "claude-4-opus", ...}'  # DEPRECATED

# After
curl https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -d '{"model": "claude-opus-4-8", ...}'

Migration Checklist

  1. Search codebase for claude-4-opus and claude-sonnet-4
  2. Update model strings to claude-opus-4-8 / claude-sonnet-4-6
  3. Update config files and environment variables
  4. Run tests — behavior is identical, just the model string changes
  5. Deploy before June 15, 2026

FAQ

Is Claude 4 being deprecated?

Yes. Anthropic is retiring Claude 4 Opus and Claude Sonnet 4 on June 15, 2026. After this date, API calls using these model IDs will return errors. Claude Opus 4.8 and Claude Sonnet 4.6 are the direct replacements.

What is the best replacement for Claude 4 Opus?

Claude Opus 4.8 is the direct replacement at $5/$25 per million tokens (vs $15/$75 — a 67% cost reduction). For cheaper alternatives, DeepSeek V4 Pro ($0.435/$0.87) and Gemini 2.5 Pro ($1.25/$10) offer strong performance at 80-95% less cost.

Will my code break after June 15?

Yes — API calls using claude-4-opus or claude-sonnet-4 will return errors. You need to update the model string. The rest of your integration (API key, SDK, endpoint) stays the same.

How much does migration cost?

Migration is free — it's a code change, not a paid upgrade. Just update the model string. The real savings come from switching to a cheaper model: Claude Opus 4.8 saves 67%, and alternatives like DeepSeek V4 Pro save 95%.

What happens to my API key?

Your Anthropic API key continues to work with all Anthropic models including Claude Opus 4.8 and Claude Sonnet 4.6. No new key needed.

Related Tools

Get the Claude 4 Migration Checklist

Step-by-step guide with code samples, cost comparisons, and a deadline tracker. Free, no spam.