Integrations
Codex
Codex uses `~/.codex/config.toml` for OpenAI-compatible models and reads credentials from `OPENAI_API_KEY` (Windows config directory: `%USERPROFILE%\.codex\`).
Last updated: 2026-08-03
If a model is unavailable, confirm it exists in the model list and recheck your API Key and Base URL. View model list
1
Install Codex
Install globally and verify.
Terminal
npm install -g @openai/codex@latest
codex --version2
Recommended: persistent setup
Keep the existing config.toml and store the API Key in your user environment or shell profile. env_key makes Codex read it automatically.
Windows PowerShell (user environment)
[System.Environment]::SetEnvironmentVariable("OPENAI_API_KEY","your-apihub-key",[System.EnvironmentVariableTarget]::User)macOS zsh (~/.zshrc)
echo 'export OPENAI_API_KEY="your-apihub-key"' >> ~/.zshrc
source ~/.zshrcLinux bash (~/.bashrc)
echo 'export OPENAI_API_KEY="your-apihub-key"' >> ~/.bashrc
source ~/.bashrcconfig.toml (Windows: %USERPROFILE%\.codex\config.toml)
model_provider = "apihub"
model = "deepseek-v4-flash"
model_reasoning_effort = "high"
disable_response_storage = true
[model_providers.apihub]
name = "ApiHub"
base_url = "https://www.apihub.ink/v1"
wire_api = "responses"
env_key = "OPENAI_API_KEY"3
Temporary setup (current terminal only)
Use this only to test connectivity. The variable is lost when the terminal closes.
Windows PowerShell
$env:OPENAI_API_KEY="your-apihub-key"macOS / Linux
export OPENAI_API_KEY="your-apihub-key"4
Launch
Start Codex and confirm no 401 errors before working on real tasks.
Terminal
codexVerification
- Codex reads config successfully and sends requests without auth errors.
Common Errors
- Wrong `wire_api` value causes protocol mismatch.
- `OPENAI_API_KEY` is not set in the terminal that launches Codex.
- On Windows, using `~` instead of `%USERPROFILE%` — path not found.