Try a new model in Codex or Claude Code without another API key
AutoRouter8 min read
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, 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). DeepSeek, Kimi, MiniMax and Alibaba Cloud Model Studio 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:
- Create an API key on the DeepSeek Platform.
- Run the exports below in your terminal (macOS and Linux), or add them to your shell profile to keep them.
- Start
claudein your project from that same terminal. - Run
/status: theAnthropic base URLline should show the provider's address (Anthropic docs).
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).
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). The provider has to speak OpenAI's Responses API, since responses is the only wire_api value Codex supports (OpenAI config reference). Kimi and DeepSeek both say theirs does (Kimi docs, DeepSeek docs).
With Kimi K3, following Kimi's Codex guide:
- Create an API key on the Kimi platform.
- Load the key into your shell without writing it to your history, using the first block below.
- Add the second block to
~/.codex/config.toml, replacing any existingmodelandmodel_providervalues. - Restart Codex, which reads
config.tomlonly at startup. In the Codex app, choosekimi-k3in the model picker (it may show as Custom); in the CLI, runcodexin your project.
echo "Paste your Kimi API key and press Enter (input is hidden):"
read -s KIMI_API_KEY
export KIMI_API_KEY
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 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). Model routers for Claude Code and Codex, compared compares OpenRouter with routers that also choose the model for each turn.
- Claude Code: OpenRouter's guide sets
ANTHROPIC_BASE_URLtohttps://openrouter.ai/api, puts the OpenRouter key inANTHROPIC_AUTH_TOKEN, setsANTHROPIC_API_KEYto an empty string, and has you run/logoutonce if you were signed in to Anthropic. SettingCLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1adds a curated list of OpenRouter models to/model(OpenRouter docs). - Codex: add the provider block below to
~/.codex/config.toml, exportOPENROUTER_API_KEYfrom your shell profile, and changemodelto any OpenRouter model slug (OpenRouter docs).
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 explains. Every turn shows its model, what it cost and why.
- Download AutoRouter for macOS from autorouter.com.
- Open it, sign in or create a free account, sign in to your plans, allow Accessibility, and click Enable for each app.
- 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).
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
envblock in~/.claude/settings.json. With no gateway credential set, Claude Code goes back to your saved claude.ai login (Anthropic docs). If you ran/logoutfor OpenRouter, sign in again with/login(Anthropic docs). - Codex: delete the top-level lines you added, such as
model,model_providerandmodel_context_window, or restore your earlier values. Withoutmodel_provider, Codex uses its built-inopenaiprovider (OpenAI 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.tomland Claude Code'ssettings.jsonbefore 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; in Claude Code, OpenRouter's guide pins a model through the model override variables (OpenRouter docs). 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). How Claude Code usage limits work 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).
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). 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
- AutoRouter privacy
- Claude Code: other LLM gateways
- Claude Code: connect to an LLM gateway
- Claude Code: commands
- DeepSeek: integrate with Claude Code
- DeepSeek: integrate with Codex
- DeepSeek: models and pricing
- Kimi: use Kimi in Claude Code
- Kimi: use Kimi K3 in Codex
- MiniMax: Claude Code
- Alibaba Cloud Model Studio: Claude Code
- Codex: advanced configuration
- Codex: configuration reference
- OpenRouter: Claude Code
- OpenRouter: Codex CLI
- OpenRouter: Codex Desktop app
- OpenRouter: Gemini Pro Latest
- OpenRouter pricing