Tools & IDE

Codex CLI Configuration

Endpoint: https://api.shopaikey.com

Codex CLI is OpenAI's official command-line tool (CLI) for pair programming, code refactoring, and debugging right in your terminal.


macOS / Linux

code
curl -fsSL https://cdn.shopaikey.com/codex/setup.sh | bash

Windows (PowerShell)

code
irm https://cdn.shopaikey.com/codex/setup.ps1 | iex

The script automatically installs Codex CLI (if not already installed), backs up old settings, and configures your API key.


1. Install Codex

:::tip We recommend using the automatic setup script in section 0 for quick configuration! :::

You can choose one of three ways to install Codex:

Codex CLI (Command Line Interface)

For the command-line version, run:

code
npm i -g @openai/codex@latest

Codex CLI Package: https://www.npmjs.com/package/@openai/codex

VS Code Extension

For VS Code, install the official extension:

https://marketplace.visualstudio.com/items?itemName=openai.chatgpt

Or search for codex directly in the VS Code Extension Marketplace.

Codex App (Desktop)

To use the desktop app, download from:

https://developers.openai.com/codex/quickstart?setup=app


2. Locate the Codex Configuration Directory

First, open Terminal (or Command Prompt on Windows).

Then run the command for your operating system to open the configuration directory:

Windows

In CMD:

code
start "" "%USERPROFILE%\.codex"

macOS / Linux

code
open "$HOME/.codex"

The .codex directory will open — this is where Codex configuration files are stored.


3. Create Configuration Files

Inside the .codex directory, create the following two files:

config.toml file

Create config.toml with the following content:

code
model_provider = "shopaikey"
model = "gpt-5.2"
model_reasoning_effort = "xhigh"
network_access = "enabled"
disable_response_storage = true
windows_wsl_setup_acknowledged = true
model_verbosity = "high"

[model_providers.shopaikey]
name = "shopaikey"
base_url = "https://api.shopaikey.com/v1"
wire_api = "responses"
requires_openai_auth = true

auth.json file

Create auth.json with the following content:

code
{
  "OPENAI_API_KEY": ""
}

4. Enter Your API Key

In the auth.json file, enter your API key in the OPENAI_API_KEY field:

code
{
  "OPENAI_API_KEY": "sk-your-api-key-here"
}

The API key can be obtained from your ShopAIKey dashboard.

Then save the file.


5. Launch and Test

Open a terminal and run:

code
codex

If configured successfully, you'll enter chat mode and can start using Codex.

Important Notes

:::warning CLI Usage Notes

  • Do not switch models mid-session: After launching the CLI, avoid switching models within the same session.
  • If you've switched models: Restart Codex with the following command to continue using the desired model:
code
codex -m gpt-5.3-codex -c model_reasoning_effort="xhigh"

:::

:::warning When does configuration take effect?

  • Every time you edit config.toml or auth.json, you must restart Codex for the configuration to take effect.
  • How to restart: Press Ctrl + C to exit the current Codex session, then run codex again.
  • Applies to: VS Code Extension and Codex App also use the same configuration system. :::

6. Usage Guide

After configuration, you can start using Codex CLI.

Launch Interactive Mode

In your project directory, type:

code
codex

You'll enter the chat interface. You can ask:

"Explain this project's structure to me"
"Create a test file for the login function in src/auth.js"

Run Commands Directly (Single Shot)

Send a quick request without entering chat mode:

code
codex "Refactor utils.js to make the code cleaner"

Choose a Model

Codex CLI supports various models. Specify a model when launching:

code
codex --model gpt-5 "Explain the calculateTotal function"

View the full model list at Model Pricing.


Advanced Configuration (Optional)

Using Environment Variables

In addition to config files, you can use environment variables to configure Codex:

Linux / macOS

code
export OPENAI_BASE_URL="https://api.shopaikey.com/v1"
export OPENAI_API_KEY="sk-your-api-key-here"

Windows (PowerShell)

code
$env:OPENAI_BASE_URL = "https://api.shopaikey.com/v1"
$env:OPENAI_API_KEY = "sk-your-api-key-here"

Windows (CMD)

code
set OPENAI_BASE_URL=https://api.shopaikey.com/v1
set OPENAI_API_KEY=sk-your-api-key-here

Using a .env File

You can also create a .env file in the ~/.codex/ directory:

code
OPENAI_BASE_URL=https://api.shopaikey.com/v1
OPENAI_API_KEY=sk-your-api-key-here

Troubleshooting

Codex cannot connect

  • Verify that base_url in config.toml is exactly https://api.shopaikey.com/v1
  • Verify that the API Key in auth.json is valid
  • Try restarting Codex after editing the configuration

"command not found" error

  • Ensure Codex CLI is installed: npm i -g @openai/codex@latest
  • Run source ~/.zshrc (macOS/Linux) to reload environment variables

Model not working correctly

  • Check that the model name in config.toml matches the model you want to use
  • Restart Codex with a specific model parameter:
code
codex -m gpt-5.2 -c model_reasoning_effort="xhigh"

Additional Resources