Model availability changes frequently. The examples below use
your-model-id — replace it
with a current coding-friendly model ID from the CometAPI Models page.Prerequisites
| Requirement | Details |
|---|---|
| OS | macOS 12+, Linux (Ubuntu 20.04+ / Debian 10+), or Windows 11 via WSL2 |
| Node.js | 22+ (LTS recommended) |
| Git | 2.23+ recommended |
| CometAPI key | Get one from CometAPI Dashboard (starts with sk-) |
Install Codex CLI
Configure CometAPI
There are two ways to point Codex at CometAPI. Choose whichever fits your workflow.- Simple: openai_base_url
- Named provider
The easiest option — redirect the built-in OpenAI provider to CometAPI with a single line.
No need to define a custom provider.Create
~/.codex/config.toml:Store your API key
Create~/.codex/auth.json:
sk-your-cometapi-key with your actual CometAPI key.
Start Codex
Override model per session
Switch to a different model for a single run without editingconfig.toml:
Alternative: environment variable
Instead ofauth.json, export the key directly:
export line to ~/.zshrc or ~/.bashrc.
Troubleshooting
| Symptom | Fix |
|---|---|
API key auth is missing a key | Ensure ~/.codex/auth.json contains "OPENAI_API_KEY": "sk-..." |
| Login prompt appears unexpectedly | Delete stale ~/.codex/auth.json and recreate it with your CometAPI key |
| Model not found | Check the Models page for currently available models |
| Connection timeout | Confirm openai_base_url or base_url is https://api.cometapi.com/v1 in config.toml |
| Windows issues | Codex requires WSL2 on Windows — native CMD/PowerShell is not supported |