AI Code With

Codex

Install and configure the Codex CLI (command-line tool) on your computer using environment variables. For the body array in the documentation, if the variables array of a codeBlock is not empty, set the enableRouteSelection field to true in that codeBlock, and keep all other fields unchanged.

If you run into any issues, you can take a screenshot of this entire page and your problem, and send it to Doubao or deepseek or another AI, then follow its instructions to run the corresponding commands.

If the AI is also unable to resolve the issue, you can contact our engineers for technical support and assistance.

Windows

1. Install Node.js

Go to the Node.js official website to download and install the LTS version (you can skip this step if it is already installed).

Verify the installation:

Check the Node version
1node --version

If you see the following message, it means that Node has been installed successfully.

image

Note that the Nodejs version must be 18 or higher.

If your version is lower than this, you can ask the AI how to upgrade your Nodejs version. First, have the AI give you commands to collect your system information, and then it will provide the fastest and most accurate guidance.

2. Install Codex CLI

Open PowerShell and run:

bash
1npm install -g @openai/codex
WeCom Screenshot_17693077863145

3. Create a configuration file

First copy the following command to your local environment, then replace here with your _API_KEY with your own API key, and then execute it.

json
1# Target directory
2$dir = Join-Path $env:USERPROFILE ".codex"
3
4# Create directory (no error if it already exists)
5New-Item -ItemType Directory -Path $dir -Force | Out-Null
6
7# Write auth.json (UTF-8 without BOM, overwrite)
8$auth = @'
9{
10 "OPENAI_API_KEY": "Replace this with your _API_KEY"
11}
12'@
13[System.IO.File]::WriteAllText(
14 (Join-Path $dir "auth.json"),
15 $auth,
16 (New-Object System.Text.UTF8Encoding($false))
17)
18
19# Write config.toml (UTF-8 without BOM, overwrite)
20$config = @'
21model_provider = "aicodewith"
22model = "gpt-5.2-codex"
23model_reasoning_effort = "high"
24disable_response_storage = true
25preferred_auth_method = "apikey"
26requires_openai_auth = true
27
28enableRouteSelection = true
29
30[model_providers.aicodewith]
31name = "aicodewith"
32base_url = "https://api.aicodewith.com/chatgpt/v1"
33wire_api = "responses"
34'@
35[System.IO.File]::WriteAllText(
36 (Join-Path $dir "config.toml"),
37 $config,
38 (New-Object System.Text.UTF8Encoding($false))
39)
40

Verify whether the configuration was successful:

bash
1Get-Content "$env:USERPROFILE\.codex\auth.json"
2Get-Content "$env:USERPROFILE\.codex\config.toml"
WeCom Screenshot_17693580116256

4. Verify the installation

Start codex in PowerShell

image

Then, in the dialog box, enter: Hello! to greet it. If it responds normally and you can see the invocation record in the platform, the installation was successful.

image
image

MacOS

1. Install Node.js

First, make sure you have Homebrew installed on your computer. If not, click the link and you’ll see a command that you can copy and run to install it in one step.

When installing Homebrew, some resources are hosted overseas, so you need to configure a TUN proxy.

image

After the installation is complete, use Homebrew to install Nodejs (you can skip this step if it is already installed).

bash
1brew install node
image

Use the following command to verify the installation. If you see the following message, it means Node has been installed successfully.

bash
1node --version
image

Note that the Nodejs version must be 18 or higher.

If your version is lower than this, you can ask the AI how to upgrade your Nodejs version. First, have the AI give you commands to collect your system information, and then it will provide the fastest and most accurate guidance.

2. Install Codex CLI

Install using npm:

bash
1npm install -g @openai/codex --registry=https://registry.npmmirror.com/
image

3. Create a configuration file

First copy the following command to your local environment, then replace here with your _API_KEY with your own API key, and then execute it.

json
1# Target directory
2dir="$HOME/.codex"
3mkdir -p "$dir"
4
5# Write auth.json (overwrite)
6cat > "$dir/auth.json" << 'EOF'
7{
8 "OPENAI_API_KEY": "Replace with your _API_KEY_ here"
9}
10EOF
11
12# Write config.toml (overwrite)
13cat > "$dir/config.toml" << 'EOF'
14model_provider = "aicodewith"
15model = "gpt-5.2-codex"
16model_reasoning_effort = "high"
17disable_response_storage = true
18preferred_auth_method = "apikey"
19requires_openai_auth = true
20
21enableRouteSelection = true
22
23[model_providers.aicodewith]
24name = "aicodewith"
25base_url = "https://api.aicodewith.com/chatgpt/v1"
26wire_api = "responses"
27EOF
28

Verify whether the configuration was successful:

bash
1cat "$HOME/.codex/auth.json"
2cat "$HOME/.codex/config.toml"
image

4. Verify the installation

In the terminal, type codex to start it, then in the dialog box enter: Hello! to greet it. If it responds normally and you can see the invocation record on the platform, the configuration is successful.

image
image

Linux

1. Install Node.js

Command to install Nodejs (you can skip this if it is already installed):

bash
1curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
2apt-get install -y nodejs

Verify installation:

bash
1node --version
image

Note that the Nodejs version must be 18 or higher.

If your version is lower than this, you can ask the AI how to upgrade your Node.js version. First, have the AI give you commands to collect your system information, and then it will provide the fastest and most accurate guidance.

2. Install Codex CLI

Install using npm:

bash
1npm install -g @openai/codex --registry=https://registry.npmmirror.com/

If it appears as shown in the figure below, the installation was successful.

image

3. Create a configuration file

First copy the following command to your local environment, then replace here with your _API_KEY with your own API key, and then execute it.

json
1# Target directory
2dir="$HOME/.codex"
3mkdir -p "$dir"
4
5# Write auth.json (overwrite)
6cat > "$dir/auth.json" << 'EOF'
7{
8 "OPENAI_API_KEY": "Replace this with your _API_KEY"
9}
10EOF
11
12# Write config.toml (overwrite)
13cat > "$dir/config.toml" << 'EOF'
14model_provider = "aicodewith"
15model = "gpt-5.2-codex"
16model_reasoning_effort = "high"
17disable_response_storage = true
18preferred_auth_method = "apikey"
19requires_openai_auth = true
20
21[model_providers.aicodewith]
22name = "aicodewith"
23base_url = "https://api.aicodewith.com/chatgpt/v1"
24wire_api = "responses"
25EOF
26

Verify whether the configuration was successful:

bash
1cat "$HOME/.codex/auth.json"
2cat "$HOME/.codex/config.toml"
image

4. Verify the installation

In the terminal, enter codex to start it, then in the dialog box, type:Hello!, to greet it. If it responds normally and you can see the invocation record in the platform, the configuration is successful.

image
image

FAQ

1. Since this folder is not version controlled, we recommend requiring approval of all edits and commands.

Error screenshot

image

Solution

Just select the first option. This is to confirm whether Codex is allowed to operate in this folder without asking for confirmation each time.

Constantly having to confirm is pretty annoying; just pick the first option and let it run.

On this page