# How to Migrate Code and Prompts from Claude Sonnet 4.x to Opus 4.5

> Easily migrate Claude Sonnet 4.x code and prompts to Opus 4.5. Update model identifiers, boost max tokens, and use the anthropics/claude-code repository for automated bulk updates.

- Repository: [Anthropic/claude-code](https://github.com/anthropics/claude-code)
- Tags: migration-guide
- Published: 2026-04-02

---

**Replace the model identifier `claude-3-sonnet-20240229` with `claude-3-opus-20240229`, increase `max_tokens` from 4,096 to 75,000, and run the migration skill from the `anthropics/claude-code` repository to automate bulk configuration updates.**

Migrate your existing Claude Sonnet 4.x implementations to Opus 4.5 using the official migration plugin in the `anthropics/claude-code` repository. This process involves updating API parameters to leverage the 75,000 token context window, adjusting cost-calculation logic for the lower per-token pricing, and optionally streamlining prompt verbosity to match Opus's richer response characteristics.

## Update Model Identifiers and API Parameters

The primary change when migrating from **Claude Sonnet 4.x** to **Claude Opus 4.5** is the **model identifier** string. In [`plugins/claude-opus-4-5-migration/README.md`](https://github.com/anthropics/claude-code/blob/main/plugins/claude-opus-4-5-migration/README.md), the specification requires replacing `claude-3-sonnet-20240229` with `claude-3-opus-20240229` in all API calls. Additionally, remove or update any hardcoded `max_tokens` values that assume Sonnet's 4,096 token limit, as Opus 4.5 supports up to 75,000 output tokens.

### Node.js Fetch Example

```typescript
import fetch from "node-fetch";

async function callClaudeOpus(messages: any[]) {
  const response = await fetch("https://api.anthropic.com/v1/messages", {
    method: "POST",
    headers: {
      "x-api-key": process.env["ANTHROPIC_API_KEY"],
      "content-type": "application/json",
      "anthropic-version": "2023-06-01",
    },
    body: JSON.stringify({
      model: "claude-3-opus-20240229",      // ← updated from claude-3-sonnet-20240229
      max_tokens: 75000,                     // ← increased from 4096
      temperature: 0.7,
      messages,
    }),
  });

  const data = await response.json();
  return data.content[0].text;
}

```

The `model` field and `max_tokens` parameter are the critical differences. Failing to update the model name results in a **400 Bad Request** error from the Anthropic API.

## Expand Token Limits and Context Windows

Claude Opus 4.5 dramatically extends the **context window** from Sonnet 4.x's 4,000 tokens to 75,000 tokens. According to [`plugins/claude-opus-4-5-migration/skills/claude-opus-4-5-migration/references/prompt-snippets.md`](https://github.com/anthropics/claude-code/blob/main/plugins/claude-opus-4-5-migration/skills/claude-opus-4-5-migration/references/prompt-snippets.md), this allows you to:

- Retain full conversation history without truncation
- Pass larger codebases or documentation blocks in a single prompt
- Reduce token waste from previously necessary summarization workarounds

Update your `max_prompt_tokens` and `max_output_tokens` configurations in YAML, JSON, or environment variables to utilize the expanded capacity.

### YAML Configuration Before and After

```yaml

# Before (Sonnet 4.x)

model: claude-3-sonnet-20240229
max_prompt_tokens: 4000
max_output_tokens: 4096

# After (Opus 4.5)

model: claude-3-opus-20240229
max_prompt_tokens: 75000
max_output_tokens: 75000

```

## Refactor Prompt Templates for Opus 4.5

The [`references/prompt-snippets.md`](https://github.com/anthropics/claude-code/blob/main/references/prompt-snippets.md) file in the migration plugin notes that Opus 4.5 often produces **richer responses** with less scaffolding. Review your **system prompts** for verbosity that was necessary to constrain Sonnet's shorter outputs. You can typically:

1. Remove explicit "be concise" instructions that were workarounds for token limits
2. Simplify multi-step reasoning instructions into single, coherent directives
3. Eliminate redundant formatting constraints

Test existing `stop_sequences` and `temperature` values, as Opus 4.5's different architecture may respond differently to Sonnet-tuned hyperparameters.

## Automate Migration with the Claude-Code Plugin

The `anthropics/claude-code` repository includes an executable skill at [`plugins/claude-opus-4-5-migration/skills/claude-opus-4-5-migration/SKILL.md`](https://github.com/anthropics/claude-code/blob/main/plugins/claude-opus-4-5-migration/skills/claude-opus-4-5-migration/SKILL.md) that automates configuration updates. This skill scans supplied configuration files, rewrites `model` fields, expands token limits, and prints a diff for review.

Run the migration skill from your project root:

```bash
claude-code skill run claude-opus-4-5-migration \
  --config ./my-project/config.yaml

```

The skill definition references [`plugins/claude-opus-4-5-migration/skills/claude-opus-4-5-migration/references/effort.md`](https://github.com/anthropics/claude-code/blob/main/plugins/claude-opus-4-5-migration/skills/claude-opus-4-5-migration/references/effort.md) for estimating migration scope based on project size.

## Update Pricing and Usage Tracking

Adjust cost-calculation logic to reflect Opus 4.5's **lower per-token rates**. Where Sonnet 4.x cost `$0.0015` per 1,000 input tokens, Opus 4.5 pricing is `$0.00075` per 1,000 input tokens. Update any budget monitoring scripts or usage dashboards to prevent over-reporting expenses after migration.

## Summary

- Replace `claude-3-sonnet-20240229` with `claude-3-opus-20240229` in all API requests to avoid 400 errors
- Increase `max_tokens` and `max_output_tokens` from 4,096 to 75,000 to utilize the expanded context window
- Reference [`plugins/claude-opus-4-5-migration/README.md`](https://github.com/anthropics/claude-code/blob/main/plugins/claude-opus-4-5-migration/README.md) for the complete migration checklist
- Run `claude-code skill run claude-opus-4-5-migration` to automate config file updates using the skill defined in [`SKILL.md`](https://github.com/anthropics/claude-code/blob/main/SKILL.md)
- Update pricing calculations from `$0.0015` to `$0.00075` per 1K input tokens for accurate budgeting
- Review prompt verbosity in [`references/prompt-snippets.md`](https://github.com/anthropics/claude-code/blob/main/references/prompt-snippets.md)—Opus 4.5 typically requires less scaffolding than Sonnet 4.x

## Frequently Asked Questions

### What is the exact model identifier for Claude Opus 4.5?

The model identifier is `claude-3-opus-20240229`. According to the migration plugin source in [`plugins/claude-opus-4-5-migration/README.md`](https://github.com/anthropics/claude-code/blob/main/plugins/claude-opus-4-5-migration/README.md), this string replaces the previous `claude-3-sonnet-20240229` identifier used in Sonnet 4.x implementations.

### How do I update existing YAML configuration files?

Use the `claude-opus-4-5-migration` skill or perform a search-and-replace operation. Update the `model` field to `claude-3-opus-20240229`, change `max_prompt_tokens` to `75000`, and set `max_output_tokens` to `4000` or higher. The [`references/prompt-snippets.md`](https://github.com/anthropics/claude-code/blob/main/references/prompt-snippets.md) file contains before-and-after examples for common configuration formats.

### Does Opus 4.5 require different prompt engineering?

Generally no, but you should simplify prompts that were verbose to work within Sonnet's 4K token constraints. Opus 4.5 generates richer outputs naturally, so you can remove "be concise" instructions and other scaffolding. Always re-test `temperature` and `stop_sequences` values, as the larger model may exhibit different behavior with your existing settings.

### Where can I find the migration automation scripts?

The automation skill is located at [`plugins/claude-opus-4-5-migration/skills/claude-opus-4-5-migration/SKILL.md`](https://github.com/anthropics/claude-code/blob/main/plugins/claude-opus-4-5-migration/skills/claude-opus-4-5-migration/SKILL.md) in the `anthropics/claude-code` repository. Execute it via `claude-code skill run claude-opus-4-5-migration` to automatically rewrite model identifiers and token limits across your project files.