Connect Codex CLI / App
Overview
OpenAI Codex is OpenAI's AI coding assistant, available in two flavors:
- Codex CLI (
@openai/codex): a terminal client that picks up custom backends via theOPENAI_BASE_URLenvironment variable or a config file. - Codex App: a desktop GUI client that only honors custom backends declared in
~/.codex/config.tomlundermodel_providers.
Starting with Codex v0.92, Codex defaults to OpenAI's Responses API (POST /v1/responses); from v0.134 the legacy Chat Completions fallback (wire_api = "chat") was fully removed. Wuliang Open AI ships a complete Responses API adapter, so it works as a drop-in Codex backend.
Prerequisites
- Codex CLI:
npm install -g @openai/codex - Codex App: run
codex appin your terminal — it will walk you through the desktop installer - An API Key created on the Wuliang Open AI platform (create one)
Configuration Steps
Option A — Config file (recommended, works for both CLI and App)
⚠️ The Codex App does NOT read
OPENAI_BASE_URL. You must declaremodel_providersin~/.codex/config.toml. The CLI still honors env vars, but using the config file keeps both clients aligned.
Edit ~/.codex/config.toml (create if missing), replacing your-api-key with your API Key:
model = "gpt-5.5"
model_provider = "wuliang"
[model_providers.wuliang]
name = "Wuliang Open AI"
base_url = "https://open.dieyuyun.com/v1"
env_key = "OPENAI_API_KEY"Then export the API Key in your shell config (~/.zshrc / ~/.bashrc) so Codex can read it:
export OPENAI_API_KEY="your-api-key"Reload with source ~/.zshrc (or restart your terminal).
Option B — Environment variables (Codex CLI only)
Codex CLI picks up OPENAI_BASE_URL and OPENAI_API_KEY from the environment. The Codex App ignores these variables.
macOS / Linux
Add the following to ~/.zshrc or ~/.bashrc, replacing your-api-key with your API Key:
export OPENAI_API_KEY="your-api-key"
export OPENAI_BASE_URL="https://open.dieyuyun.com/v1"Then reload the config:
source ~/.zshrc # or source ~/.bashrcWindows
Run in Command Prompt or PowerShell:
setx OPENAI_API_KEY "your-api-key"
setx OPENAI_BASE_URL "https://open.dieyuyun.com/v1"Close and reopen your terminal for the variables to take effect.
Launch Codex
Terminal CLI
codexDesktop App
codex appor launch the Codex icon from your application list. After startup, deepseek-v4-flash should appear in the model picker — type hi to verify connectivity.
API Endpoint Reference
Wuliang Open AI supports both OpenAI protocols:
| Protocol | Path | Notes |
|---|---|---|
| Responses API | POST /v1/responses | Default for Codex CLI / App; recommended for new clients |
| Chat Completions | POST /v1/chat/completions | Legacy protocol; compatible with most OpenAI clients (ChatBox, NextChat, etc.) |
| Field | Value |
|---|---|
| Base URL | https://open.dieyuyun.com/v1 |
| Auth Header | Authorization: Bearer your-api-key |
| Format | JSON |
Responses API example:
curl --request POST 'https://open.dieyuyun.com/v1/responses' \
--header 'Authorization: Bearer your-api-key' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-5.5",
"input": "Introduce yourself.",
"instructions": "You are a helpful assistant.",
"temperature": 0.7,
"max_output_tokens": 1024
}'Chat Completions example (legacy):
curl --request POST 'https://open.dieyuyun.com/v1/chat/completions' \
--header 'Authorization: Bearer your-api-key' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-5.5",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Introduce yourself."}
],
"temperature": 0.7,
"max_tokens": 1024
}'Troubleshooting
Codex App returns Incorrect API key or requests still hit api.openai.com
Cause: The Codex App ignores OPENAI_BASE_URL, so it keeps talking to the official OpenAI endpoint.
Fix: Configure ~/.codex/config.toml with a [model_providers.wuliang] block that explicitly sets base_url (see Option A).
Codex CLI returns 404 /v1/responses not found
Cause: Your Codex CLI is recent enough to default to the Responses API, but the target backend doesn't implement it.
Fix: Upgrade the Wuliang gateway (already supported), or pin an older Codex CLI and set wire_api = "chat" (only honored before v0.92; removed in v0.134).
Model not allowed
Grant the gpt-5.5 model access to your current API Key in the Wuliang console. See Manage API Keys.
Notes
- Config file first:
~/.codex/config.tomlis the unified configuration surface for both Codex CLI and Codex App — prefer it as the default onboarding path. - API Key Security: Do not commit
config.tomlor shell rc files containing real API Keys to version control. - Model Override: Pass
--model gpt-5.5on the CLI to temporarily override the configured model.
Related Docs
- Manage API Keys - Create and configure API Keys
- Models & Pricing - Browse available models and pricing
- API Reference - View the full API documentation