Migration Guide

Claude 4 Migration Guide: Step-by-Step Before June 15

Claude 4 Opus and Sonnet 4 retire in 13 days. Here's exactly how to migrate โ€” with code examples for Python, Node.js, and REST API, plus a testing checklist and rollback plan.

Jun 2, 2026 ยท 8 min read

Deadline: June 15, 2026. After this date, API calls to claude-4-opus and claude-sonnet-4 will return errors. Your API key still works โ€” you just need to update the model name.

What's Retiring and What Replaces It

Retiring ModelPrice (In/Out per M)ReplacementNew PriceSavings
Claude 4 Opus $15.00 / $75.00 Claude Opus 4.8 $5.00 / $25.00 67%
Claude Sonnet 4 $3.00 / $15.00 Claude Sonnet 4.6 $3.00 / $15.00 Same price, 5x context

Good news: Both replacements use the same API key, SDK, and endpoint. For Claude-to-Claude migration, it's literally a one-line change.

Step 1: Find All Deprecated Model References

Search your entire codebase for the old model IDs. Check source code, config files, environment variables, and documentation.

Python / Node.js projects

# Search for both deprecated models
grep -rn "claude-4-opus\|claude-sonnet-4" src/ config/ .env*

# Also check for the long-form names
grep -rn "Claude 4 Opus\|Claude Sonnet 4" docs/ README.md

Common locations to check

Step 2: Update the Model Name

Python (Anthropic SDK)

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

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

Node.js (Anthropic SDK)

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

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

REST API (curl)

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

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

Sonnet migration

# Before
model: "claude-sonnet-4"

# After
model: "claude-sonnet-4-6"

Pro tip: Use environment variables for model selection. Set MODEL_NAME=claude-opus-4-8 in your .env file so future migrations are a single config change.

Step 3: Update SDK Version

Make sure you're on the latest Anthropic SDK version. Older versions may not recognize the new model IDs.

# Python
pip install --upgrade anthropic

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

The new model IDs work with SDK version 0.39+ (Python) and 0.39+ (Node.js). If you're on an older version, upgrade first.

Step 4: Test in Parallel

Don't switch cold turkey. Run both models side-by-side for 1-2 weeks to validate output quality.

Parallel testing pattern

import os

OLD_MODEL = "claude-4-opus"
NEW_MODEL = "claude-opus-4-8"

def test_migration(prompt):
    # Run both models
    old_response = client.messages.create(model=OLD_MODEL, ...)
    new_response = client.messages.create(model=NEW_MODEL, ...)

    # Compare outputs
    print(f"Old: {old_response.content[0].text[:100]}")
    print(f"New: {new_response.content[0].text[:100]}")
    print(f"Old cost: ${calculate_cost(old_response)}")
    print(f"New cost: ${calculate_cost(new_response)}")

What to test

Step 5: Deploy and Monitor

Once validated, update production. Keep the old model ID in a comment for reference.

Deployment checklist

Rollback plan

If something goes wrong, you can switch back instantly โ€” just change the model name back. But note: after June 15, the old model IDs will stop working entirely. Keep your rollback window within the next 13 days.

Cross-Provider Migration (Advanced)

If you want to switch from Anthropic entirely (to save 85-99%), the migration is more involved:

TargetPrice (In/Out per M)API CompatibleMigration Effort
GPT-5 $1.25 / $10.00 OpenAI SDK Change base URL + model name
Gemini 3.1 Pro $2.00 / $12.00 Google SDK New SDK, different message format
DeepSeek V4 Pro $0.435 / $0.87 OpenAI-compatible Change base URL + model name
Mistral Large 3 $0.50 / $1.50 OpenAI-compatible Change base URL + model name

DeepSeek migration example (OpenAI-compatible)

# DeepSeek uses OpenAI-compatible API
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DEEPSEEK_API_KEY"),
    base_url="https://api.deepseek.com/v1"
)

response = client.chat.completions.create(
    model="deepseek-v4-pro",
    messages=[{"role": "user", "content": "Hello"}]
)

Need help choosing? Use the Claude 4 Migration Tool to compare all 34 alternatives with your exact usage. See costs ranked cheapest-first, get code snippets, and calculate savings.

Cost Impact: Real Workload Example

For a typical workload of 10M input + 2M output tokens/month:

ModelMonthly CostSavings vs Claude 4 Opus
Claude 4 Opus (current) $300.00 โ€”
Claude Opus 4.8 $100.00 $200.00 saved (67%)
GPT-5 $32.50 $267.50 saved (89%)
DeepSeek V4 Pro $6.09 $293.91 saved (98%)
Gemini 2.0 Flash $1.80 $298.20 saved (99%)

Calculate your exact savings with the Claude Deprecation Calculator โ€” input your real token usage and see costs across all 34 models.

Timeline: What to Do and When

WhenActionTime
Today Search codebase for deprecated model IDs 5 min
Today Update model name to replacement 5 min
This week Run parallel testing on key prompts 1-2 hours
Before June 15 Deploy to production 30 min
After June 15 Old model IDs stop working โ€” migration required โ€”

Deadline: June 15 โ€” 13 days left

Compare all 34 alternatives with your exact usage. See costs, get code, and calculate savings.

Open Migration Tool โ†’ Deprecation Calculator

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

Found this useful? Share it: