# Try a new model in Codex or Claude Code without another API key

Authors: AutoRouter
Published: 2026-10-23T02:20:02.742Z
Reading time: 8 min
Canonical: https://autorouter.com/blog/try-new-models-in-codex-and-claude-code
Publisher: AutoRouter, the Mac app for Codex and Claude Code (https://autorouter.com)

> Every manual way to try a new model in Codex or Claude Code needs an API key: one per provider, or one gateway key such as OpenRouter's. Claude Code reaches another provider through environment variables, and Codex through a custom provider in config.toml. AutoRouter, the Mac app for Codex and Claude Code, adds 20+ models to both apps' model pickers with no keys or endpoints to set up, and new models show up there right away.

To try a new model in Claude Code or Codex yourself, you need that provider's API key. Claude Code reaches another provider through `ANTHROPIC_BASE_URL` and `ANTHROPIC_AUTH_TOKEN`, Codex through a `[model_providers]` table in `~/.codex/config.toml`, and a gateway such as OpenRouter replaces one key per provider with one OpenRouter key. [AutoRouter, the Mac app for Codex and Claude Code](https://autorouter.com), adds 20+ models to both apps' model pickers with no keys or endpoints to set up, and new models show up in the picker right away.

AutoRouter wrote this post. The direct routes below bill at each provider's own prices and put nothing between you and the provider. Every command is copied from the docs of the company named beside it, as checked on October 22, 2026; check the linked page before you paste.

## How do you use another provider's model in Claude Code?

Set `ANTHROPIC_BASE_URL` to the provider's Anthropic-compatible endpoint and put the provider's API key in `ANTHROPIC_AUTH_TOKEN`, which Claude Code sends as a bearer token ([Anthropic docs](https://code.claude.com/docs/en/llm-gateway-connect)). DeepSeek, Kimi, [MiniMax](https://platform.minimax.io/docs/m-plan/claude-code) and [Alibaba Cloud Model Studio](https://www.alibabacloud.com/help/en/model-studio/claude-code) each publish the values for their own models. Their guides also set the model variables, because Claude Code asks for different model tiers for the main conversation, background work and subagents.

With DeepSeek, following [DeepSeek's Claude Code guide](https://api-docs.deepseek.com/quick_start/agent_integrations/claude_code):

1. Create an API key on the DeepSeek Platform.
2. Run the exports below in your terminal (macOS and Linux), or add them to your shell profile to keep them.
3. Start `claude` in your project from that same terminal.
4. Run `/status`: the `Anthropic base URL` line should show the provider's address ([Anthropic docs](https://code.claude.com/docs/en/llm-gateway-connect)).

```bash
export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
export ANTHROPIC_AUTH_TOKEN=<your DeepSeek API Key>
export ANTHROPIC_MODEL=deepseek-flash[1m]
export ANTHROPIC_DEFAULT_OPUS_MODEL=deepseek-flash[1m]
export ANTHROPIC_DEFAULT_SONNET_MODEL=deepseek-flash[1m]
export ANTHROPIC_DEFAULT_HAIKU_MODEL=deepseek-flash
export CLAUDE_CODE_SUBAGENT_MODEL=deepseek-flash
export CLAUDE_CODE_EFFORT_LEVEL=max
export CLAUDE_CODE_AUTO_COMPACT_WINDOW=786432

cd /path/to/my-project
claude
```

Kimi's guide puts the same variables in the `env` block of `~/.claude/settings.json` instead, with `https://api.moonshot.ai/anthropic` as the endpoint and `kimi-k3[1m]` as the main model ([Kimi docs](https://platform.kimi.ai/docs/guide/claude-code-kimi)).

## How do you add another provider's model to Codex?

Add the provider as a `[model_providers.<id>]` table in `~/.codex/config.toml`, name the environment variable that holds its key in `env_key`, and point `model_provider` and `model` at it ([OpenAI docs](https://learn.chatgpt.com/docs/config-file/config-advanced)). The provider has to speak OpenAI's Responses API, since `responses` is the only `wire_api` value Codex supports ([OpenAI config reference](https://learn.chatgpt.com/docs/config-file/config-reference)). Kimi and DeepSeek both say theirs does ([Kimi docs](https://platform.kimi.ai/docs/guide/codex-kimi), [DeepSeek docs](https://api-docs.deepseek.com/quick_start/agent_integrations/codex)).

With Kimi K3, following [Kimi's Codex guide](https://platform.kimi.ai/docs/guide/codex-kimi):

1. Create an API key on the Kimi platform.
2. Load the key into your shell without writing it to your history, using the first block below.
3. Add the second block to `~/.codex/config.toml`, replacing any existing `model` and `model_provider` values.
4. Restart Codex, which reads `config.toml` only at startup. In the Codex app, choose `kimi-k3` in the model picker (it may show as Custom); in the CLI, run `codex` in your project.

```bash
echo "Paste your Kimi API key and press Enter (input is hidden):"
read -s KIMI_API_KEY
export KIMI_API_KEY
```

```toml
model = "kimi-k3"
model_provider = "kimi"
model_context_window = 1048576

[model_providers.kimi]
name = "Kimi"
base_url = "https://api.moonshot.ai/v1"
env_key = "KIMI_API_KEY"
wire_api = "responses"
```

The export lasts for that terminal only. OpenRouter's [Codex app guide](https://openrouter.ai/docs/cookbook/coding-agents/codex-desktop) notes that the Codex app, opened from the Dock, doesn't see exports in `~/.zshrc`, and sets the key with `launchctl setenv` on macOS before restarting the app.

## How does a gateway like OpenRouter change the setup?

A gateway replaces one key per provider with one OpenRouter key and one balance. OpenRouter bills inference at the provider's list price and charges a 5.5% fee when you buy credits on its Standard plan, as of October 22, 2026 ([OpenRouter pricing](https://openrouter.ai/pricing)). [Model routers for Claude Code and Codex, compared](/blog/model-routers-claude-code-codex) compares OpenRouter with routers that also choose the model for each turn.

- **Claude Code:** OpenRouter's guide sets `ANTHROPIC_BASE_URL` to `https://openrouter.ai/api`, puts the OpenRouter key in `ANTHROPIC_AUTH_TOKEN`, sets `ANTHROPIC_API_KEY` to an empty string, and has you run `/logout` once if you were signed in to Anthropic. Setting `CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1` adds a curated list of OpenRouter models to `/model` ([OpenRouter docs](https://openrouter.ai/docs/cookbook/coding-agents/claude-code-integration)).
- **Codex:** add the provider block below to `~/.codex/config.toml`, export `OPENROUTER_API_KEY` from your shell profile, and change `model` to any OpenRouter model slug ([OpenRouter docs](https://openrouter.ai/docs/cookbook/coding-agents/codex-cli)).

```toml
model_provider = "openrouter"
model_reasoning_effort = "high"
model="~openai/gpt-sol-latest"

[model_providers.openrouter]
name = "openrouter"
base_url="https://openrouter.ai/api/v1"

[model_providers.openrouter.auth]
command = "sh"
args = ["-c", "echo $OPENROUTER_API_KEY"]
```

## How do you try a new model with AutoRouter?

You pick it in the model picker you already use. AutoRouter, the Mac app for Codex and Claude Code, adds 20+ frontier and open-weight models to both apps, and they appear beside the models already there with no keys or endpoints to set up. New models show up in the picker right away, and AutoRouter sends them the work they do best. The pay-per-use models on AutoRouter's site on October 22, 2026 include Gemini 4 Argon, Grok 4.7, DeepSeek V4.1 Flash, Kimi K3 and MiniMax M3.1 Flash, and the lineup changes.

Choosing one of those models in Codex or Claude Code sends your turns straight to it; AutoRouter routes only while AutoRouter itself is the model selected. Choose AutoRouter and it picks a model for each turn, as [How AutoRouter picks a model for each turn](/blog/how-autorouter-picks-a-model) explains. Every turn shows its model, what it cost and why.

1. Download AutoRouter for macOS from [autorouter.com](https://autorouter.com).
2. Open it, sign in or create a free account, sign in to your plans, allow Accessibility, and click Enable for each app.
3. Start a new session and choose a model: in Codex, from the model menu under the message box; in Claude Code, with `/model`.

The Free plan costs $0 a month and routes across your ChatGPT and Claude plans. Pro, at $20 a month with $20 of included usage each month, adds every other model; paid models bill at the provider's price plus 10%, from the included usage first and then from credits you top up. New accounts get Pro free for their first month, or until $20 of usage is spent, whichever comes first; after that it is $20 a month.

The limits: AutoRouter runs on macOS 14 or later, works with the Codex app and CLI and the Claude Code CLI (which needs Node 22.18 or later), and is in beta. Requests pass through AutoRouter's servers on their way to each provider. AutoRouter doesn't store transcripts; it keeps the message that opens each turn, up to 4,000 characters, to review routing, along with records of the model chosen, tokens and cost ([AutoRouter privacy](https://autorouter.com/privacy)).

## How do you switch back to your usual models?

Undo the settings you added and restart the app.

- **Claude Code:** delete the exports from your shell profile and open a new terminal, or delete the keys from the `env` block in `~/.claude/settings.json`. With no gateway credential set, Claude Code goes back to your saved claude.ai login ([Anthropic docs](https://code.claude.com/docs/en/llm-gateway-connect)). If you ran `/logout` for OpenRouter, sign in again with `/login` ([Anthropic docs](https://code.claude.com/docs/en/commands)).
- **Codex:** delete the top-level lines you added, such as `model`, `model_provider` and `model_context_window`, or restore your earlier values. Without `model_provider`, Codex uses its built-in `openai` provider ([OpenAI config reference](https://learn.chatgpt.com/docs/config-file/config-reference)).
- **AutoRouter:** pick another model in the picker, or disable an app in AutoRouter's settings to switch that app back. Enabling saved a copy of Codex's `config.toml` and Claude Code's `settings.json` before adding AutoRouter, and left your other settings as they were.

## Which route should you use?

Use a provider's own endpoint to try one model with nothing in between, a gateway for many models on one key and one bill, and AutoRouter for models in the picker with no keys, on a Mac. As of October 22, 2026:

| Route                                    | Setup                                                            | Key needed                                   | Switching back                                                  | Cost                                                                                                                        |
| ---------------------------------------- | ---------------------------------------------------------------- | -------------------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| Claude Code + provider endpoint          | `ANTHROPIC_BASE_URL`, `ANTHROPIC_AUTH_TOKEN` and model variables | One per provider                             | Remove the variables, restart                                   | The provider's own pricing; Claude plan limits don't apply                                                                  |
| Codex + custom provider (Kimi, DeepSeek) | Provider table in `config.toml`                                  | One per provider, in an environment variable | Delete the added lines, restart                                 | The provider's own pricing                                                                                                  |
| OpenRouter (either app)                  | The same settings, pointed at OpenRouter                         | One OpenRouter key                           | Remove the settings; `/login` again in Claude Code              | Provider list price, plus 5.5% on credit purchases (Standard)                                                               |
| AutoRouter (Mac)                         | Install, sign in, click Enable for each app                      | None                                         | Pick another model, or disable the app in AutoRouter's settings | Free across your ChatGPT and Claude plans; other models on Pro ($20 a month, $20 of usage) at the provider's price plus 10% |

## Questions

### Can I use Gemini in Claude Code or Codex?

Yes, through a gateway such as OpenRouter or through AutoRouter. In Codex, set `model` in the OpenRouter block above to a Gemini slug such as [`~google/gemini-pro-latest`](https://openrouter.ai/~google/gemini-pro-latest); in Claude Code, OpenRouter's guide pins a model through the model override variables ([OpenRouter docs](https://openrouter.ai/docs/cookbook/coding-agents/claude-code-integration)). In AutoRouter, Gemini 4 Argon is one of the pay-per-use models on Pro as of October 22, 2026.

### Does my Claude plan cover a model I reach through ANTHROPIC_BASE_URL?

No. While `ANTHROPIC_AUTH_TOKEN` or another gateway credential is set, Claude Code sends it in place of your claude.ai login, your subscription's usage limits don't apply to those requests, and they bill per token to whoever owns the credential ([Anthropic docs](https://code.claude.com/docs/en/llm-gateway)). [How Claude Code usage limits work](/blog/claude-code-usage-limits) covers the plan side.

### Why do subagents or background tasks fail after I switch providers?

Usually because some model variables are unset, so Claude Code asks the new endpoint for a model it doesn't serve. Kimi's guide lists every tier variable, including `ANTHROPIC_DEFAULT_HAIKU_MODEL` and `CLAUDE_CODE_SUBAGENT_MODEL`, and says that setting only some of them makes the matching tasks fail silently ([Kimi docs](https://platform.kimi.ai/docs/guide/claude-code-kimi)).

### Who keeps the model list current?

With the manual routes, you do. DeepSeek, for example, retired the model behind its legacy `deepseek-v4-flash` name and now serves that name with DeepSeek-V4.1-Flash-1017 at the Flash price, as of October 22, 2026 ([DeepSeek pricing](https://api-docs.deepseek.com/quick_start/pricing)). In AutoRouter, the AutoRouter team curates the lineup and tests every new model as it becomes available.

### What does a new model cost through AutoRouter?

On Pro, a pay-per-use model costs the provider's price plus 10%, taken from the $20 of usage included each month and then from credits you top up. AutoRouter earns the 10% on paid models. Price only decides between models that already clear the quality bar, and your plans come first; AutoRouter earns nothing on plans.

## Sources

- [AutoRouter](https://autorouter.com)
- [AutoRouter privacy](https://autorouter.com/privacy)
- [Claude Code: other LLM gateways](https://code.claude.com/docs/en/llm-gateway)
- [Claude Code: connect to an LLM gateway](https://code.claude.com/docs/en/llm-gateway-connect)
- [Claude Code: commands](https://code.claude.com/docs/en/commands)
- [DeepSeek: integrate with Claude Code](https://api-docs.deepseek.com/quick_start/agent_integrations/claude_code)
- [DeepSeek: integrate with Codex](https://api-docs.deepseek.com/quick_start/agent_integrations/codex)
- [DeepSeek: models and pricing](https://api-docs.deepseek.com/quick_start/pricing)
- [Kimi: use Kimi in Claude Code](https://platform.kimi.ai/docs/guide/claude-code-kimi)
- [Kimi: use Kimi K3 in Codex](https://platform.kimi.ai/docs/guide/codex-kimi)
- [MiniMax: Claude Code](https://platform.minimax.io/docs/m-plan/claude-code)
- [Alibaba Cloud Model Studio: Claude Code](https://www.alibabacloud.com/help/en/model-studio/claude-code)
- [Codex: advanced configuration](https://learn.chatgpt.com/docs/config-file/config-advanced)
- [Codex: configuration reference](https://learn.chatgpt.com/docs/config-file/config-reference)
- [OpenRouter: Claude Code](https://openrouter.ai/docs/cookbook/coding-agents/claude-code-integration)
- [OpenRouter: Codex CLI](https://openrouter.ai/docs/cookbook/coding-agents/codex-cli)
- [OpenRouter: Codex Desktop app](https://openrouter.ai/docs/cookbook/coding-agents/codex-desktop)
- [OpenRouter: Gemini Pro Latest](https://openrouter.ai/~google/gemini-pro-latest)
- [OpenRouter pricing](https://openrouter.ai/pricing)

## Read next

- [Every way to choose a model in Claude Code](https://autorouter.com/blog/claude-code-model-settings.md): Claude Code takes its model from, in order of priority, the /model command, the --model flag, the ANTHROPIC_MODEL environment variable, the model key in settings.json and the ANTHROPIC_DEFAULT_MODEL variable. Aliases such as opus, sonnet, haiku, fable and opusplan stand for the current model in each family, and subagents take their model from their own model field, CLAUDE_CODE_SUBAGENT_MODEL or the main session. AutoRouter, the Mac app for Codex and Claude Code, adds one more choice to /model that picks a model for each turn while it is selected.
- [Which model to use for which coding task](https://autorouter.com/blog/which-model-for-which-task.md): Use a frontier model such as Claude Opus 5.5 or GPT-6 Astra for multi-file refactors, hard bugs and UI built from a design. Use a strong model such as Claude Sonnet 5.5 or GPT-6.1 Sol for tests and code review, and a fast model such as Claude Haiku 5.5 or GPT-6 Luna for renames, commit messages and one-line shell commands. AutoRouter, the Mac app for Codex and Claude Code, makes that choice on every turn.
- [Codex model providers and config.toml, explained](https://autorouter.com/blog/codex-model-providers.md): Codex picks its model from the model key and its endpoint from the model_provider key in ~/.codex/config.toml, and each custom provider is a [model_providers.<id>] table with a base URL, an environment variable for its API key and the Responses wire API. Profiles are separate files loaded with --profile, -c overrides one key for one run, and --oss runs a local Ollama or LM Studio model. Enabling AutoRouter, the Mac app for Codex and Claude Code, adds it to config.toml after saving a copy of the file, and disabling it switches Codex back.

Tags: [Guides](https://autorouter.com/blog/tags/guides.md), [Models](https://autorouter.com/blog/tags/models.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.
