Try a new model in Codex or Claude Code without another API key
Tyler J. CagleUpdated 13 min read
To try a new model in Claude Code or Codex without another key, use Auto, the Mac app for all your coding agents: it adds models from different providers to each one's model picker with no keys or endpoints to set up, and new models show up in the picker right away. To try one 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.
Auto 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). Step-by-step guides cover each provider in both apps: DeepSeek, Kimi, GLM and MiniMax.
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). Codex model providers and config.toml, explained covers the provider keys, profiles and one-run overrides.
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. To run Claude models in Codex or GPT models in Claude Code, see How to use Claude in Codex and GPT in Claude Code. For choosing which model a task needs once it is in the picker, see How to choose and change models in Codex and Claude Code.
- 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 Auto?
You pick it in the model picker you already use. Auto adds frontier and open-weight models to every coding agent you use, 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 Auto sends them the work they do best. The pay-per-use models on Auto'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 your app's picker sends your turns straight to it; AutoRouter routes only while Auto itself is the model selected. Choose Auto 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 Auto 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 the AI subscriptions you already pay for. Pro, which includes 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 a week of Pro, or until its included usage is spent, whichever comes first; after that, Pro is paid (see pricing).
The limits: Auto runs on macOS 14 or later, works with all your coding agents (Claude Code, Codex, Cursor, etc.), and is in beta; Claude Code needs Node 22.18 or later. Requests pass through Auto's servers on their way to each provider. Auto 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 (Auto 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). - Auto: pick another model in the picker, or disable an app in Auto's settings to switch that app back. Enabling saved a copy of Codex's
config.tomland Claude Code'ssettings.jsonbefore adding Auto, and left your other settings as they were.
Which model-switching tools work on a Mac for coding agents?
Auto, Ollama and a gateway such as OpenRouter all switch models inside coding agents on a Mac, and they differ in where the model runs. Auto, the Mac app for all your coding agents, adds hosted models from different providers to each agent's picker with no keys (macOS 14 or later), while Ollama runs open-weight models on your own Mac, or on its cloud, behind Claude Code and Codex. Apple's WWDC26 session shows a third local route, the MLX-LM server, which any agent that speaks the OpenAI chat completions protocol can use (Apple). As of November 23, 2026:
| Tool | Where the model runs | Agents it works with | Mac setup | Key and cost | Fits when |
|---|---|---|---|---|---|
| Auto | Hosted providers, through Auto's servers | Claude Code, Codex, Cursor, etc. (supported apps) | Install, sign in, click Enable for each app | No key. Free plan $0 a month; Pro with usage included each month, paid models at the provider's price plus 10% | You want hosted models from different providers in the picker, with a model chosen for each task |
| Ollama, local models | Your Mac | Claude Code and Codex | Install Ollama and the agent, then run ollama launch claude or ollama launch codex | No provider key and no usage charge; your Mac does the work | Code must stay on your machine, you work offline, or you want no per-token bill |
| Ollama, cloud models | ollama.com | Claude Code and Codex | Choose a :cloud model in ollama launch, or set OLLAMA_API_KEY for a direct connection | An Ollama key; billed by Ollama, see its site for current prices | You want a larger open model without downloading it |
| MLX-LM server (Apple) | Your Mac | OpenCode, Xcode, Pi, or any OpenAI-compatible agent | pip install mlx-lm, run mlx_lm.server --model <model>, and point the agent at http://127.0.0.1:8080/v1 | No key and no usage cost | You want Apple's open-source stack with no extra app |
When do local models fit better than hosted ones?
Local models fit when code must stay on your Mac, when you work offline, or when you want no per-token bill. Apple's WWDC26 session says a local agent loop has "no usage costs" and that only commands that need the network, such as git, reach it (Apple).
Two limits matter. First, context: Ollama's docs say to use a context window of at least 64k tokens for Codex and 64k or higher for larger repositories in Claude Code, and to pick a model that supports tool calling (Ollama: Codex, Ollama: Claude Code). Second, memory: Ollama's docs give no RAM guidance for Macs, and Apple's session says the latest DeepSeek model, at 1.6 trillion parameters, needs more than 800GB of memory for its weights alone, while its own demo runs a 4B-parameter Qwen 3.5 model. Apple also says the M5's Neural Accelerators make prompt processing about four times faster than the M4, which matters because agent sessions read hundreds of thousands of tokens and generate few (Apple).
How is that different from Auto's model picker?
Auto's picker lists hosted models, and when you choose Auto it picks one for each prompt. Requests pass through Auto's servers on their way to each provider, so Auto fits when you want hosted frontier and open-weight models with no setup, and Ollama fits when code must not leave the machine. With Ollama you pick the model yourself: in Codex, /model switches between your installed, tool-capable Ollama models without restarting (Ollama: Codex), and in Claude Code you run claude --model qwen3.5 (Ollama: Claude Code).
If a plan limit is why you are switching, a hosted fallback is the shorter fix; How Claude Code usage limits work explains those limits. Ollama's Claude Code setup points ANTHROPIC_BASE_URL at http://localhost:11434, the same mechanism as the manual routes above, so remove those variables as described under switching back before you return to Auto or your usual models. For hosted open-weight models, see GLM in Claude Code and Codex; for other Mac switchers and gateways, see Magpie alternatives and OpenRouter alternatives.
Which route should you use?
Use Auto for models in the picker with no keys, on a Mac; a provider's own endpoint to try one model with nothing in between; a gateway for many models on one key and one bill; or Ollama to run a model on your own Mac. As of October 22, 2026, except the Ollama row, which is as of November 23, 2026:
| Route | Setup | Key needed | Switching back | Cost |
|---|---|---|---|---|
| Auto (Mac) | Install, sign in, click Enable for each app | None | Pick another model, or disable the app in Auto's settings | Free across your AI subscriptions; other models on Pro at the provider's price plus 10% |
| 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) |
| Ollama (local or cloud models) | ollama launch claude or ollama launch codex | None for local models; an Ollama key for cloud models | Remove the Ollama variables or profile, restart; ollama launch codex --restore removes its Codex profile | Local: no usage charge. Cloud: billed by Ollama |
Questions
Can I use Gemini in Claude Code or Codex?
Yes, through a gateway such as OpenRouter or through Auto. 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 Auto, Gemini 4 Argon is one of the pay-per-use models on Pro as of October 22, 2026. How to use Gemini in Claude Code and Codex walks through the LiteLLM and OpenRouter setups.
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 Auto, the Auto team curates the lineup and tests every new model as it becomes available.
What does a new model cost through Auto?
On Pro, a pay-per-use model costs the provider's price plus 10%, taken from the usage included each month and then from credits you top up. Auto earns the 10% on paid models. Price only decides between models that already clear the quality bar, and your plans come first; Auto earns nothing on plans.
Can I run Claude Code or Codex on local models on a Mac?
Yes, through Ollama. Install Ollama and the agent, then run ollama launch claude or ollama launch codex and choose a model; set the context window to 64k tokens or more (Ollama: Claude Code, Ollama: Codex). For Claude Code you can also set ANTHROPIC_AUTH_TOKEN to ollama, ANTHROPIC_API_KEY to an empty string and ANTHROPIC_BASE_URL to http://localhost:11434, then run claude --model qwen3.5. For Codex, codex --oss -m gpt-oss:120b selects a specific local model.
Sources
- Auto
- Auto 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
- Ollama: Claude Code
- Ollama: Codex CLI
- Apple: Run local agentic AI on the Mac using MLX (WWDC26)