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 FoxAPI, you can use it with any OpenAI-compatible model available through FoxAPI’s API.Codex CLI supports a
config.toml configuration file for defining custom model providers, making it easy to connect to FoxAPI without modifying environment variables for the base URL.Prerequisites
FoxAPI API Key
An active FoxAPI API key with access to OpenAI-compatible models.
Node.js 22+
Codex CLI requires Node.js version 22 or later.
Installation & Configuration
Set Your API Key
Codex CLI reads the
OPENAI_API_KEY environment variable for authentication. Set it to your FoxAPI API key:- macOS / Linux
- Windows (PowerShell)
Add the following line to your shell profile (Then reload your shell configuration:
~/.bashrc, ~/.zshrc, etc.):Configure FoxAPI as a Model Provider
Create or edit the Codex CLI configuration file:Configuration fields explained:
- macOS / Linux
- Windows
Edit
~/.codex/config.toml:| Field | Description |
|---|---|
model | Default model to use (can be overridden with --model flag) |
model_reasoning_effort | Reasoning effort level: "low", "medium", or "high" |
model_provider | Name of the custom provider (must match the [model_providers.xxx] section) |
base_url | FoxAPI’s API endpoint |
env_key | Environment variable name that holds your API key |
wire_api | API protocol to use ("responses" is required) |
Verify the Connection
Test the connection with a simple prompt:Recommended Models
| Model | Best For |
|---|---|
gpt-4.1 | Complex multi-step coding tasks (recommended default) |
gpt-4o | General coding tasks with balanced speed and quality |
o4-mini | Fast, cost-effective coding assistance |
config.toml when launching Codex:
Troubleshooting
Error: 401 Unauthorized
Error: 401 Unauthorized
Error: Connection failed
Error: Connection failed
- Check that
base_urlinconfig.tomlis set tohttps://api.foxapi.cc/v1(with/v1). - Verify your network can reach
api.foxapi.cc.
Model not found
Model not found
- Confirm the model name is correct and available on FoxAPI.
- Check your FoxAPI account for model access permissions.
Config file not taking effect
Config file not taking effect
- Confirm the file is located at
~/.codex/config.toml(macOS/Linux) orC:\Users\{username}\.codex\config.toml(Windows). - Validate the TOML syntax — ensure strings are properly quoted and section headers use square brackets.
- Check that
model_providervalue matches the[model_providers.xxx]section name exactly.