Skip to main content

Overview

Codex CLI is OpenAI’s open-source command-line coding agent. It can read your codebase, propose changes, execute commands, and iterate based on feedback — all from the terminal. By pointing Codex CLI to AihubMax, you can use it with any OpenAI-compatible model available through AihubMax’s API.
Codex CLI supports a config.toml configuration file for defining custom model providers, making it easy to connect to AihubMax without modifying environment variables for the base URL.

Prerequisites

AihubMax API Key

An active AihubMax API key with access to OpenAI-compatible models. Go to AihubMax →

Node.js 22+

Codex CLI requires Node.js version 22 or later. Download Node.js →

Installation & Configuration

1

Install Codex CLI

Verify the installation:
2

Set Your API Key

Before configuring environment variables, go to the AihubMax Console to create a dedicated key:
  1. Open the “API Keys” page and click “Create Key”.
  2. Name the key as you prefer for easy identification.
  3. Make sure to select the “Codex” group — this is the official channel for Codex CLI, ensuring OpenAI-compatible protocol support and adequate concurrency limits.
If you don’t select the “Codex” group, Codex CLI may not be able to call AihubMax’s Codex-compatible models, or you may encounter rate/feature limitations.
You can choose either method below: use CC-Switch for one-click setup (automatically writes environment variables and Codex configuration), or manually configure by setting environment variables and editing config.toml in the next step.Codex CLI reads the OPENAI_API_KEY environment variable for authentication. Set it to your AihubMax API key:
3

Configure AihubMax as a Model Provider

If you chose CC-Switch in the previous step, the tool has already written your ~/.codex/config.toml. You can skip directly to “Start Using Codex”. This step is only needed for manual configuration.
Create or edit the Codex CLI configuration file:
Edit ~/.codex/config.toml:
The wire_api field must be set to "responses". The "chat" option is deprecated and may cause unexpected behavior.
Configuration fields explained:
4

Start Using Codex

Navigate to your project and launch Codex:
Or run a one-off command:

Verify the Connection

Test the connection with a simple prompt:
If the configuration is correct, Codex will respond through AihubMax’s API. You can override the default model from config.toml when launching Codex:

Troubleshooting

  • Verify your OPENAI_API_KEY is a valid AihubMax key.
  • Ensure the key has not expired and has sufficient balance.
  • If using config.toml, confirm the env_key field matches the environment variable name you set (default: OPENAI_API_KEY).
  • Check that base_url in config.toml is set to https://api.aihubmax.com/v1 (with /v1).
  • Verify your network can reach api.aihubmax.com.
  • Confirm the model name is correct and available on AihubMax.
  • Check your AihubMax account for model access permissions.
  • Confirm the file is located at ~/.codex/config.toml (macOS/Linux) or C:\Users\{username}\.codex\config.toml (Windows).
  • Validate the TOML syntax — ensure strings are properly quoted and section headers use square brackets.
  • Check that model_provider value matches the [model_providers.xxx] section name exactly.