AI & Agents

Claude Code Models: How to Configure and Switch Models

Claude Code offers four model tiers with a 10x cost spread between the cheapest and most capable option. Your default model depends on your subscription type, and switching requires one command. This guide covers which model to pick for each coding task, three ways to switch mid-session, how aliases resolve differently across providers, and how effort levels give you finer cost control than model switching alone.

Fast.io Editorial Team 11 min read
AI model configuration and neural network indexing visualization

What Determines Your Default Model

Haiku 4.5 processes input tokens at $1 per million while Fable 5 charges $10 for the same volume, according to Anthropic's June 2026 models overview. Output tokens show the same 10x spread: $5 for Haiku versus $50 for Fable. That range makes model selection the single highest-impact configuration decision in Claude Code, yet many developers never change their default.

The default model depends on your account type:

  • Max, Team Premium, Enterprise pay-as-you-go, and API users default to Opus 4.8 ($5/$25 per million input/output tokens)
  • Pro, Team Standard, and Enterprise subscription seats default to Sonnet 4.6 ($3/$15 per million tokens)
  • Claude Platform on AWS users default to Opus 4.7
  • Bedrock, Vertex, and Foundry users default to Sonnet 4.5

Two developers asking the same question can get different quality responses because their plans route to different models. A Max subscriber running Opus 4.8 gets deep reasoning on every prompt. A Pro subscriber running Sonnet 4.6 gets faster responses but less investigation on complex problems. Neither choice is wrong, but the mismatch between task complexity and model capability is where time and money go to waste.

The 10x spread isn't only about raw cost. Each model tier brings a different combination of context window size, output token limit, and reasoning depth. Haiku runs with a 200K context window and 64K output limit. Fable 5, Opus 4.8, and Sonnet 4.6 all support 1M context windows and 128K output. Picking the right model for a task means weighing all three dimensions: cost per token, reasoning capability, and how much code the model can hold in context at once.

These settings apply across every Claude Code surface: the CLI, IDE extensions (VS Code and JetBrains), the web app at claude.ai/code, the desktop app, and Claude Cowork. Cowork sessions use the same model resolution as any other Claude Code session, though server-managed settings from the admin console reach Cowork differently than local CLI sessions. A managed settings file deployed to a device applies to Cowork when present, but for remote Cowork sessions on Anthropic-managed VMs, administrators use server-managed settings or MDM policies instead.

Available Models and When to Use Each

Claude Code supports eight model versions across four capability tiers. The four you need to know are Fable 5, Opus 4.8, Sonnet 4.6, and Haiku 4.5. The others (Opus 4.7, Opus 4.6, Opus 4.5, Sonnet 4.5) are legacy versions that remain selectable but receive no further updates.

Fable 5: Long Autonomous Sessions

Fable 5 (claude-fable-5) became generally available on June 9, 2026. It is Anthropic's most capable widely released model, priced at $10 per million input tokens and $50 per million output tokens. It carries a 1M token context window and 128K token output limit.

Fable is built for work that outlasts a single sitting. It investigates before acting, verifies its own output more often than smaller models, and sustains multi-hour autonomous sessions without losing the thread. Root-cause investigations, outage debugging, and architecture decisions are where Fable earns its premium. You do not need to prompt Fable to verify its work or test its changes. It handles that on its own.

Two things to know before selecting it. First, Fable is never the default on any account type. You must choose it with /model fable or the best alias. Second, Fable's safety classifiers can trigger automatic fallback to Opus when requests touch cybersecurity or biology content. If that happens mid-session, run /model fable to switch back.

Opus 4.8: Complex Reasoning

Opus 4.8 (claude-opus-4-8) is the most capable Opus-tier model at $5/$25 per million tokens. It supports a 1M context window and 128K output. On Max, Team, and Enterprise plans, the 1M window is included with your subscription.

Opus handles large cross-cutting refactors, difficult debugging, and multi-step architectural decisions. When a problem requires reading dozens of files and synthesizing a plan before writing code, Opus outperforms Sonnet. The tradeoff is latency: Opus takes longer per response than Sonnet, and it consumes more of your quota on subscription plans.

Use Opus when the problem is hard enough that a wrong first attempt costs more time than the extra seconds of reasoning.

Sonnet 4.6: Daily Development

Sonnet 4.6 (claude-sonnet-4-6) is the balanced choice at $3/$15 per million tokens with a 1M context window and 128K output. It handles code generation, data analysis, test writing, and most day-to-day development tasks with speed that keeps you in flow.

Sonnet is the default for Pro, Team Standard, and Enterprise subscription seats. For most coding work, Sonnet produces results close to Opus quality at 40% lower cost with noticeably faster responses. Start here and upgrade to Opus only when you hit a reasoning ceiling on a specific problem.

Haiku 4.5: Speed and Volume

Haiku 4.5 (claude-haiku-4-5-20251001) runs at $1/$5 per million tokens with a 200K context window and 64K output. It is the fastest Claude model and the cheapest to run.

Haiku fits quick lookups, simple edits, file reads, routine questions, and high-volume scripted runs where latency matters more than depth. It also works well as a sub-agent model when you want to fan out many small tasks without burning quota. For batch operations or CI pipelines that process hundreds of prompts, Haiku keeps costs predictable.

Matching Models to Tasks

When deciding between models, match the task to the cheapest model that can handle it:

  • Quick questions, file reads, grep-style lookups: Haiku 4.5. The latency advantage alone makes it worth switching for simple tasks.
  • Writing code, fixing bugs, running tests, most daily work: Sonnet 4.6. The default for a reason.
  • Large refactors, multi-file architecture changes, difficult debugging: Opus 4.8. Deeper reasoning pays for itself in fewer failed attempts.
  • Multi-hour autonomous sessions, root-cause investigations, outage triage: Fable 5. Its ability to sustain context and self-verify over long runs reduces the need for human check-ins.

If you find yourself re-prompting Sonnet multiple times to get a correct answer on a complex problem, the time you spend is worth more than the cost difference. Switch to Opus, get the answer on the first or second attempt, and switch back.

Comparison of Claude model capabilities and pricing tiers

Three Ways to Change Your Model

Claude Code provides three methods for changing your model, listed here in order of increasing persistence.

1. The /model Command (During a Session)

Type /model at the prompt to open an interactive picker showing every available model. Select one and press Enter to switch and save as your default for future sessions. Press s instead to switch for the current session only.

You can also type the model name directly:

/model sonnet
/model opus
/model fable
/model haiku

As of Claude Code v2.1.153, pressing Enter in the picker writes your choice to the model field in your user settings file. New sessions start on that model until you change it again. Run /status to confirm which model is active.

Switching mid-session preserves your conversation history, file reads, and context. Only the model processing your next message changes. One thing to expect: the first turn after switching re-reads the full history without cached context, so it may take longer than usual.

2. The --model Flag (At Startup)

Pass --model when launching Claude Code to set the model for that session:

claude --model opus
claude --model claude-fable-5
claude --model haiku

This flag accepts model aliases (opus, sonnet, haiku, fable, best, opusplan) or full model IDs (claude-opus-4-8, claude-sonnet-4-6). The choice applies only to the session you launch. Other terminals keep their own model settings.

Use --model when you want parallel sessions on different models. Launch one terminal with claude --model opus for architecture work and another with claude --model sonnet for implementation.

3. The ANTHROPIC_MODEL Environment Variable (Persistent Default)

Set ANTHROPIC_MODEL in your shell configuration file to change the default across all new sessions:

# In ~/.zshrc (macOS) or ~/.bashrc (Linux)
export ANTHROPIC_MODEL="claude-opus-4-8"

After editing, source the config file and restart your terminal. Every claude invocation without a --model flag will use this model.

How Precedence Works

When multiple settings exist, Claude Code resolves the model in this order:

  1. /model command (during the session, highest priority)
  2. --model CLI flag (at startup)
  3. ANTHROPIC_MODEL environment variable
  4. model field in your settings file (written by the /model picker)

A higher-priority method always wins. If you launch with claude --model sonnet but then run /model opus, the session switches to Opus. If you resume a session with claude --resume, the session keeps the model it was using when saved, regardless of your current settings. Launching with --model alongside --resume overrides the restored model.

You can also set a permanent default directly in your settings file at ~/.claude/settings.json:

{
  "model": "opus"
}

The /model picker writes to this file when you press Enter, so you rarely need to edit it by hand. Project-level and organization-managed settings take precedence over user settings, so an admin can enforce a specific model through managed configuration while individual developers can override it for personal sessions.

When running Claude Code agents that produce file artifacts across different models and sessions, tools like Fast.io provide persistent workspaces where those outputs stay organized. Fast.io's MCP server gives agents direct workspace access, and Intelligence Mode indexes every file for semantic search, so you can find what any agent wrote without remembering which session or model produced it.

Fastio features

Persist agent outputs across model switches and sessions

A shared workspace with version history for every file your Claude Code agents produce. Intelligence Mode indexes outputs for semantic search, so you can find what any agent wrote without remembering which session or model produced it. Starts with a 14-day free trial.

Model Aliases and Provider Resolution

Model aliases let you reference capability tiers without remembering version numbers. Type opus instead of claude-opus-4-8, and Claude Code resolves the alias to the right model for your provider.

Available Aliases

  • default clears any override and reverts to your account's default model
  • best uses Fable 5 if your org has access, otherwise the latest Opus
  • fable selects Claude Fable 5
  • opus selects the latest Opus for your provider
  • sonnet selects the latest Sonnet for your provider
  • haiku selects Haiku 4.5
  • opus[1m] selects Opus with a 1M token context window
  • sonnet[1m] selects Sonnet with a 1M token context window
  • opusplan uses Opus during plan mode and switches to Sonnet during execution

Aliases point to the recommended model version for your provider and update over time. To pin a specific version, use the full model ID or set the ANTHROPIC_DEFAULT_OPUS_MODEL environment variable. Anthropic also provides ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL, and ANTHROPIC_DEFAULT_FABLE_MODEL for controlling what each alias resolves to.

Alias Resolution Varies by Provider

The same alias points to different model versions depending on where Claude Code sends requests:

  • Anthropic API: opus resolves to Opus 4.8, sonnet resolves to Sonnet 4.6
  • Claude Platform on AWS: opus resolves to Opus 4.7, sonnet resolves to Sonnet 4.6
  • Bedrock, Vertex, and Foundry: opus resolves to Opus 4.6, sonnet resolves to Sonnet 4.5

On third-party providers, newer models are available by specifying the full model ID or by setting the ANTHROPIC_DEFAULT_OPUS_MODEL and ANTHROPIC_DEFAULT_SONNET_MODEL environment variables to the provider-specific identifiers. Without pinning, users on Bedrock may get Opus 4.6 while a colleague on the Anthropic API gets Opus 4.8 from the same alias.

opusplan: Hybrid Planning and Execution The opusplan alias provides an automated two-phase workflow. In plan mode, Claude Code uses Opus for reasoning, architecture analysis, and decision-making. When it moves to execution, it switches to Sonnet for code generation and implementation.

This pairing gives you Opus-quality planning with Sonnet-speed execution. Select it with /model opusplan or claude --model opusplan. Add the [1m] suffix (opusplan[1m]) to force 1M context in both phases.

When availableModels restrictions exclude Opus, opusplan stays on Sonnet in plan mode rather than switching. The hybrid behavior degrades gracefully.

Fallback Model Chains

When the primary model is overloaded or unavailable, Claude Code can try a fallback model instead of failing the request. Set a chain with the --fallback-model flag:

claude --fallback-model sonnet,haiku

Or persist it in your settings file:

{
  "fallbackModel": ["claude-sonnet-4-6", "claude-haiku-4-5"]
}

Chains cap at three models after duplicate removal. The switch applies only to the current turn, so your next message tries the primary model again. Authentication and rate-limit errors never trigger a fallback switch.

Tuning Effort Levels and Extended Context

The effort parameter controls how much reasoning Claude applies to each step. Lower effort is faster and cheaper for straightforward tasks. Higher effort provides deeper investigation for complex problems. Adjusting effort is often a better lever than switching models entirely, because you keep the same per-token rate while changing how many thinking tokens the model generates.

Available Effort Levels

Not every model supports every level:

  • Fable 5: low, medium, high, xhigh, max (default: high)
  • Opus 4.8: low, medium, high, xhigh, max (default: high)
  • Opus 4.7: low, medium, high, xhigh, max (default: xhigh)
  • Opus 4.6 and Sonnet 4.6: low, medium, high, max (default: high)

If you set a level the active model does not support, Claude Code falls back to the highest supported level at or below what you requested. Setting xhigh on Sonnet 4.6 runs as high.

When to Adjust Effort vs. Switch Models

Start by adjusting effort before reaching for a different model. Running Sonnet 4.6 at high effort handles most development work. If a task needs more reasoning, try max on the same model before switching to Opus.

The cost structure rewards this approach. Sonnet at max effort still costs $3/$15 per million tokens, the same base rate as high. You pay for more thinking tokens at Sonnet's lower rate rather than fewer tokens at Opus's higher rate. Reserve model switches for problems where the model's training and capability matter more than the reasoning budget: large multi-file refactors, decisions requiring deep codebase understanding, and architectural tradeoff analysis.

Setting the Effort Level

You can change effort through any of these methods:

  • /effort during a session (no arguments opens a slider, or type the level directly: /effort xhigh)
  • Left/right arrow keys in the /model picker to adjust the slider
  • --effort high flag when launching Claude Code
  • CLAUDE_CODE_EFFORT_LEVEL environment variable
  • effortLevel in your settings file (accepts low, medium, high, xhigh but not max)

The max level provides the deepest reasoning with no constraint on token spending and applies to the current session only. It resets when you start a new session, unless set through the environment variable.

For one-off deep reasoning without changing your session effort, type ultrathink anywhere in your prompt. Claude Code recognizes the keyword and applies deeper reasoning on that single turn.

Extended Context Windows

Context window size is another configuration dimension that compounds with model selection. Fable 5 always runs with a 1M token context window. Opus 4.8 and Sonnet 4.6 support 1M context, but availability depends on your plan:

  • Max, Team, and Enterprise: Opus with 1M context is included with your subscription. Sonnet with 1M requires usage credits.
  • Pro: Both Opus and Sonnet with 1M require usage credits.
  • API and pay-as-you-go: Full access to 1M context on all supported models.

Select the extended context version with the [1m] suffix:

/model opus[1m]
/model sonnet[1m]
/model claude-opus-4-8[1m]

The 1M window uses standard pricing with no premium for tokens beyond 200K. If your sessions regularly trigger auto-compaction or you work with large codebases, the extended window reduces information loss from context compression.

To disable 1M context entirely (useful for testing or cost control), set CLAUDE_CODE_DISABLE_1M_CONTEXT=1.

Frequently Asked Questions

What is the default model in Claude Code?

The default depends on your account type. Max, Team Premium, Enterprise pay-as-you-go, and API users default to Opus 4.8. Pro, Team Standard, and Enterprise subscription seats default to Sonnet 4.6. Bedrock, Vertex, and Foundry users default to Sonnet 4.5. Claude Platform on AWS defaults to Opus 4.7. Run /status to see which model your session is using.

How do I switch models in Claude Code?

Three ways. During a session, type /model followed by the model name (like /model opus or /model sonnet). At launch, use the --model flag (claude --model fable). For a persistent default, set the ANTHROPIC_MODEL environment variable in your shell config file. The /model command during a session takes highest priority and overrides the other methods.

What is the difference between Sonnet and Opus in Claude Code?

Sonnet 4.6 costs $3/$15 per million input/output tokens and responds faster. Opus 4.8 costs $5/$25 and provides deeper reasoning for complex tasks like large refactors, multi-file debugging, and architecture decisions. Both support 1M context windows and 128K output. Use Sonnet for daily coding and Opus when you need more thorough investigation on hard problems.

How does the effort parameter work in Claude Code?

The effort parameter (set via /effort or --effort) controls reasoning depth within your current model. Levels range from low (fastest, cheapest) through high (the default for most models) to max (deepest reasoning, session-only). Adjusting effort changes how many thinking tokens the model generates while keeping the same per-token rate. Try increasing effort before switching to a more expensive model.

What is opusplan mode in Claude Code?

The opusplan alias is a hybrid model configuration. During plan mode, Claude Code uses Opus for reasoning and architecture decisions. During execution, it automatically switches to Sonnet for code generation. This gives you Opus-quality planning with Sonnet-speed implementation. Select it with /model opusplan or claude --model opusplan.

Does model selection affect the context window size?

Yes. Haiku 4.5 has a 200K token context window. Fable 5 always runs with 1M tokens. Opus 4.8 and Sonnet 4.6 support up to 1M tokens, but availability depends on your plan. Max, Team, and Enterprise plans include 1M for Opus. Pro and other plans require usage credits. Add [1m] to any alias (like opus[1m]) to request the extended window.

Related Resources

Fastio features

Persist agent outputs across model switches and sessions

A shared workspace with version history for every file your Claude Code agents produce. Intelligence Mode indexes outputs for semantic search, so you can find what any agent wrote without remembering which session or model produced it. Starts with a 14-day free trial.