Skip to main content

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

  1. Install Node.js LTS (v20+). Verify with node -v and npm -v.
  2. 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

Step 2: Configure ShuYou

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.
FieldDescription
modelDefault model slug from ShuYou models
base_urlhttps://api.shuyou.ai/v1
wire_apiMust 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.