Model Selection Guide
Understand the characteristics and applicable scenarios of different AI models to make the best choice.
Model Selection Guide¶
Claude Code supports multiple AI models, each with different capabilities, speeds, and prices. Choosing the right model helps you get the best results while controlling costs. This guide helps you make optimal choices for different scenarios.
Claude Model Family Overview¶
Currently, Claude Code primarily uses three tiers of models, which form a capability ladder:
Claude Opus 4.6 β The Most Powerful Brain¶
Opus is Anthropic's most powerful model. It excels in the following areas:
- Deep Reasoning: Capable of long-chain logical reasoning, suitable for complex architecture design
- Code Quality: Generated code is more comprehensive, with better boundary case handling
- Long Context Understanding: Supports a 200K token context window (~150,000 characters), with stronger ability to understand large codebases
- Extended Thinking: Built-in extended thinking capability, complex problems are first reasoned through internally before giving answers
Best For: Architecture design, large-scale refactoring, technical proposal evaluation, difficult bug troubleshooting.
Claude Sonnet 4.6 β The Best Balance¶
Sonnet is the daily go-to for most developers. It achieves the best balance between capability and cost:
- High Cost Performance: Output quality is close to Opus, but price is only about 60%
- Fast Speed: Response speed is faster than Opus, suitable for frequent interactions
- Strong Code Ability: For most daily coding tasks, Sonnet's performance is fully adequate
- 200K Context: Also supports 200K token context window
Best For: Daily coding, bug fixing, code review, documentation writing, test writing.
Claude Haiku 4.5 β Lightweight and Fast¶
Haiku is the smallest and fastest model, with the lowest price:
- Fastest Speed: Response speed is the fastest among the three models
- Lowest Price: Both input and output prices are the cheapest
- Basic Capabilities: Fully capable for simple tasks, but limited complex reasoning ability
- 200K Context: Also supports 200K token context window
Best For: Simple Q&A, code formatting, generating boilerplate code, quick translation.
Detailed Model Comparison¶
Capability and Price Comparison¶
| Comparison Item | Opus 4.6 | Sonnet 4.6 | Haiku 4.5 |
|---|---|---|---|
| Context Window | 200K tokens | 200K tokens | 200K tokens |
| Input Price | $5.00/M | $3.00/M | $1.00/M |
| Output Price | $25.00/M | $15.00/M | $5.00/M |
| Cached Writing | $6.25/M | $3.75/M | $1.25/M |
| Cached Reading | $0.50/M | $0.30/M | $0.10/M |
| Reasoning Ability | Extremely Strong | Strong | Moderate |
| Code Quality | Extremely High | High | Medium |
| Response Speed | Slower | Medium | Fast |
| Extended Thinking | Supported | Supported | Not Supported |
Price unit: USD per million tokens, data source is LiteLLM open-source pricing table.
Cost Comparison for the Same Task¶
Assuming completing a moderately complex coding task (15K tokens input, 5K tokens output):
| Model | Input Cost | Output Cost | Total Cost | Relative Cost |
|---|---|---|---|---|
| Opus 4.6 | $0.075 | $0.125 | $0.200 | 500% |
| Sonnet 4.6 | $0.045 | $0.075 | $0.120 | 300% |
| Haiku 4.5 | $0.015 | $0.025 | $0.040 | 100% |
The cost of Opus completing one task is 5 times that of Haiku, and Sonnet is 3 times that of Haiku. But the capability difference is equally significantβfor complex tasks, using a cheaper model may require repeated retries, ultimately costing more.
Scenario-Based Selection Guide¶
Below are model selection recommendations by actual development scenario:
Daily Coding β Sonnet 4.6¶
For daily writing of functions, components, interfaces, etc., Sonnet is fully adequate:
/model sonnet
# These tasks work great with Sonnet
> "Add deleteUser method to @src/services/user-service.ts"
> "Create a Pagination component with previous/next/page jump support"
> "Add pagination parameter support to @src/app/api/orders/route.ts"
Architecture Design / Large-Scale Refactoring β Opus 4.6¶
When it comes to system design and global decisions, Opus's deep reasoning capability is worth the cost:
/model opus
> "Analyze the overall architecture of the @src/ directory. I plan to split the
monolithic application into microservices. Please evaluate which modules are
suitable for independence and provide a splitting plan."
> "The existing code uses REST API + Redux state management. I want to migrate to
GraphQL + React Query. Please develop a detailed progressive migration plan
ensuring it can be advanced in phases without affecting the production service."
Code Formatting / Simple Q&A β Haiku 4.5¶
For mechanical work that doesn't require deep thinking, Haiku is the most cost-effective:
/model haiku
> "Add JSDoc comments to all interfaces in @src/types/index.ts"
> "Convert the following JavaScript code to TypeScript: [code]"
> "What does this ESLint error mean: no-unused-vars"
Large PR Review β Opus 4.6¶
When reviewing large changes involving multiple files, Opus can find deeper issues:
/model opus
> "This PR modifies 15 files, involving payment system refactoring.
Please conduct a comprehensive review, focusing on:
1. Backward compatibility (will old version clients be affected)
2. Data consistency (could payment status become inconsistent)
3. Error recovery mechanism (handling of network timeouts, third-party service exceptions)"
Bug Fixing β Sonnet 4.6¶
Most bug fixes can be handled well by Sonnet:
/model sonnet
> "Users report that the date picker occasionally displays as blank in Chrome browser.
Error logs are as follows: [logs]
Please check @src/components/DatePicker.tsx and fix this issue."
If it's a particularly complex bug involving concurrency or distributed systems, consider switching to Opus.
Documentation Writing β Sonnet 4.6¶
For writing API documentation, README, comments, etc., Sonnet's output quality is good enough:
/model sonnet
> "Generate JSDoc documentation for all public methods in the @src/services/ directory"
> "Generate API documentation from code in OpenAPI 3.0 format"
> "Write a README for this project, including installation steps and usage instructions"
Scenario Selection Quick Reference¶
| Task Type | Recommended Model | Reason |
|---|---|---|
| Writing a function/component | Sonnet | Best cost performance |
| Architecture design | Opus | Requires deep reasoning |
| Code refactoring (large-scale) | Opus | Requires global understanding |
| Bug fixing | Sonnet | Most bugs don't need Opus |
| Difficult problems | Opus | Complex problems require deep analysis |
| Writing tests | Sonnet | Test logic is relatively straightforward |
| Code review | Sonnet/Opus | Simple PRs use Sonnet, large PRs use Opus |
| Code formatting | Haiku | Mechanical work, no deep reasoning needed |
| Adding comments/documentation | Haiku/Sonnet | Simple comments use Haiku, complex docs use Sonnet |
| Simple Q&A | Haiku | Can be answered in a sentence or two |
| Translation | Haiku | Translation doesn't require complex reasoning |
| Technical proposal evaluation | Opus | Requires weighing multiple factors |
How to Switch Models¶
Method 1: /model Command (Recommended)¶
Switch models anytime in Claude Code:
/model # View current model and available model list
/model sonnet # Switch to Sonnet
/model opus # Switch to Opus
/model haiku # Switch to Haiku
Switch takes effect immediately; the next message will use the new model.
Method 2: Environment Variables¶
Set the default model in shell configuration files (such as ~/.bashrc or ~/.zshrc):
# Set default to use Sonnet
export ANTHROPIC_MODEL=claude-sonnet-4-6
# Or temporarily specify at startup
ANTHROPIC_MODEL=claude-opus-4-6 claude
Method 3: Configure in CLAUDE.md¶
You can give Claude some model usage suggestions in the project's CLAUDE.md (note this is a suggestion, not a mandatory configuration):
## Model Usage Suggestions
- Use Sonnet for daily development
- Switch to Opus for architecture evaluation before making changes
- Use Haiku for batch comment additions to save costs
Method 4: Startup Parameters¶
Specify the model when starting Claude Code:
claude --model claude-opus-4-6
claude --model claude-sonnet-4-6
claude --model claude-haiku-4-5
GPT and Codex Models (via QCode.cc)¶
Through QCode.cc's relay service, Claude Code can also use OpenAI models.
Available Models¶
| Model | Input Price | Output Price | Characteristics |
|---|---|---|---|
| gpt-5.4 | $2.00/M | $16.00/M | Latest generation GPT, comprehensive upgrade |
| gpt-5.4 Pro | $2.00/M | $16.00/M | 5.4 Professional edition, enhanced reasoning |
| gpt-5.4-codex | $2.00/M | $16.00/M | 5.4 Codex edition, specialized for code |
| gpt-5.3-codex-spark | $1.75/M | $14.00/M | 5.3 Codex lightweight edition, fast |
| gpt-5.3-codex | $1.75/M | $14.00/M | 5.3 Codex standard edition |
Price data source is LiteLLM open-source pricing table and may change with vendor adjustments. The gpt-5.4 series is the latest model, pricing follows official announcements.
Codex Model Characteristics¶
OpenAI's Codex series is specifically optimized for code tasks:
- gpt-5.4 series is the latest OpenAI model with comprehensively upgraded code generation quality and reasoning capability
- gpt-5.4 Pro is suitable for complex reasoning and large-scale refactoring
- gpt-5.4-codex is specifically optimized for code tasks
- gpt-5.3-codex-spark is the cost-effective choice, fast and low cost
- Input price is lower than Claude Sonnet ($1.75~$2.00 vs $3.00)
When to Consider Non-Claude Models¶
In most cases, Claude models are the best choice for Claude Code (after all, it's natively adapted). But you might want to try other models in the following situations:
- Better performance for specific programming languages: Some languages (such as Python) may perform slightly differently on Codex
- Very tight budget: Codex's input price is about 42% lower than Sonnet
- Want to do comparison testing: Try the same task with different models to see which gives better results
# Switch to Codex model
/model gpt-5.3-codex
Note: Non-Claude models may not have access to certain features in Claude Code (such as Extended Thinking, some Tool Use features). It's recommended to primarily use Claude models and use other models as supplements.
Cost-Benefit Analysis¶
Typical Workday Model Usage Strategy¶
An efficient developer's typical day might use models as follows:
| Time | Task | Model | Estimated Cost |
|---|---|---|---|
| 9:00 | After morning meeting, evaluate technical proposal with Opus | Opus | $0.50 |
| 9:30-12:00 | Core feature development | Sonnet | $2.00 |
| 13:00-13:30 | Batch add code comments | Haiku | $0.20 |
| 13:30-17:00 | Continue feature development + fix bugs | Sonnet | $2.50 |
| 17:00-17:30 | Review colleague's PR | Sonnet | $0.40 |
| 17:30-18:00 | Complex bug troubleshooting | Opus | $0.80 |
| Daily Total | $6.40 |
Mixed Usage Strategy¶
The most cost-effective and efficient strategy is "Sonnet as main, Opus for highlights, Haiku for odd jobs":
Total task distribution:
βββ Sonnet 4.6 (70%) β Daily development, bug fixing, test writing, review
βββ Opus 4.6 (15%) β Architecture decisions, complex problems, large refactoring
βββ Haiku 4.5 (15%) β Formatting, simple Q&A, batch operations
Compared to using Opus throughout:
| Strategy | Monthly Estimated Cost | Effect |
|---|---|---|
| Opus throughout | $250-400 | Using a sledgehammer to crack a nut |
| Sonnet throughout | $120-200 | May be insufficient for complex tasks |
| Mixed strategy | $130-220 | Best cost performance |
The mixed strategy's cost is close to using Sonnet throughout, but has Opus's deep reasoning support at critical moments.
When Opus is Worth It¶
When a task meets any of the following conditions, switching to Opus is worthwhile:
- Large impact scope: Changes involve multiple modules, systems, or teams
- One-time decisions: Architecture selection, tech stack migration, etc., decisions that cannot be easily reversed
- High debugging cost: This bug has been investigated for a long time and needs deeper analysis
- Critical code quality: This code will be called in many places and needs to be robust enough
Conversely, if you're just writing an internal tool, changing a style, or adding a comment, Sonnet or even Haiku is perfectly adequate.
Practical Tips¶
Switching Models Mid-Conversation¶
You can switch models mid-conversation. For example:
# First use Opus to develop a plan
/model opus
> "Analyze the existing code architecture and develop an implementation plan for the permission system"
# After the plan is confirmed, switch to Sonnet to execute
/model sonnet
> "According to the plan, start implementing the first step: create the permission model"
This way you can enjoy Opus's reasoning capability for key decisions, and use Sonnet to control costs during the execution phase.
Use /cost to Compare Consumption Across Different Models¶
After completing a task, use /cost to see how much you spent. Next time you do a similar task, try a different model and compare results and costs. After a few comparisons, you'll develop intuition for which model to use for each type of task.
Model Capabilities Are Continuously Evolving¶
Anthropic regularly updates model capabilities. Tasks that Sonnet can't handle well today might be doable in the next version. It's recommended to occasionally try Sonnet on tasks you've only used Opus for beforeβyou might be pleasantly surprised.