Migrating from Claude 3.5 Sonnet to Claude 4 Sonnet: A Comprehensive Guide for Organizations
Co-Authored with Gareth Jones from Anthropic
This post addresses the essential steps and considerations for migrating to Anthropic’s Claude 4 Sonnet model on Amazon Bedrock, emphasizing improved capabilities and strategic planning for a seamless transition.
Navigating the Migration from Anthropic’s Claude 3.5 Sonnet to Claude 4 Sonnet on Amazon Bedrock
This post is co-written with Gareth Jones from Anthropic.
Anthropic’s Claude 4 Sonnet model has launched on Amazon Bedrock, marking a significant advancement in foundation model capabilities. Consequently, the deprecation timeline for Anthropic’s Claude 3.5 Sonnet (v1 and v2) has been announced. This evolution presents a dual imperative for production AI applications: the chance to harness enhanced performance and the operational necessity to migrate before deprecation. Organizations must treat model migrations as a core component of their AI inference strategy, as poor execution can lead to service disruptions, performance regressions, or cost overruns.
This post provides a systematic approach to migrating from Anthropic’s Claude 3.5 Sonnet to Claude 4 Sonnet on Amazon Bedrock. We’ll examine key model differences, highlight essential migration considerations, and provide proven best practices to turn this transition into a strategic advantage that delivers measurable value for your organization.
Overview of Model Differences
Understanding specific changes between model versions is crucial for a successful migration. The move from Anthropic’s Claude 3.5 Sonnet to Claude 4 Sonnet introduces capability and behavioral shifts that you can leverage:
-
Increased Context Window: Claude 4 Sonnet expands the context window from 200,000 tokens to 1 million tokens (beta). This allows applications to process and reason over extensive documents in a single prompt, simplifying complex workflows.
-
Native Reasoning Mechanisms: Unlike Claude 3.5, which relies on chain-of-thought prompting techniques, Claude 4 introduces built-in, API-enabled reasoning features like extended thinking. These allow dedicated computational time to reason before answering, markedly improving performance on complex challenges.
-
Advanced Tool Use: Claude 4 significantly upgrades tool-use capabilities, allowing for the execution of multiple tools in parallel and extended reasoning between tool calls. This leads to more sophisticated and efficient workflows compared to the sequential tool use of earlier versions.
To learn more about these model differences, refer to the Complete Model Comparison Guide.
Prerequisites
Before utilizing Anthropic’s Claude 4 Sonnet model, ensure you have access to these models on Amazon Bedrock. Follow these steps:
-
Request Access: Review and accept the model’s End User License Agreement (EULA) before proceeding. Verify that Claude 4 Sonnet is available in your intended AWS Region, as model support can differ based on location.
-
Cross-Region Inference: Consider using cross-region inference (CRIS) by specifying an inference profile, which can enhance throughput and resource availability.
API Changes and Code Updates
When migrating on Amazon Bedrock, you can utilize either the model-specific InvokeModel API or the unified Converse API.
Using the InvokeModel API
If you opt for the InvokeModel API, the migration is straightforward—just update the modelId
in your code:
-
Old Model ID:
- ‘anthropic.claude-3-5-sonnet-20240620-v1:0’
- ‘anthropic.claude-3-5-sonnet-20241022-v2:0’
-
New Model ID:
- ‘anthropic.claude-4-sonnet-20240514-v1:0’
If using a CRIS profile, ensure you specify the correct inference profile ID from the source regions.
Transitioning to the Converse API
This migration is an excellent opportunity to switch to the Converse API for a standardized request/response format, enhancing future migrations to different models or providers.
Here’s an example code snippet to achieve this:
import boto3
bedrock_runtime = boto3.client(service_name="bedrock-runtime")
response = bedrock_runtime.converse(
modelId='us.anthropic.claude-sonnet-4-20250514-v1:0',
messages=[{'role': 'user', 'content': [{'text': "Your prompt here"}]}],
inferenceConfig={'maxTokens': 1024}
)
print(response['output']['message']['content'][0]['text'])
Key Changes in API
- Text Editor Tool Update: The tool definition has changed. Update your code accordingly.
- Removed Commands: The
undo_edit
command is no longer supported. - New Refusal Stop Reason: Update your application logic to manage this new reason effectively.
Prompt Engineering and Behavioral Shifts
Don’t assume existing prompts will perform optimally with the new model. Follow model-specific best practices for prompt structuring. For example, using XML tags can enhance clarity in multi-part inputs. Claude 4 is designed for improved instruction adherence, potentially resulting in fewer elaborations unless prompted.
New Reasoning Features
Leverage the built-in extended thinking in Claude 4 by including the thinking
keyword argument in your API call. Be strategic with this capability, as it incurs additional costs.
For high-stakes tasks, enabling extended thinking is efficient. However, for simpler queries, traditional methods may still be best. Update your Converse API accordingly, as shown below:
response = bedrock_runtime.converse(
modelId='us.anthropic.claude-sonnet-4-20250514-v1:0',
messages=[{'role': 'user', 'content': [{'text': "Your prompt here"}]}],
inferenceConfig={'maxTokens': 2048},
additionalModelRequestFields={"thinking": {"type": "enabled", "budget_tokens": 1024}}
)
Evaluating Performance and Safety
Verification of new model performance is essential. Create a representative dataset of prompts and expected outputs to form a benchmark. Automate this evaluation within your continuous integration pipeline.
Test the new model with the same guardrail configurations used in production to ensure efficacy and compliance with safety standards.
Implementation Strategy
Adopt a phased rollout when deploying Claude 4 Sonnet. Implement strategies like shadow testing and A/B testing to ensure minimal risks. Consider canary releasing or blue/green deployments to maintain service continuity.
Conclusion
Migrating from Anthropic’s Claude 3.5 Sonnet to Claude 4 Sonnet can unlock substantial benefits when treated as a structured engineering project. Emphasizing understanding model differences, adapting API calls, and establishing robust evaluation strategies are crucial to a successful upgrade.
Take this opportunity to enhance your application, and initiate your analysis and testing today.
For more details, check out Migrating to Claude 4 and Anthropic’s Claude in Amazon Bedrock.
About the Authors
Melanie Li, PhD – Senior Generative AI Specialist at AWS. Focused on deploying state-of-the-art AI/ML tools.
Deepak Dalakoti, PhD – Deep Learning Architect at AWS. Works on accelerating generative AI adoption.
Mahsa Paknezhad, PhD – Deep Learning Architect specializing in scalability and production readiness.
Nicholas Moore – Solutions Architect who specializes in cloud solutions and AI.
Derrick Choo – Senior Solutions Architect focusing on enterprise digital transformation through AI.
Sovik Kumar Nath – Senior Solutions Architect with experience in designing end-to-end ML solutions.
Saurabh Trikande – Senior Product Manager passionate about making AI accessible.
Gareth Jones – Product Manager at Anthropic, collaborating with AWS to enhance Claude API accessibility.