Claude Code and Codex on the same model

2026-09-27

Two coding apps can be open and still talk to two different brains. A coding agent (the app that reads files and runs commands) is not the model (the program that writes the next words). Claude Code is one agent. Codex is another.

Claude Code and Codex can use the same model only when each app is pointed at a server that speaks its own request shape, including the helper slots, not just the main model name.

I set three keys. Six jobs still called the old server.

Why one model name does not move both apps

Mind map: Claude Code and Codex on the same model

You changed a model name and expected both apps to follow. They will not. Each app keeps its own file on your machine.

Claude Code reads ~/.claude/settings.json. Codex reads ~/.codex/config.toml. A base URL (the server address the app calls) written in one file is invisible to the other.

That is why “Claude Code and Codex on the same model” fails for people who only edit one line. The apps are not a shared setting. They are two programs with two config files.

Claude Code reads settings.json; Codex reads config.toml — two files, two brains.
Claude Code reads settings.json; Codex reads config.toml — two files, two brains.

If you only live in Claude Code, you can ignore Codex for now. If you bounce between them, you need both files to name the same brain, and each file has to speak that brain’s language.

The loop under either app is the same idea as the learn-claude-code teardown: tools, a chat, a model call. The model call is the part this page is about.

The two languages the apps already speak

An API (a web address that takes a request and returns text) is not one shape. Claude Code speaks Anthropic Messages (a request with system, messages, and tools that describe their inputs as input_schema). Codex speaks OpenAI Responses (a request with input, and tools that describe their inputs as parameters).

I built both bodies for the same sentence: “Read README.md and say if the clamp bug is min/max swapped.”

The Messages body was 378 bytes. It had system, messages, max_tokens, and tools[0].input_schema.

The Responses body was 360 bytes. It had input, and tools[0].parameters. It had no system field and no max_tokens.

Same job. Different keys. A server that only understands one column rejects the other app. The error looks like a broken tool. It is a shape mismatch.

Messages uses input_schema; Responses uses parameters — same job, different JSON keys.
Messages uses input_schema; Responses uses parameters — same job, different JSON keys.

A gateway (a small program on your computer that rewrites one request shape into the other) is how one local address can serve both apps. I renamed input_schema to parameters in that test. The required field path survived. That rename is the whole idea of a translator. A real gateway also has to move streams, tool results, and thinking blocks. The rename is the part you can see in one minute.

If the vendor already speaks Messages, Claude Code can call it directly. Codex still cannot, unless that vendor also speaks Responses, or something in the middle translates.

The nine slots that still call the old server

A slot (a named bucket the app fills with a model) is why one ANTHROPIC_MODEL line is not enough. Claude Code does not use one model. It uses a main model, four tiers, a fast model, and a helper model.

The tiers are opus, sonnet, haiku, and fable. You meet them as /model opus, or as a subagent (a helper the main app starts for a side job) that asks for model: haiku.

I audited a file that only set three keys.

  • ANTHROPIC_BASE_URL
  • ANTHROPIC_AUTH_TOKEN (the secret that proves you may call that server)
  • ANTHROPIC_MODEL

Result: 3 of 9 set. These six were empty, so those jobs still use the app’s default server:

  • ANTHROPIC_DEFAULT_OPUS_MODEL
  • ANTHROPIC_DEFAULT_SONNET_MODEL
  • ANTHROPIC_DEFAULT_HAIKU_MODEL
  • ANTHROPIC_DEFAULT_FABLE_MODEL
  • ANTHROPIC_SMALL_FAST_MODEL (the cheap fast bucket, usually the same pick as haiku)
  • CLAUDE_CODE_SUBAGENT_MODEL

Nine Claude Code model slots: three set, six empty still calling the old server.
Nine Claude Code model slots: three set, six empty still calling the old server.

There is a second trap in the model string. A token (a small chunk of text you pay to send or receive) adds up. A long window (how much text the model can hold at once) is often marked [1m], meaning about a million tokens. Claude Code treats a name without [1m] as a short window, about 200 thousand tokens, and starts compacting (squeezing old chat so it fits) earlier than the model needs.

On the direct DeepSeek path, the long slots use deepseek-flash[1m]. The haiku slot and the subagent slot in the vendor’s own example use deepseek-flash with no mark. On the direct Kimi path, the long slots use kimi-k3[1m]. The haiku slot uses kimi-k2.7-code. Copy the names. Do not invent a prettier one.

Two more lines belong on the direct path, next to the nine:

  • CLAUDE_CODE_EFFORT_LEVEL (how hard the model tries: low, medium, high, xhigh; max lasts one session)
  • CLAUDE_CODE_AUTO_COMPACT_WINDOW (how big the chat may get before the app squeezes it)

DeepSeek’s Claude Code page pairs the flash model with a compact window of 786432. Kimi’s page uses 1000000 next to kimi-k3[1m]. If you set [1m] and leave the compact window tiny, you paid for a long memory and then threw it away.

One more rule, from the writer that fills these slots when every tier matches the main model: it also sets CLAUDE_CODE_SUBAGENT_MODEL to that same model. If the tiers differ, it deletes CLAUDE_CODE_SUBAGENT_MODEL. One helper model would override the tier the helper asked for. If you want haiku jobs on a cheap model and opus jobs on a strong one, do not pin the subagent line.

I pointed both apps at one local address

The useful layout is a gateway on 127.0.0.1:3425. That address exists only on your machine. It is not a website you open from another computer.

Claude Code’s env block then looks like this. The token here is the gateway’s own token, not the vendor key. The model id uses provider/model, which is the catalog form, not the bare vendor id.

# ~/.claude/settings.json -> env
ANTHROPIC_BASE_URL=http://127.0.0.1:3425
ANTHROPIC_AUTH_TOKEN=<gateway token>
ANTHROPIC_MODEL=deepseek/deepseek-flash[1m]
ANTHROPIC_DEFAULT_OPUS_MODEL=deepseek/deepseek-flash[1m]
ANTHROPIC_DEFAULT_SONNET_MODEL=deepseek/deepseek-flash[1m]
ANTHROPIC_DEFAULT_HAIKU_MODEL=deepseek/deepseek-flash
ANTHROPIC_DEFAULT_FABLE_MODEL=deepseek/deepseek-flash[1m]
ANTHROPIC_SMALL_FAST_MODEL=deepseek/deepseek-flash
CLAUDE_CODE_SUBAGENT_MODEL=deepseek/deepseek-flash[1m]
Both apps call 127.0.0.1:3425; the gateway translates Messages and Responses to one model.
Both apps call 127.0.0.1:3425; the gateway translates Messages and Responses to one model.

Codex does not read that file. If Codex is already signed in, the small change is openai_base_url aimed at the gateway. Its own OpenAI models can still pass through. Other models get translated. The model list is built when Codex starts, so a window that is already open will not see the new names. Restart it.

If Codex is not signed in, it needs its own provider table: model_provider set to the gateway, wire_api set to responses, and a base URL that ends in /v1. A model name with none of those keys still calls OpenAI. I checked a half-config that only had model. It had no openai_base_url. That is not a route.

Direct path, no gateway, Claude Code only. This does not move Codex.

# DeepSeek, Messages-shaped door
ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
ANTHROPIC_AUTH_TOKEN=<your DeepSeek key>
ANTHROPIC_MODEL=deepseek-flash[1m]
ANTHROPIC_DEFAULT_OPUS_MODEL=deepseek-flash[1m]
ANTHROPIC_DEFAULT_SONNET_MODEL=deepseek-flash[1m]
ANTHROPIC_DEFAULT_HAIKU_MODEL=deepseek-flash
CLAUDE_CODE_SUBAGENT_MODEL=deepseek-flash
CLAUDE_CODE_EFFORT_LEVEL=max
CLAUDE_CODE_AUTO_COMPACT_WINDOW=786432
# Kimi platform key, a different door
ANTHROPIC_BASE_URL=https://api.moonshot.ai/anthropic
ANTHROPIC_AUTH_TOKEN=<your Moonshot key>
ANTHROPIC_MODEL=kimi-k3[1m]
ANTHROPIC_DEFAULT_OPUS_MODEL=kimi-k3[1m]
ANTHROPIC_DEFAULT_SONNET_MODEL=kimi-k3[1m]
ANTHROPIC_DEFAULT_HAIKU_MODEL=kimi-k2.7-code
ANTHROPIC_DEFAULT_FABLE_MODEL=kimi-k3[1m]
CLAUDE_CODE_SUBAGENT_MODEL=kimi-k3[1m]
CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000
CLAUDE_CODE_EFFORT_LEVEL=max

Match the key to the door. A platform key goes to api.moonshot.ai/anthropic. A Kimi Code membership key goes to the coding host, api.kimi.com/coding. The wrong pair comes back as not allowed. Do not “fix” that by pasting the key into a second variable and hoping.

Official pages, if you want the current ids rather than my copy: DeepSeek’s Claude Code page and Kimi’s Claude Code page. Model ids move. The slot names do not.

When one menu helps, and when you should skip it

Magpie (a menu-bar app that writes these files and runs the local gateway) is the open source tool that does the click. Repo: yetone/magpie. One small binary. It edits one key at a time, so comments in the file can survive. I did not install the desktop build in this test. I read the writer that fills Claude Code’s nine keys, and I ran the slot audit against that list.

Use the menu when you have two or more agents and you are tired of keeping two files in sync. Profiles (a saved set of every agent’s model picks) let you flip the whole desk in one move: cheap models for the afternoon, strong models for the hard bug.

Skip it when you only use Claude Code and the vendor already speaks Messages. Set the nine keys by hand. You do not need a translator for one language.

Skip it when an admin file already sets ANTHROPIC_BASE_URL. On Linux that file is /etc/claude-code/managed-settings.json. On a Mac it is /Library/Application Support/ClaudeCode/managed-settings.json. On Windows it is C:\ProgramData\ClaudeCode\managed-settings.json. I simulated that case. The user file was complete, 9 of 9. The managed base still wins. /status will show the admin host, and your edit will look like it did nothing.

Also skip a menu if your real problem is the house rules, not the model. A dirty CLAUDE.md makes every model over-edit. Changing the brain does not fix a bad briefing. If you are about to test a new model inside an old file, run the Opus 5.5 prompt audit on that file first.

And do not confuse this with swapping the harness (the loop, permissions, and session around the model). That is a different job. The MiniMax Code CLI test is the page for “should I leave Claude Code.” This page is “keep the app, point it at one brain, and point Codex there too.”

Can I use my Claude login inside Codex?

No. Not by copying the token.

Anthropic checks the request, not only the key. A prompt written by another agent can be treated as extra usage even when the login is yours. Pasting a Claude session into Codex is how you get a surprise bill, or a refusal, or both.

The safe path, if you insist on the Claude subscription, is to start the real claude program and bridge the caller’s tools back into that live turn. That needs Claude Code installed and signed in. It is slower and stranger than a normal API key. The prompt cache (the cheap reread of text the server already saw) can stay warm because the same process continues. A fresh replay of the whole chat would not.

Do not paste a Claude login into Codex; use a vendor key or bridge the real claude process.
Do not paste a Claude login into Codex; use a vendor key or bridge the real claude process.

For DeepSeek or Kimi, use a key you created for that vendor. Do not paste a Claude login into Codex and hope.

Google sign-ins have a separate limit. An account used outside the app it belongs to can be suspended. Do not route a login you cannot afford to lose.

Try this before you change a real project

Eight minutes. No spend. Work on a copy.

  1. Copy ~/.claude/settings.json and, if you use Codex, ~/.codex/config.toml. Do not edit the live files first.
  2. Count the nine Claude Code slots. A missing slot still calls the old server.
  3. Open the Codex file. A model line with no openai_base_url and no model_provider is not a route.
  4. Put [1m] only on long slots when that model actually has a long window. Leave the fast slot short on purpose if you want cheap side jobs.
  5. Set CLAUDE_CODE_AUTO_COMPACT_WINDOW on the direct path so the long window is allowed to exist.
  6. Restart Codex. It builds the model list at startup.
  7. In Claude Code, run /status. The base on screen must match the file. If it does not, check the managed settings file.
  8. Ask both apps to read one file and name one bug. If one app errors on tools, you sent the wrong request shape. That is a gateway problem, not a prompt problem.

Eight-minute checklist: copy configs, count nine slots, fix Codex route, restart, run /status.
Eight-minute checklist: copy configs, count nine slots, fix Codex route, restart, run /status.

I did steps 2 through 4 on a throwaway file. The half-config scored 3 of 9. The full local block scored 9 of 9. The shape test showed input_schema on one side and parameters on the other. I did not send a paid request. Do not send one until /status matches the file.

If you try only one thing, count the slots. A single model name is how the bill stays on the old server while you think you switched.

If you liked this, also read

The learn-claude-code teardown if you want the loop under either app. The CLAUDE.md writeup if the briefing is still a manifesto. The Opus 5.5 prompt audit before you judge a new model. The MiniMax Code CLI test if you were about to swap the app instead of the model.

Questions people actually ask

Can I point Claude Code and Codex at the same DeepSeek model?

Yes, if each app is aimed at a server that speaks its shape. Claude Code can call DeepSeek’s Messages door directly with the nine slots filled. Codex needs a Responses door, or a local gateway that translates. A model name in only one file does not count.

Why does Claude Code still call Anthropic after I change the model?

Usually a missing slot, or a managed settings file that overrides yours. Check opus, sonnet, haiku, fable, the small fast model, and the subagent model. Then run /status. If the base on screen is not the base in your user file, the admin file won.

Can I use my Claude login inside Codex?

Not by copying it. The check looks at the request content. Use a vendor key you created, or a tool that starts the real claude program and bridges tools into that process. That second path needs Claude Code installed and signed in.

Is a local gateway worth it if I only use Claude Code?

No. If the vendor already speaks Messages, write the env block by hand and stop. A gateway earns its place when a second app speaks a different shape, or when you want one menu for every agent on the machine.

JOIN OUR NEWSLETTER
Be the first to know. Get fresh AI/Tech updates instantly, no spam, unsubscribe anytime

2 comments

Leave a comment