Codex tutorial

Point Codex at the KaiyunCode OpenAI-compatible API, then choose an enabled model.

Setup

Codex CLI uses OpenAI-compatible authentication. This guide sets wire_api to responses and base_url to https://kaiyuncode.com/v1.

Replace REPLACE_WITH_YOUR_API_KEY with an API key created in KaiyunCode. Change model to a GPT model enabled on your account.

  • Config directory: %USERPROFILE%\.codex on Windows, ~/.codex on macOS and Linux.
  • auth.json stores OPENAI_API_KEY.
  • config.toml stores the model, provider, wire_api, and base_url.
  • Check it by running codex and sending a short message, or asking it to inspect the current project.

Install Codex CLI

Codex CLI requires Node.js 18 or newer. Open a new terminal after installation so the updated PATH is used.

Windows PowerShell
node --version
npm install -g @openai/codex
macOS / Linux
node --version
npm install -g @openai/codex

Verify Codex

Confirm the files were written, then start codex. A normal reply and a call record in KaiyunCode mean the setup works.

Windows PowerShell
Get-Content "$env:USERPROFILE\.codex\auth.json"
Get-Content "$env:USERPROFILE\.codex\config.toml"
codex
macOS / Linux
cat "$HOME/.codex/auth.json"
cat "$HOME/.codex/config.toml"
codex

Codex troubleshooting

  • If Codex says the model is unavailable, switch to a GPT model enabled on KaiyunCode.
  • If it says you are not signed in, check that OPENAI_API_KEY in auth.json replaced only the sample text and that the JSON quotes remain.
  • If requests go to official OpenAI, confirm config.toml has base_url = "https://kaiyuncode.com/v1" and model_provider = "custom".