Skip to content
InnovateTechie
Claude Code

How to Change the Model in Claude Code (Every Method)

InnovateTechieBy InnovateTechie10 min read
Share
How to change model in Claude Code — the /model command switching between Opus, Sonnet, and Haiku

Part ofWhat Is Claude Code? The Complete Guide

Quick answer

How to change model in Claude Code: type /model to switch between Opus, Sonnet, and Haiku instantly, or set a permanent default with --model.

To change the model in Claude Code, type /model and pick from the list, or run /model opus (or sonnet / haiku) to switch instantly mid-session. To make a choice stick, launch with claude --model opus or set ANTHROPIC_MODEL in your shell. This guide covers how to change model in Claude Code every way — for one session and as your permanent default.

Commands, aliases, and model lineup verified 31 July 2026 against the Claude Code model configuration reference.

Switching models is one of the highest-leverage habits in Claude Code: Sonnet for the fast bulk of your work, Opus for the genuinely hard problems, Haiku for cheap throwaway tasks. We move between them constantly. The lineup currently spans Claude Opus 5, Claude Sonnet 5, and Claude Haiku 4.5, and the switch itself takes under 10 seconds — we review this guide regularly so the commands and aliases stay accurate. Below is exactly how to change model in Claude Code — mid-session with a keystroke, at launch with a flag, and permanently through config — plus which one to reach for and what to do when the switch won't take.

Key takeaway

To change the model in Claude Code, type /model or /model opus|sonnet|haiku to switch instantly for the session, or set the ANTHROPIC_MODEL variable or launch with --model to make Opus 5, Sonnet 5, or Haiku 4.5 your permanent default.

Step 1: See which model Claude Code is using

Type /model on its own — it prints the active model and opens the picker. /status also shows it alongside your account and version.

Before you switch, check what's active so you can confirm the change. Type this in an interactive session:

/model

Run on its own, /model shows your current model and opens the picker listing every model you can select. You can also type /status to see the active model alongside your account and version. Knowing the starting point makes the next step unambiguous.

Step 2: How to change model in Claude Code with the /model command

Run /model opus, /model sonnet, or /model haiku. The change applies immediately and lasts the rest of the session.

The /model command is the fastest way to switch, and it's the answer most people are looking for. Pass an alias to jump straight to a model without touching the menu:

/model opus      # switch to the latest Opus
/model sonnet    # switch to the latest Sonnet
/model haiku     # switch to the fast, cheap Haiku

The change applies immediately and lasts for the rest of the session. This is the core of how to change model in Claude Code on the fly — start a task on Sonnet, hit a hard architectural decision, type /model opus, and drop back to /model sonnet when the tricky part is done.

How to change model in Claude Code — the /model command switching between Opus, Sonnet, and Haiku

Step 3: How to change model in Claude Code permanently

Three options: launch with claude --model opus, export ANTHROPIC_MODEL in your shell, or set the model key in settings.json.

/model only changes the current session. To set a default that every new session uses, you have three options — pick whichever fits your workflow:

  1. Launch flag — start Claude Code on a specific model for that run:
    claude --model opus
  2. Environment variable — set it once in your shell so every session inherits it. Add this to .zshrc or .bashrc:
    export ANTHROPIC_MODEL="claude-sonnet-5"
  3. Settings file — set the model key in your settings.json for a per-project or per-user default.

The environment variable is the cleanest permanent answer to how to change model in Claude Code for good, while --model is handy for one-off runs. All three are documented in the Claude Code model configuration reference.

Model aliases: opus, sonnet, haiku, and opusplan

Short aliases mean you never type a full model ID — sonnet, opus, haiku, plus best, opusplan, and the [1m] long-context variants.

Claude Code accepts short aliases so you never have to type a full model ID. These are the ones worth knowing:

AliasWhat it selects
sonnetLatest Sonnet — the balanced daily-driver default
opusLatest Opus — deepest reasoning and hardest refactors
haikuLatest Haiku — fastest and cheapest for simple tasks
bestThe most capable model available to your plan
sonnet[1m]Sonnet with a 1M-token context window
opus[1m]Opus with a 1M-token context window
opusplanOpus during plan mode, then Sonnet for execution

opusplan is the power move: you get Opus's planning quality where it matters most and Sonnet's speed and price for the actual edits. Use sonnet[1m] or opus[1m] when you're working across a large codebase that needs the extra context.

Which model should you switch to

Default to Sonnet; escalate to Opus when a mistake is expensive to catch; drop to Haiku for mechanical bulk work.

Changing the model is only useful if you pick the right one. The rule of thumb: default to Sonnet, escalate to Opus when a mistake is expensive to catch.

TaskSwitch to
Everyday coding, tests, small fixessonnet
Large multi-file refactors, architectureopus
Long autonomous agent runsopus or opusplan
Bulk, simple, or throwaway workhaiku

Sonnet now delivers most of Opus's coding quality at a fraction of the cost — Sonnet 5 runs $3/$15 per million tokens against Opus 5's $5/$25, while Haiku 4.5 drops to $1/$5 — so you'll stay on Sonnet more than you expect; we break down exactly where each wins in Claude Sonnet vs Opus. Model access also depends on your plan; Opus needs Max or API credits, which we cover in Claude Code cost.

Claude Code model aliases and where to set them — session, launch flag, and environment variable

Troubleshooting: the model won't change

Almost always one of three things: the model is not on your plan, a stale ANTHROPIC_MODEL is overriding you, or you edited settings mid-session.

If a switch doesn't take, it's almost always one of these:

  1. The model isn't on your plan. Opus requires Max or API access — on Pro, /model opus may be unavailable or capped. Anthropic's model configuration guide lists what each plan can select.
  2. An environment variable is overriding you. A stale ANTHROPIC_MODEL in your shell config wins over expectations. Check with echo $ANTHROPIC_MODEL and unset it if it's forcing the wrong model.
  3. You edited settings mid-session. Config changes apply on the next launch — restart Claude Code after editing settings.json.

Item 2 is the one that caught us out on our own machine. We run Claude Code against this site from a Windows PowerShell terminal, and after setting ANTHROPIC_MODEL once for a bulk Haiku job we forgot it was there — every new session silently opened on the wrong model until we ran the environment check and cleared it. Since then, whenever a /model switch appears to "not take," the first thing we check is a leftover environment variable rather than anything inside Claude Code itself. The tell is subtle: the picker reports the switch succeeded, so it looks like it worked, but the very next session quietly reverts because the environment variable wins on every fresh launch while an in-session pick only lasts until you close the window. Running the check above settles it in seconds, and clearing the variable restores the ordinary precedence where your launch flag and your session picks behave exactly the way the documentation describes.

That covers how to change model in Claude Code when the obvious command seems to do nothing. For the complete list of commands and config keys, see our Claude Code CLI documentation.

Model-switching workflows worth stealing

Knowing how to switch matters less than knowing when. Four patterns cover almost every session: plan-on-Opus, escalate-and-step-back, drop-to-Haiku, and pin-per-project.

Knowing switching models is one thing; knowing when is what saves time and money. These are the switching patterns we lean on every day, and they're the real reason the /model command matters:

  • Plan on Opus, build on Sonnet. Type /model opusplan and let Claude Code use Opus while it plans, then Sonnet while it edits — the single best default for any non-trivial feature. It pairs naturally with plan mode, where the planning quality pays off most.
  • Escalate mid-task, then step back down. Start on sonnet, hit a gnarly bug or an architecture call, run /model opus, solve it, then /model sonnet. You pay Opus rates only for the few minutes you genuinely need them, which keeps your bill close to Sonnet's.
  • Drop to Haiku for grunt work. Bulk renames, log parsing, quick file summaries — /model haiku costs a fraction of Sonnet and is plenty capable for mechanical tasks that don't need deep reasoning.
  • Pin a default per project. A repo that always needs deep reasoning can set ANTHROPIC_MODEL in a project-level config, so every session there opens on Opus without a manual switch.

The point of learning switching models isn't to fiddle with settings — it's to match the model to the moment. Most of your day lives comfortably on Sonnet; the real wins come from the deliberate jumps up to Opus for hard problems and down to Haiku for cheap, high-volume work.

SituationCommandWhy
New feature, unsure of approach/model opusplanOpus plans, Sonnet executes
Sudden hard bug or design call/model opusDeepest reasoning, then switch back
Repetitive bulk edits/model haikuCheapest, fast enough
Working across a whole codebase/model opus[1m]1M-token context window

Frequently Asked Questions

Type /model in an interactive session to open the picker, or run /model opus, /model sonnet, or /model haiku to switch instantly. The change lasts for that session. To make it permanent, launch with claude --model or set the ANTHROPICMODEL environment variable.

Set ANTHROPICMODEL in your shell config (for example export ANTHROPICMODEL="claude-sonnet-5" in .zshrc), add the model key to settings.json, or pass --model at launch. Any of these makes every new session start on your chosen model.

Claude Code supports Opus, Sonnet, and Haiku via the opus, sonnet, and haiku aliases, plus best, opusplan, and 1M-context variants sonnet[1m] and opus[1m]. Which ones you can select depends on your plan — Opus generally needs Max or API access.

opusplan is a hybrid mode: Claude Code uses Opus while you're in plan mode for the highest-quality planning, then automatically switches to Sonnet for executing the edits. It gives you Opus reasoning where it matters and Sonnet speed and cost for the rest.

It can. Opus costs more per token than Sonnet, and Haiku costs less — so switching model changes your rate. On a subscription, usage counts against your plan limits rather than a per-token bill. See our Claude Code cost guide for the full breakdown.

Run /model sonnet (or /model default where available) to return to the standard model for the session. To reset a permanent default, unset ANTHROPICMODEL in your shell config or remove the model key from settings.json, then restart Claude Code.
InnovateTechie

Written by

InnovateTechie

Writing about Claude and the Anthropic toolkit — models, Claude Code, pricing, features, and fixes, in clear, practical, hands-on guides tested by daily use.

View all posts →