Codex CLI
Connect OpenAI’s Codex CLI to ShuYou and call GPT and other OpenAI-compatible models from the terminal with one API key.
Prerequisites
- Install Node.js LTS (v20+). Verify with
node -v and npm -v.
- Create a ShuYou API key in the console.
ShuYou OpenAI-compatible base URL: https://api.shuyou.ai/v1
Step 1: Install Codex CLI
npm install -g @openai/codex
codex --version
Edit ~/.codex/config.toml (Windows: %USERPROFILE%\.codex\config.toml):
model = "openai/gpt-4o"
model_reasoning_effort = "medium"
model_provider = "shuyou"
[model_providers.shuyou]
name = "ShuYou API"
base_url = "https://api.shuyou.ai/v1"
env_key = "OPENAI_API_KEY"
wire_api = "responses"
Set your API key:
export OPENAI_API_KEY="YOUR_SHUYOU_API_KEY"
Add the same line to ~/.zshrc or ~/.bashrc for persistence.$env:OPENAI_API_KEY = "YOUR_SHUYOU_API_KEY"
Or set a persistent user variable in System Environment Variables.
| Field | Description |
|---|
model | Default model slug from ShuYou models |
base_url | https://api.shuyou.ai/v1 |
wire_api | Must be responses (not chat) |
Step 3: Verify
cd your-project-directory
codex "Who are you?"
FAQ
401 / 403: Check OPENAI_API_KEY and that the model slug exists on ShuYou.
Config not applied: Restart the terminal and validate TOML syntax in config.toml.
Switch models: Change the model field in config.toml and restart Codex.
Use Codex in a dedicated project folder. Avoid directories with secrets or system files.