1. Introduction
This document is designed to guide users in successfully connecting Codex CLI to Mixroute. Codex CLI is a command-line AI-assisted coding tool that runs in your terminal. By modifying the configuration files under its official configuration directory~/.codex, you can establish a stable and easily manageable multi-model access environment.
2. Prerequisites
Before configuring, please ensure you have completed the following preparations:- Install Codex CLI: Ensure that the tool package is installed globally in your development environment.
- Obtain Mixroute Credentials (API Key):
- Visit the official Mixroute console and register or log into your account.
- Navigate to the API key management page, generate, and copy your exclusive API Key (usually starting with
sk-).
- Verify Network Connectivity: Ensure your development device’s current network environment can access Mixroute’s service address:
https://api.mixroute.ai.
3. Configuration Phase
The core configuration for Codex CLI is located in the.codex folder within your user directory. The configuration primarily involves two files: config.toml (handles interface and model parameters) and auth.json (handles secure key storage).
3.1 Locate or Create the Configuration Directory
Windows Users: PressWin+R on your keyboard, type %userprofile%\.codex, and hit Enter.
MacOS / Linux Users: Enter ~/.codex in your terminal or access it via your file manager.
Important Note: If you are installing Codex CLI for the first time, this directory or the files within it may not exist. Please create the directory and the two files mentioned below manually.
3.2 Configure Config.toml
Create or edit the.codex/config.toml file, copy and save the following Mixroute configuration:
Note:
base_urlmust end with/v1and should not have a trailing slash.- It is recommended to keep
wire_apias"chat"because most third-party proxy gateways implement/chat/completions. If you encounter a 404 error, you can try changing it to"responses"depending on the platform’s specific compatibility.
3.3 Configure auth.json
Create or edit the.codex/auth.json file. For security, do not write your API Key directly in the TOML file; instead, store it in this JSON file:
"sk-yourMixrouteKeyxxxxxxxxxxxx" with your actual Mixroute API Key obtained during the preparation phase.
4. Verification and Testing
After completing the configuration, invoke Codex CLI in your terminal to test the conversation:- If Codex responds normally, it indicates that the connection to Mixroute is successful.
- If you encounter an error (such as unauthorized or connection failure), please carefully check if the key format in
auth.jsonis correct (including double quotes) and if thebase_urlinconfig.tomlis accurately set tohttps://api.mixroute.ai/v1.