Tools
Codex
Use Codex with a KONG API AI key. Add KONG API AI to Codex's config.toml and keep the key in an environment variable, on macOS, Linux or Windows.
Codex sends its requests to KONG API AI once KONG API AI is set up in Codex's settings file. On Windows, Kong Connect does these steps for you.
Install Codex
Follow the install guide at github.com/openai/codex.
The quick way: one command
The command below asks for your key without showing it, checks the key with KONG API AI, then writes the settings of Claude Code and Codex as in the steps below. Each file is backed up before it is changed.
macOS or Linux:
curl -fsSL https://kongapiai.com/en/install.sh | bashWindows, in PowerShell:
irm https://kongapiai.com/en/install.ps1 | iexTo undo, run curl -fsSL https://kongapiai.com/en/install.sh | bash -s -- --remove, or on Windows run $env:KONG_ACTION='remove', then the install command again. To see what the command does before you run it, open its address in a browser.
Add KONG API AI to Codex
Open or create ~/.codex/config.toml (on Windows: %USERPROFILE%\.codex\config.toml) and add:
model_provider = "kong"
model = "gpt-6-astra"
[model_providers.kong]
name = "KONG API AI"
base_url = "https://kongapiai.com/v1"
[model_providers.kong.auth]
command = "sh"
args = ["-c", "echo $KONG_API_KEY"]On Windows, replace the auth part with:
[model_providers.kong.auth]
command = "powershell"
args = ["-NoProfile", "-Command", "Write-Output $env:KONG_API_KEY"]Codex also accepts env_key = "KONG_API_KEY" in place of the auth part, but then it does not read the KONG API AI model list and may warn "Unknown model".
Set the key
macOS or Linux: add to ~/.zshrc, ~/.bashrc or ~/.config/fish/config.fish:
export KONG_API_KEY="gw_live_…"Windows: run this once, for your account:
setx KONG_API_KEY "gw_live_…"Then quit Codex fully, the Codex app included, and open it again. The Codex app does not see a variable set only in one terminal window.
Start
cd /path/to/your/project
codexAfter a few requests, you see them on the Activity page of the console.
Change the model
Set model in config.toml to another model your key allows. See the list in Models and prices. Codex uses OpenAI models only.
If something fails
- Error 401, no key: the
authcommand failed, orKONG_API_KEYis not set. On Windows, use the PowerShellauthpart, set the key withsetx, then open Codex again. - Error 401, wrong key: Codex sent another key, such as
OPENAI_API_KEY. Checkmodel_provider = "kong". - Model not found: check the model name in Models and prices, and that your key allows it.
- Error 402: no credits left, or the key's monthly limit is reached. See Limits and routing.