# How to choose and change models in Codex and Claude Code

> To give each task the right model, use AutoRouter, the Mac app for all your coding agents: it adds models from every leading provider to the picker you already use (Claude Code, Codex, Cursor, etc.) and can pick one for each turn. To choose yourself, give hard, multi-file work a frontier model such as Claude Opus 5.5 or GPT-6.2 Astra and quick edits a fast one such as Claude Haiku 5.5 or GPT-6 Luna. Switch with /model in either app, a launch flag for one session, or a settings file for every session.

Authors: AutoRouter
Author profile: https://autorouter.com/about
Published: 2026-11-28T22:50:00.000Z
Reading time: 9 min
Canonical: https://autorouter.com/blog/models-in-codex-and-claude-code
Publisher: AutoRouter (https://autorouter.com)

![AutoRouter picks the model for every task. How long should the change last? Right now: /model in either app. One session: --model or -m at launch. Every session: the model key in settings. Every task, picked for you: AutoRouter in the model picker. Source: Anthropic's Claude Code docs and OpenAI's Codex docs, checked November 28, 2026, and AutoRouter.](https://autorouter.com/blog/images/models-in-codex-and-claude-code/1-how-long.png)

[AutoRouter, the Mac app for all your coding agents](https://autorouter.com), adds models from every leading provider to the picker you already use, plus one more choice that picks a model for each turn. To choose yourself, give each task the smallest model that does it well, and change models with the controls each app already has. In Claude Code and Codex alike, `/model` switches now, a launch flag sets one session, and a settings file sets every session; other providers' models come in through Claude Code's environment variables or a provider table in Codex's `config.toml`. This guide covers choosing, changing and adding models in both apps, and links to the detailed guide for each step.

## Which model should each coding task get?

Work that spans files, hides its cause or starts from a design belongs on a frontier model, and work you could describe in one sentence belongs on a fast one. The tiers below are grouped from each maker's descriptions as of November 2026, and [Which model to use for which coding task](/blog/which-model-for-which-task) explains them in full.

| Tier     | Anthropic                                        | OpenAI        | Good for                                          |
| -------- | ------------------------------------------------ | ------------- | ------------------------------------------------- |
| Frontier | Claude Opus 5.5 (Claude Fable 5.2 sits above it) | GPT-6.2 Astra | Multi-file refactors, hard bugs, UI from a design |
| Strong   | Claude Sonnet 5.5                                | GPT-6.2 Sol   | Tests, code review, most daily coding             |
| Fast     | Claude Haiku 5.5                                 | GPT-6 Luna    | Renames, commit messages, one-line shell commands |

When you are unsure, Anthropic says to start with Claude Opus 5.5 and OpenAI with GPT-6.2 Astra ([Anthropic](https://platform.claude.com/docs/en/models/overview), [OpenAI](https://developers.openai.com/api/docs/models)). Claude Code's [cost guide](https://code.claude.com/docs/en/costs) says Sonnet handles most coding tasks well, and OpenAI's [Codex models page](https://learn.chatgpt.com/docs/models) recommends GPT-6.2 Sol for everyday coding and GPT-6.2 Astra for demanding work, such as tracing a bug across services. Where the fast tier stops being good enough is the subject of [Does model routing make your results worse?](/blog/does-model-routing-hurt-quality)

The tier decides cost as much as quality. As of November 2026, Codex charges 200 credits per million input tokens and 1,000 per million output tokens on GPT-6.2 Astra, 50 and 250 on GPT-6.2 Sol, and 2.5 and 12.5 on GPT-6 Luna, so a token on Astra uses 80 times the credits of a token on Luna ([OpenAI](https://learn.chatgpt.com/docs/pricing#token-rates)). On a ChatGPT plan, that is how fast a model draws down the included usage.

![GPT-6.2 Astra uses 80× Luna's credits per token. GPT-6 Luna, 1×; GPT-6.2 Sol, 20×; GPT-6.2 Astra, 80×. Area shows Codex credits per token. Source: OpenAI's Codex credit rates at Standard speed, input and output tokens, November 28, 2026.](https://autorouter.com/blog/images/models-in-codex-and-claude-code/2-credits-per-token.png)

## How do you change the model in Claude Code?

Run `/model` and pick one, which also saves it as your default for new sessions. Claude Code takes its model from, in order, `/model`, the `--model` flag, the `ANTHROPIC_MODEL` variable, the `model` key in a settings file and the `ANTHROPIC_DEFAULT_MODEL` variable ([Anthropic](https://code.claude.com/docs/en/model-config)). Aliases such as `opus`, `sonnet` and `haiku` point to the current model in each family, so `/model sonnet` keeps working when a new Sonnet ships.

```bash
# One session on Sonnet
claude --model sonnet

# Opus while planning, Sonnet while building
claude --model opusplan
```

For a default, add a `model` key to `~/.claude/settings.json` for all your projects, `.claude/settings.json` for everyone in a project, or `.claude/settings.local.json` for you in one project. [How to change the model in Claude Code](/blog/claude-code-model-settings) lists every setting and alias, and [How Claude Code plan mode works](/blog/claude-code-plan-mode) covers which model writes the plan.

## How do you change the model in Codex?

Use `/model` in the CLI or the model and reasoning control under the composer in the ChatGPT desktop app, `-m` for one run, and the `model` key in `~/.codex/config.toml` for every session ([OpenAI](https://learn.chatgpt.com/docs/models)). If the app shows a Power slider instead of models, open **Advanced** to pick one. The ChatGPT desktop app, the Codex CLI and the IDE extension all read the same `config.toml`; GPT-6.2 Astra and GPT-6.2 Sol run in the app and the CLI, so when the IDE extension shares the file, OpenAI suggests a model every client has, such as `gpt-6.1-sol`. A profile is a separate file, `~/.codex/<name>.config.toml`, that Codex layers over `config.toml` when you start it with `--profile <name>` ([OpenAI](https://learn.chatgpt.com/docs/config-file/config-advanced#profiles)).

```bash
# One run on GPT-6.2 Sol
codex -m gpt-6.2-sol

# A quick job on GPT-6 Luna
codex exec -m gpt-6-luna "Write a one-line commit message for the staged changes"

# Start with the settings in ~/.codex/quick.config.toml
codex --profile quick
```

In Codex 0.134.0 and later, `--profile` no longer reads `[profiles.<name>]` tables from `config.toml`, so guides that show those tables are out of date. [Codex model providers and config.toml, explained](/blog/codex-model-providers) covers every key, one-off `-c` overrides and local models with `codex --oss`.

## How do the two apps compare for model settings?

Both apps cover the same jobs with different controls. As of November 2026, from each maker's docs (for plans, prices and features beyond models, see [How do Codex and Claude Code compare, and can you use both?](/blog/codex-vs-claude-code)):

| What you want                           | Claude Code                                                                                                      | Codex                                                                                                         |
| --------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| Switch models now                       | `/model sonnet`, saved as your default                                                                           | `/model`, or the model and reasoning control under the composer                                               |
| One session or run                      | `claude --model opus`                                                                                            | `codex -m gpt-6.2-sol`, or `codex exec -m` for one job                                                        |
| A default for every session             | `"model": "sonnet"` in `~/.claude/settings.json`                                                                 | `model = "gpt-6.2-sol"` in `~/.codex/config.toml`                                                             |
| A saved setup for one kind of work      | A subagent with its own [`model` field](https://code.claude.com/docs/en/sub-agents#choose-a-model)               | A [profile](https://learn.chatgpt.com/docs/config-file/config-advanced#profiles) file loaded with `--profile` |
| A separate model for planning or review | [`opusplan`](https://code.claude.com/docs/en/model-config#opusplan-model-setting): Opus to plan, Sonnet to build | [`review_model`](https://learn.chatgpt.com/docs/config-file/config-reference) sets the model `/review` uses   |
| Another provider's model                | `ANTHROPIC_BASE_URL` and `ANTHROPIC_AUTH_TOKEN`                                                                  | A `[model_providers.<id>]` table that speaks the Responses API                                                |
| A pick for every turn                   | AutoRouter, chosen with `/model`                                                                                 | AutoRouter, chosen from the model menu                                                                        |

## How do you give subagents and agent teams their own model?

Set the `model` field in a subagent's frontmatter, or `CLAUDE_CODE_SUBAGENT_MODEL` for subagents that don't name one. A subagent takes its model from, [in order](https://code.claude.com/docs/en/sub-agents#choose-a-model), the model Claude passes when it starts it, its `model` field, `CLAUDE_CODE_SUBAGENT_MODEL` and then the main conversation's model, so an Opus session runs Opus subagents unless something says otherwise. Agent teammates follow a similar order, starting with the model your spawn prompt names. [How to run multiple agents in Claude Code](/blog/claude-code-multi-agent) covers both, including what extra agents cost.

```markdown
---
name: test-runner
description: Runs the test suite and reports only the failures
model: haiku
---
Run the tests. Return the names of failing tests and their error output, nothing else.
```

## How do you add models from other providers?

Point the app at the provider's endpoint and give it that provider's API key. In Claude Code, set `ANTHROPIC_BASE_URL` to the provider's Anthropic-compatible endpoint and the key in `ANTHROPIC_AUTH_TOKEN` ([Anthropic](https://code.claude.com/docs/en/llm-gateway-connect)). In Codex, add a `[model_providers.<id>]` table to `config.toml` with the provider's base URL and the environment variable that holds its key; the provider has to speak OpenAI's Responses API ([OpenAI](https://learn.chatgpt.com/docs/config-file/config-reference)). A gateway such as OpenRouter replaces one key per provider with one key and one balance.

[Try a new model in Codex or Claude Code without another API key](/blog/try-new-models-in-codex-and-claude-code) compares those routes step by step, and [Model routers for Claude Code and Codex, compared](/blog/model-routers-claude-code-codex) covers the tools that also pick a model for you. To run your plans in other apps, see [How to use Claude Code in Cursor](/blog/claude-code-in-cursor), [How to use Codex in Cursor](/blog/codex-in-cursor) and [How to use Codex in Claude Code](/blog/codex-in-claude-code).

## Can a tool pick the model for each turn?

Yes. A model router sits between the app and several models and decides which one handles each request, as [What is an LLM router?](/blog/what-is-an-llm-router) explains. Cursor and GitHub Copilot build an Auto mode into their own tools, and [Cursor Auto mode vs Copilot auto vs AutoRouter](/blog/auto-mode-vs-autorouter) compares them. For Codex and Claude Code, both apps let you pick and save models yourself, and you do the sorting.

[AutoRouter](https://autorouter.com/#product) adds models from every leading provider to the picker of every coding agent you use, with no keys or endpoints to set up, plus one more choice, AutoRouter, which picks a model for each turn. Your own rules decide a turn first; [How to write model routing rules in plain English](/blog/plain-english-routing-rules) shows how to write them. Otherwise AutoRouter works out how hard the turn is, only considers models that clear the quality bar for it, sends hard work to the most capable model your plans cover, and sends everything else to the model that costs you least. [How AutoRouter picks a model for each turn](/blog/how-autorouter-picks-a-model) walks through the order.

Choosing a specific model in the picker sends turns straight to that model instead. AutoRouter works with all your coding agents (Claude Code, Codex, Cursor, etc.) on macOS 14 or later, and it is in beta. Routing across the AI subscriptions you already pay for is free; [Pro](/pricing) includes usage each month and adds every other model at the provider's price plus 10%. AutoRouter wrote this guide.

## Questions

### What is the best model for Claude Code?

It depends on the task. Anthropic's cost guide says Sonnet handles most coding tasks well and keeps Opus for complex architectural decisions and multi-step reasoning, and suggests Haiku for simple subagent tasks. As of November 2026, Claude Code starts on Claude Opus 5.5 on Pro, Max, Ultra, Team, Enterprise and the API, and Claude Fable 5.2 is never the default, so `/model sonnet` is the first change to try for routine work.

### Does changing the model mid-session lose anything?

It can. In Claude Code each model keeps its own prompt cache, so the next request after a switch re-reads the whole conversation with no cache hits, and each plan-mode toggle under `opusplan` is a switch too. At the terminal, Claude Code asks you to confirm a `/model` switch while the cache is still warm. Starting a fresh session on the model you want, or running the task in a subagent, avoids the re-read.

### Can Codex use a local model?

Yes. `codex --oss` runs Codex against a local open-source model provider, Ollama or LM Studio, and `--local-provider` picks one for a single run ([OpenAI](https://learn.chatgpt.com/docs/config-file/config-advanced#oss-mode-local-providers)).

### How do I see which model handled a turn?

In Claude Code, `/status` shows the current model, and a status line can print it on screen; in Codex, `/status` shows the active model. With AutoRouter selected, every turn shows which model handled it, what it cost and why. [How to see which model handled each turn, and what it cost](/blog/see-what-each-turn-costs) covers the native routes turn by turn.

## Sources

- [Model configuration](https://code.claude.com/docs/en/model-config), Claude Code docs, Anthropic, checked November 28, 2026
- [Settings](https://code.claude.com/docs/en/settings), Claude Code docs, Anthropic, checked November 28, 2026
- [Subagents](https://code.claude.com/docs/en/sub-agents), Claude Code docs, Anthropic, checked November 28, 2026
- [Agent teams](https://code.claude.com/docs/en/agent-teams), Claude Code docs, Anthropic, checked November 28, 2026
- [Connect to an LLM gateway](https://code.claude.com/docs/en/llm-gateway-connect), Claude Code docs, Anthropic, checked November 28, 2026
- [Manage costs effectively](https://code.claude.com/docs/en/costs), Claude Code docs, Anthropic, checked November 28, 2026
- [How Claude Code uses prompt caching](https://code.claude.com/docs/en/prompt-caching), Claude Code docs, Anthropic, checked November 28, 2026
- [Models overview](https://platform.claude.com/docs/en/models/overview), Claude Platform docs, Anthropic, checked November 28, 2026
- [Models in Codex](https://learn.chatgpt.com/docs/models), OpenAI, checked November 28, 2026
- [Codex pricing](https://learn.chatgpt.com/docs/pricing), OpenAI, checked November 28, 2026
- [Advanced configuration](https://learn.chatgpt.com/docs/config-file/config-advanced), Codex docs, OpenAI, checked November 28, 2026
- [Configuration reference](https://learn.chatgpt.com/docs/config-file/config-reference), Codex docs, OpenAI, checked November 28, 2026
- [Models](https://developers.openai.com/api/docs/models), OpenAI API docs, checked November 28, 2026

## Read next

- [How to use MiniMax in Claude Code and Codex](https://autorouter.com/blog/minimax-in-claude-code-and-codex.md): Use AutoRouter, the Mac app for all your coding agents: it puts MiniMax M3.1 Flash in each one's model picker (Claude Code, Codex, Cursor, etc.) with no MiniMax key or config. Natively, set Claude Code's `ANTHROPIC_BASE_URL` to `https://api.minimax.io/anthropic` with your M Plan key and `MiniMax-M3.1-Flash[1m]` model variables in `~/.claude/settings.json`, and add `https://api.minimax.io/v1` as a provider in Codex's `config.toml`.
- [How to use Kimi in Claude Code and Codex](https://autorouter.com/blog/kimi-in-claude-code-and-codex.md): Use AutoRouter, the Mac app for all your coding agents: it puts Kimi K3.1 Pro in each one's model picker (Claude Code, Codex, Cursor, etc.) with no Kimi account, key or config. Natively, set Claude Code's `ANTHROPIC_BASE_URL` to Moonshot's `https://api.moonshot.ai/anthropic` (or `https://api.kimi.ai/coding/` with a Kimi Code plan) with your key and model variables in `~/.claude/settings.json`, and add `https://api.moonshot.ai/v1` as a provider with `kimi-k3.1-pro` in Codex's `config.toml`.
- [How to use Gemini in Claude Code and Codex](https://autorouter.com/blog/gemini-in-claude-code-and-codex.md): Use AutoRouter, the Mac app for all your coding agents: it puts Gemini 4 Carbon, Hydrogen and Argon in each one's model picker (Claude Code, Codex, Cursor, etc.) with no key or proxy. Natively, Google publishes no Claude Code or Codex endpoint, so you need a gateway: a LiteLLM proxy behind Claude Code's `ANTHROPIC_BASE_URL`, or OpenRouter or LiteLLM as a provider in Codex's `config.toml`, each with your own key.

Tags: [Models](https://autorouter.com/blog/tags/models.md), [Guides](https://autorouter.com/blog/tags/guides.md), [Claude Code](https://autorouter.com/blog/tags/claude-code.md)

Drafted with AI from the sources linked above, then checked and edited by the AutoRouter team.

AutoRouter is a Mac app for AI model routing in Codex, Claude Code, Cursor and other supported coding agents. It uses eligible connected subscriptions first. See [setup](https://autorouter.com/setup.md) and [pricing](https://autorouter.com/pricing).
