VNAI Pro
Codex

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:

Terminal
node --version
codex --version

If Codex CLI is not installed:

Terminal
npm install -g @openai/codex

Install OpenCodex

Terminal
npm install -g @bitkyc08/opencodex
ocx --version

OpenCodex bundles the Bun runtime, so you do not need to install Bun separately.

Start the proxy

Terminal
ocx start

The dashboard runs at http://localhost:10100. If it does not open:

Terminal
ocx gui

OpenCodex 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:

  1. For DeepSeek, Z.AI/GLM, or Qwen, select the built-in preset. OpenCodex fills in the endpoint and adapter.
  2. Paste the API key issued by the provider.
  3. Select the default model, then click Test and Save.

For another OpenAI SDK-compatible service, select Custom and enter:

FieldValue
NameA short name, such as my-provider
AdapterOpenAI Chat Completions (openai-chat)
Base URLThe service endpoint, usually ending in /v1
API keyThe service API key
Default modelThe 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:

Terminal
ocx sync --restart-codex

This 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

Terminal
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:

Terminal
ocx start

Provider with a preset

For example, with DeepSeek:

Terminal
ocx provider add deepseek --api-key "<API_KEY>" --set-default --sync
ocx provider test deepseek
ocx models live --provider deepseek

Replace 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

Terminal
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-codex

Replace 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:

Terminal
ocx provider keychain my-provider store

Do 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:

Terminal
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:

Terminal
npm config get prefix
npm list -g @bitkyc08/opencodex

Bun runtime is missing or npm blocked the install script

If installation reported install-scripts ... blocked, reinstall while allowing Bun's script:

Terminal
npm install -g --allow-scripts=bun @bitkyc08/opencodex

connection refused or stream disconnected before completion

The proxy stopped or is not ready:

Terminal
ocx status
ocx start

To restart it automatically after a crash or when you sign in:

Terminal
ocx service install

Port 10100 is already in use

ocx start reports which process owns the port. Stop that process or choose another port, then sync:

Terminal
ocx start --port 10101
ocx sync --restart-codex

401 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:

Terminal
ocx provider test <provider>
ocx provider show <provider> --json

Update 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:

Terminal
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:

Terminal
ocx models enable "provider/model-id"
ocx sync --restart-codex

If 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:

Terminal
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

Terminal
ocx stop       # stop the proxy and restore Codex
ocx restore    # use separately if the proxy is already stopped but config was not restored

OpenCodex removes only the configuration it added; you do not need to delete ~/.codex.

Useful commands

CommandPurpose
ocx guiOpen the dashboard
ocx statusCheck the proxy
ocx doctorDiagnose configuration and suggest recovery actions
ocx models liveList the models currently exposed to Codex
ocx sync --restart-codexSync models and restart Codex
ocx stopStop the proxy and restore the original Codex configuration

See the OpenCodex documentation and provider list for more details.

On this page