¶ Use AzYun.com in Codex CLI
Define AzYun.com as a custom model provider in Codex configuration and read its key from an environment variable.
Copy
npm install -g @openai/codex
codex --version
Copy
export AZYUN_API_KEY="YOUR_API_KEY"
Edit ~/.codex/config.toml:
Copy
model = "MODEL_ID_FROM_CONSOLE"
model_provider = "azyun"
[model_providers.azyun]
name = "AzYun.com"
base_url = "https://www.azyun.com/v1"
env_key = "AZYUN_API_KEY"
wire_api = "responses"
Replace MODEL_ID_FROM_CONSOLE with the exact model ID shown in the AzYun.com console.
Copy
cd /path/to/your/project
codex
Security
Keep the real key out of config.toml and repositories. The env_key setting reads it from your environment.
Do I need to sign out of ChatGPT?
No. model_provider = "azyun" selects AzYun.com for this configuration. Restore your previous model and provider, then restart Codex, to return to the official service.