How to Change the Model in Claude Code

Claude Code lets you switch between models — Sonnet, Opus, Haiku, and Fable 5 — at almost any point: mid-conversation, at startup, as a permanent default, or through a keyboard shortcut. This guide walks through every method, across the terminal, VS Code, and GitHub Actions.

Quick answer

The fastest way to switch models is the /model command, typed directly into your Claude Code session:

/model sonnet
/model opus
/model haiku

Run /model with no argument to open an interactive picker instead of typing the model name directly.

Change the model mid-conversation

You don't need to end your session to switch models. Type /model followed by an alias or full model name at any point in the conversation:

/model opus

Claude Code switches immediately, and — as of recent versions — also saves your choice as the default for new sessions. If you only want the switch to apply to this session, open the picker with /model (no argument) and press s on the highlighted model instead of Enter.

Available model aliases:

Alias What it does
default Clears any override and reverts to your account's runtime default
best Fable 5 where available, otherwise the latest Opus
fable Claude Fable 5, for the hardest and longest-running tasks
sonnet Latest Sonnet model, for everyday coding
opus Latest Opus model, for complex reasoning
haiku Fast, efficient model for simple tasks
sonnet[1m] / opus[1m] Same model with a 1M-token context window
opusplan Uses Opus during plan mode, then switches to Sonnet for execution

You can also type a full model name, e.g. /model claude-opus-4-8.

Change the model to Opus

To switch to Opus specifically, run:

/model opus

Or launch a new session directly on Opus:

claude --model opus

If your goal is Opus-quality planning with cheaper execution, use the hybrid alias instead:

/model opusplan

This plans with Opus and automatically switches to Sonnet once it starts writing code.

Change the model with a keyboard shortcut

Claude Code has a built-in shortcut to open the model picker without typing /model:

  • macOS: Option+P
  • Windows/Linux: Alt+P

This opens the same interactive picker as running /model with no argument. From there, use the left/right arrow keys to adjust the effort level for the highlighted model before confirming.

You can rebind this (the chat:modelPicker action) or any other shortcut by editing ~/.claude/keybindings.json. Run /keybindings to open or create that file.

Change the model at startup

To start a new terminal session on a specific model without touching /model, pass the --model flag:

claude --model opus
claude --model sonnet
claude --model claude-opus-4-8

This applies only to the session you launch — it isn't saved as your default. It's useful for running different models in different terminal windows at the same time.

You can achieve the same thing with an environment variable for a single shell session:

export ANTHROPIC_MODEL=opus
claude

Change the default model

There are a few ways to make a model choice persistent, depending on scope.

Save your personal default — the simplest way is via /model: in recent versions, pressing Enter on a model in the picker (or typing /model <name> directly) saves it as your default for future sessions automatically.

Set it explicitly in your settings file (~/.claude/settings.json):

{
  "model": "opus"
}

Set a default for brand-new sessions only, without overriding an existing saved choice, using an environment variable (requires Claude Code v2.1.236+):

export ANTHROPIC_DEFAULT_MODEL=sonnet

Order of precedence, highest to lowest: the --model flag → ANTHROPIC_MODEL env var → the model field in settings (including anything saved via /model) → an organization-set default → ANTHROPIC_DEFAULT_MODEL.

Change the model in VS Code

The VS Code extension uses the same underlying model logic as the CLI, surfaced through its command menu:

  1. Open the Claude Code panel (click the Spark icon, or use the Command Palette → "Claude Code").
  2. Click the / icon in the prompt box, or type /, to open the command menu.
  3. Choose the model-switching option from the list.

Model switches made in the VS Code extension and the CLI share the same underlying settings, since both read from ~/.claude/settings.json.

Change the model in Claude Code GitHub Actions

For automated workflows (the claude-code-action GitHub Action), set the model through the claude_args input rather than /model, since there's no interactive session to type into:

- uses: anthropics/claude-code-action@v1
  with:
    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
    prompt: "Generate a summary of yesterday's commits and open issues"
    claude_args: |
      --model claude-opus-4-8
      --allowedTools "mcp__github__list_commits,mcp__github__list_issues"

If you omit --model, the action falls back to Claude Code's normal default-model resolution. You can pass any model name or alias the CLI accepts (sonnet, opus, claude-sonnet-5, etc.).

Organization-managed model restrictions

If you're on a Claude Enterprise plan, an admin may restrict which models are selectable org-wide via availableModels in managed settings, or by disabling specific models in the claude.ai admin console. If a model you try to select is greyed out in the picker or gets silently substituted with a notice, this is almost always why — check with your organization admin rather than your local settings.

Checking your current model

To confirm which model is active right now:

  • Look at your status line, if you've configured one.
  • Run /status, which shows your current model alongside account and usage info.

Quick reference

I want to... Do this
Switch models right now /model <alias>
Open the model picker /model or Option+P / Alt+P
Switch for this session only /model → highlight model → press s
Start a session on a specific model claude --model <alias>
Set my personal default permanently /model <alias> (Enter), or edit "model" in ~/.claude/settings.json
Set the model in VS Code Command menu (/) → model option
Set the model in a GitHub Action claude_args: "--model <name>"