I tried to put DeepSeek inside the Codex app without losing ChatGPT Voice
On 21 and 22 November 2026 I spent a day trying to use a self-hosted LiteLLM gateway from inside the ChatGPT/Codex macOS app. The gateway serves DeepSeek v4.1 Flash and a number of OpenAI models. I wanted to keep the normal ChatGPT view, keep the Voice button, and add DeepSeek to the model picker. The app build was 26.1117.41037, the bundled Codex CLI was 0.166.0, and the app server was 0.171.0.
The short version: the model picker accepted DeepSeek, the chat backend did not. The chat was executing in a Codex Cloud environment that used OpenAI, and Voice is tied to the OpenAI provider. A local config entry could not bridge those two backends. The rest of this note is the evidence, including the configs, the patches, and the log lines.
The app is two products
The first thing I had to accept is that the app is not one chat product with a pluggable model list. It contains a ChatGPT surface and a Codex surface.
The ChatGPT surface has the normal chat layout, the server-driven model list, and Voice. The Codex surface has projects, a local agent, custom model providers, and tools. It does not have Voice. The two surfaces share an Electron shell and a settings file, which makes them look like one product. The backend is different.
The gateway had to speak Responses
Codex 0.166.0 no longer accepts Chat Completions as a provider protocol. The first config I tried used wire_api = "chat", the natural choice for a LiteLLM gateway with chat models. Codex refused to start:
Error: failed to load bootstrap configuration
Caused by:
`wire_api = "chat"` is no longer supported.
How to fix: set `wire_api = "responses"` in your provider config.
More info: https://github.com/openai/codex/discussions/7782
in `model_providers.litellm.wire_api`
I switched to wire_api = "responses" and tested the gateway directly. A chat-style model and a Responses-only model both returned 200:
curl -sS "https://your-gateway.example/v1/responses" \
-H "Authorization: Bearer $LITELLM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4.1-flash-openrouter",
"input": "Reply with exactly: OK",
"max_output_tokens": 16
}'
The gateway handled the translation. The app still did not use it for the chat.
Attempt 1: a provider and a catalog
I added a provider block and a model catalog to ~/.codex/config.toml, and left the global provider on OpenAI.
model = "gpt-6.2-sol"
model_provider = "openai"
model_catalog_json = "~/.codex/litellm-catalog.json"
[model_providers.litellm]
name = "LiteLLM"
base_url = "https://your-gateway.example/v1"
wire_api = "responses"
experimental_bearer_token = "..."
I generated the catalog from the gateway instead of writing it by hand. The gateway serves a Codex-format catalog when the request includes client_version. Without that query, it returns an OpenAI-style list. The two responses have different schemas, and the Codex one is what the app reads:
import json, os, urllib.request
base = "https://your-gateway.example/v1"
key = os.environ["LITELLM_API_KEY"]
version = "0.166.0"
req = urllib.request.Request(
f"{base}/models?client_version={version}",
headers={
"Authorization": f"Bearer {key}",
"originator": "codex_cli_rs",
"user-agent": "codex_cli_rs/0.166.0",
},
)
catalog = json.load(urllib.request.urlopen(req))["models"]
The Codex catalog had 36 chat models. The proxy's /v1/models endpoint had 106 entries, including audio and image models. The nine Responses-only models, including gpt-5.3-codex and the Pro models, were missing from the Codex catalog. I added them from /model/info, using a minimal entry template and the capability fields:
{
"slug": "gpt-5.3-codex",
"display_name": "gpt-5.3-codex",
"supported_reasoning_levels": [
{"effort": "low", "description": "Fast responses with lighter reasoning"},
{"effort": "medium", "description": "Balances speed and reasoning depth"},
{"effort": "high", "description": "Greater reasoning depth"}
],
"context_window": 272000,
"use_responses_lite": false,
"supports_search_tool": false,
"apply_patch_tool_type": "freeform"
}
Then I merged the bundled OpenAI models so they would not disappear from the picker. The final file had the bundled models, the 36 from the gateway catalog, and the nine I added by hand. The picker showed all of them. DeepSeek was listed. The app stayed on the normal ChatGPT view, and Voice was present.
Selecting DeepSeek and sending a message produced This model isn't available with a Choose another model button. The app-server log showed the split between the model and the provider:
model=deepseek-v4.1-flash-openrouter codex.turn.reasoning_effort=low
provider=OpenAI wire_api=responses transport="responses_websocket"
The catalog changed the picker. The conversation stayed on the ChatGPT backend.
Attempt 2: make LiteLLM the default
Next I set the global provider to LiteLLM and the model to DeepSeek.
model = "deepseek-v4.1-flash-openrouter"
model_provider = "litellm"
model_catalog_json = "~/.codex/litellm-catalog.json"
DeepSeek worked in the Codex work surface and in the CLI. The app lost the ChatGPT view and the Voice button. The app-server session log showed the provider it had loaded:
Configuring session: model=deepseek-v4.1-flash-openrouter;
provider=ConfiguredModelProvider {
info: ModelProviderInfo {
name: "LiteLLM",
base_url: Some("https://your-gateway.example/v1"),
wire_api: Responses,
requires_openai_auth: false,
...
}
}
The provider is global per app instance. A non-OpenAI provider puts the app into the custom/Codex mode, and Voice is gated on the OpenAI provider, not only on the account.
I also found the surface mode. The app persists home-composer-mode-v1 in ~/.codex/.codex-global-state.json:
{
"electron-owner-atoms:...": {
"home-composer-mode-v1": "chat"
}
}
Setting it to chat restored the ChatGPT layout, but the provider change still removed Voice. Mode and provider are separate gates, and both have to favor OpenAI.
Attempt 3: keep OpenAI global and show DeepSeek in the picker
I tried to keep OpenAI global and limit the catalog to DeepSeek plus the bundled models. The picker showed both. The chat still failed with modelNotFound. The app created the thread with a default model and the OpenAI provider, then the composer changed the turn model to DeepSeek.
The app-server supports a per-thread modelProvider. The thread/start schema includes it, and turn/start accepts the model for the turn:
{"id": 2, "method": "thread/start", "params": {
"modelProvider": "litellm",
"model": "deepseek-v4.1-flash-openrouter",
"cwd": "/tmp",
"approvalPolicy": "never",
"sandbox": "read-only"
}}
{"id": 3, "method": "turn/start", "params": {
"threadId": "thread-id",
"model": "deepseek-v4.1-flash-openrouter",
"input": [{"type": "text", "text": "Reply with OK"}]
}}
A standalone app-server accepted that pair while the global config stayed on OpenAI. The turn returned OK. The capability exists. The chat UI did not send modelProvider when I selected DeepSeek. It sent gpt-6-luna and openai. The backend then produced modelNotFound.
Attempt 4: patch the app
I extracted app.asar and added overrides at three points.
First, the client method that starts a thread. Both the renderer and the main process had a startThread wrapper. I forced the provider there:
startThread(e, t) {
if (e && typeof e === "object") {
e = { ...e, modelProvider: "litellm" };
console.warn("ZPM_START", e.model, "litellm");
}
await this.ensureReady();
// ...
}
Second, the turn path. Before a DeepSeek turn, send a thread settings update:
if (e && typeof e.model === "string" && e.threadId &&
e.model.includes("deepseek")) {
await r({
id: `thread/settings/update:${crypto.randomUUID()}`,
method: "thread/settings/update",
params: {
threadId: e.threadId,
model: e.model,
modelProvider: "litellm",
},
});
}
Third, the stdio transport. The app writes newline-delimited JSON to the app-server. I wrapped the write:
function ZPM_WIRE(e) {
const msg = JSON.parse(e);
if (msg.method === "turn/start" &&
msg.params?.model?.includes("deepseek")) {
return JSON.stringify({
jsonrpc: "2.0",
id: "thread/settings/update:" + crypto.randomUUID(),
method: "thread/settings/update",
params: {
threadId: msg.params.threadId,
model: msg.params.model,
modelProvider: "litellm",
},
}) + "\n" + e + "\n";
}
return e + "\n";
}
this.proc.stdin.write(ZPM_WIRE(e));
The markers proved the code loaded. ZPM_PATCH_LOADED appeared. ZPM_START showed thread creation with modelProvider: "litellm". The live turn still used OpenAI. The stdio wrapper never logged a DeepSeek turn. The chat was using a different transport.
To load the patched bundle I had to deal with the signature. The archive has an integrity hash in Info.plist, and Electron validates it. The hash covers the asar JSON header, not the whole file:
import hashlib, plistlib, struct
from pathlib import Path
asar = Path("/Applications/ChatGPT.app/Contents/Resources/app.asar")
blob = asar.read_bytes()
sizes = struct.unpack("<IIII", blob[:16])
json_len = sizes[3]
header = blob[16:16 + json_len]
hash_hex = hashlib.sha256(header).hexdigest()
plist_path = Path("/Applications/ChatGPT.app/Contents/Info.plist")
raw = plist_path.read_bytes()
fmt = plistlib.FMT_BINARY if raw.startswith(b"bplist") else plistlib.FMT_XML
info = plistlib.loads(raw)
info["ElectronAsarIntegrity"]["Resources/app.asar"]["hash"] = hash_hex
plist_path.write_bytes(plistlib.dumps(info, fmt=fmt))
A plain repack still failed the integrity check, so I disabled the fuse and signed the app ad hoc:
npx @electron/fuses write --app /Applications/ChatGPT.app \
EnableEmbeddedAsarIntegrityValidation=off
codesign --force --deep --sign - --options runtime \
--entitlements /tmp/entitlements.plist \
/Applications/ChatGPT.app
The entitlements needed com.apple.security.cs.disable-library-validation, because the nested framework is signed by OpenAI and the outer app was now ad hoc. Without it, dyld refused to load the framework. With it, the app launched, but Gatekeeper rejected the normal launch:
spctl --assess --type execute /Applications/ChatGPT.app
# rejected
The only way to run it was the raw binary:
/Applications/ChatGPT.app/Contents/MacOS/ChatGPT
That is not a patch I would keep. Every app update replaces the bundle.
The cloud environment
The decisive line was in the process list:
ps -o pid,ppid,command -p 32963
# .../codex -c forced_login_method=chatgpt exec-server \
# --remote https://codex-cloud-environments.chatgpt.com/api \
# --environment-id ccarenv_...
The chat thread was executing in a Codex Cloud environment. The local app-server was a different connection. The cloud process used OpenAI. The local model_providers and the patches had no effect on it. The This computer location and a local project did not reliably change that in my tests.
The app-server log confirmed the same thread used OpenAI:
rpc.method="thread/start" rpc.transport="stdio"
app_server.client_name="Codex Desktop"
model=deepseek-v4.1-flash-openrouter
provider=OpenAI
The request reached a stdio app-server. It was the cloud exec-server. The local app-server I patched was a different connection.
Attempt 5: a project-level config
I tried a project-level .codex/config.toml in the local project:
model = "deepseek-v4.1-flash-openrouter"
model_provider = "litellm"
The thread still started with gpt-6-luna and provider=OpenAI. The app's explicit thread parameters took precedence over the project layer. A project config is not a per-chat provider switch.
Attempt 6: a local router
I tried a local router. The idea was to keep the global provider on OpenAI, point chatgpt_base_url at a local HTTP router, and route DeepSeek requests to LiteLLM while everything else went to ChatGPT:
chatgpt_base_url = "http://127.0.0.1:18790/backend-api/"
The app accepted the URL for some endpoints. The workspace routing layer rejected it:
workspace backend must use an HTTPS origin without credentials
The model request never reached the router. A working version would need a trusted local certificate, a rewrite of the workspace routing response, and WebSocket handling for Voice. The complexity and update fragility were not worth it for one model.
Why it failed
Five constraints explain the result.
- Two backends. The ChatGPT surface speaks the ChatGPT conversation API and uses a server-driven model list. The Codex surface speaks the app-server protocol and supports custom providers. Voice belongs to the ChatGPT surface. A custom provider lives on the Codex side.
- The provider is global per app instance. A non-OpenAI provider selects the custom mode and removes the ChatGPT surface and Voice. The mode is not a per-chat setting.
- The thread provider is fixed at creation. The composer changes the turn model. The backend rejects a model that does not belong to the thread's provider. The app server can accept a per-thread
modelProvider, but the UI did not send it for the selected model. - The chat ran in a Codex Cloud environment. The cloud exec-server used OpenAI and ignored local config and patches. The location selector and local project did not change that in my tests.
- The app is signed and uses asar integrity. Renderer patches require re-signing, Gatekeeper bypasses, and a direct binary launch. They do not reach the cloud execution path anyway.
What works
Three setups worked.
- Codex CLI or the Codex work surface with LiteLLM as the provider. DeepSeek runs, projects work, and ChatGPT Voice is absent.
- Two app instances. The main ChatGPT app keeps OpenAI and Voice. A second instance uses a separate
CODEX_HOMEand user data directory, with LiteLLM and DeepSeek. The second window is the Codex surface, so the layout differs and Voice is absent. - ZCode or the CLI for DeepSeek, and the ChatGPT app for Voice. This is the least integrated option and the most reliable.
What would make it work
Native per-thread provider routing in the ChatGPT surface. The app server already supports a modelProvider per thread. The chat UI would need to send the provider that matches the selected model, and the ChatGPT surface would need to allow a LiteLLM thread without dropping Voice. A gateway that speaks the ChatGPT conversation protocol could also sit behind the ChatGPT backend. That is a larger project than a config entry.
What I would not repeat
- Do not patch a signed Electron app for this. The cloud path ignores it, and the signing work creates a fragile install.
- Do not treat the model picker as proof. The catalog only changes the list.
- Do not trust the UI for the provider. Read the app-server log. The model and provider fields tell you which backend handled the turn.
I kept the config that works: OpenAI in the ChatGPT app, LiteLLM for the Codex CLI and a second window. The one-window setup with DeepSeek and Voice is not possible in this build. If that changes, this note will get an update.