Use DeepSeek, GLM, and Qwen with Codex
Install OpenCodex to connect Codex to Chinese models and any OpenAI SDK-compatible API
OpenCodex is a local proxy. It translates Codex requests into the formats supported by DeepSeek, GLM, Qwen, and other OpenAI SDK-compatible APIs.
OpenAI SDK compatibility is not enough
A model must support streaming and tool/function calling for the Codex agent workflow to work fully. A chat-only endpoint may return text but cannot use the terminal, browser, or other tools. Choose a coding/agent model and complete the Test step below.
Check the prerequisites
You need Node.js 18 or later and Codex CLI:
node --version
codex --versionIf Codex CLI is not installed:
npm install -g @openai/codexInstall OpenCodex
npm install -g @bitkyc08/opencodex
ocx --versionOpenCodex bundles the Bun runtime, so you do not need to install Bun separately.
Start the proxy
ocx startThe dashboard runs at http://localhost:10100. If it does not open:
ocx guiOpenCodex must keep running
Codex sends requests through this local proxy. Closing the terminal running ocx start causes a
connection error. To start the proxy in the background when you sign in, run
ocx service install.
Add a provider and API key
In the dashboard, open Providers → Add provider:
- For DeepSeek, Z.AI/GLM, or Qwen, select the built-in preset. OpenCodex fills in the endpoint and adapter.
- Paste the API key issued by the provider.
- Select the default model, then click Test and Save.
For another OpenAI SDK-compatible service, select Custom and enter:
| Field | Value |
|---|---|
| Name | A short name, such as my-provider |
| Adapter | OpenAI Chat Completions (openai-chat) |
| Base URL | The service endpoint, usually ending in /v1 |
| API key | The service API key |
| Default model | The exact model ID published by the API |
Use a preset when one exists; use Custom only for providers not listed.
Sync models into Codex
On the Models page, enable the models you want to use. Then run:
ocx sync --restart-codexThis updates the model catalog and restarts Codex so the new models appear immediately. Routed
models use the provider/model format, for example deepseek/deepseek-flash.
Verify the setup in Codex
ocx status
ocx models live
codex -m "provider/model-id"Replace provider/model-id with an ID shown by ocx models live, then ask Codex to perform a task
that uses a tool, such as reading a file and running its tests. If both the response and tool call
work, setup is complete.
Manual CLI configuration
Use this method when the dashboard does not open or you are setting up a headless machine. The proxy must be running before provider management commands can connect:
ocx startProvider with a preset
For example, with DeepSeek:
ocx provider add deepseek --api-key "<API_KEY>" --set-default --sync
ocx provider test deepseek
ocx models live --provider deepseekReplace deepseek with a preset ID shown by ocx provider presets. Do not add --adapter or
--base-url for a preset because OpenCodex already supplies them.
OpenAI SDK-compatible API
ocx provider add my-provider --adapter openai-chat --base-url "https://example.com/v1" --api-key "<API_KEY>" --default-model "model-id" --set-default --sync
ocx provider test my-provider
ocx models live --provider my-provider
ocx models enable "my-provider/model-id"
ocx sync --restart-codexReplace the URL, key, and model ID with the service's real values. If the key is already stored in the configuration file and the machine has an unlocked keychain, you can move it into the operating system credential store:
ocx provider keychain my-provider storeDo not edit the Codex config while the proxy is running
OpenCodex configuration lives at ~/.opencodex/config.json (Windows:
%USERPROFILE%\.opencodex\config.json). Prefer the dashboard or ocx provider commands so the
file is validated. Do not edit ~/.codex/config.toml yourself: OpenCodex owns the connection
section and may rewrite it during sync.
Quick diagnosis
Run these commands in order before changing the configuration:
ocx status
ocx health
ocx ready --wait --timeout 30
ocx doctor
ocx provider test <provider>
ocx models live --provider <provider>ocx doctor usually reports the cause and a recovery action. Never share an API key or your full
config.json when asking for support.
Common errors
ocx: command not found
Open a new terminal after installation. If it still fails, check that npm's global bin directory is
on PATH:
npm config get prefix
npm list -g @bitkyc08/opencodexBun runtime is missing or npm blocked the install script
If installation reported install-scripts ... blocked, reinstall while allowing Bun's script:
npm install -g --allow-scripts=bun @bitkyc08/opencodexconnection refused or stream disconnected before completion
The proxy stopped or is not ready:
ocx status
ocx startTo restart it automatically after a crash or when you sign in:
ocx service installPort 10100 is already in use
ocx start reports which process owns the port. Stop that process or choose another port, then sync:
ocx start --port 10101
ocx sync --restart-codex401 or 403
The API key is invalid or expired, or the service process cannot read the environment variable that contains it. Test the exact provider first:
ocx provider test <provider>
ocx provider show <provider> --jsonUpdate the key in the dashboard. When the key is an ${ENV_VAR} reference, that variable must exist
in the proxy/service environment, not only in your current terminal.
404 model not found
The model ID is wrong or the account is not entitled to it. Read the IDs actually published by the provider:
ocx models live --provider <provider>Then select the exact provider/model-id string; do not substitute the model's display name.
A model does not appear in Codex
The model may be disabled or Codex may still hold an old catalog:
ocx models enable "provider/model-id"
ocx sync --restart-codexIf it is still missing, fully quit Codex App, reopen it, and start a new task.
Chat works but the terminal or tools do not
The provider uses the wrong adapter or the model does not support function calling. For an ordinary
OpenAI SDK-compatible API, use openai-chat; prefer a preset when available and test again:
ocx provider test <provider>If the provider only supports text chat, switch to a model or endpoint with tool calling. OpenCodex cannot add a capability that the model does not have.
Restore the original Codex configuration
ocx stop # stop the proxy and restore Codex
ocx restore # use separately if the proxy is already stopped but config was not restoredOpenCodex removes only the configuration it added; you do not need to delete ~/.codex.
Useful commands
| Command | Purpose |
|---|---|
ocx gui | Open the dashboard |
ocx status | Check the proxy |
ocx doctor | Diagnose configuration and suggest recovery actions |
ocx models live | List the models currently exposed to Codex |
ocx sync --restart-codex | Sync models and restart Codex |
ocx stop | Stop the proxy and restore the original Codex configuration |
See the OpenCodex documentation and provider list for more details.