KONG API AI Docs Start free

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:

Terminal
curl -fsSL https://kongapiai.com/en/install.sh | bash

Windows, in PowerShell:

powershell
irm https://kongapiai.com/en/install.ps1 | iex

To 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:

toml
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:

toml
[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:

Terminal
export KONG_API_KEY="gw_live_…"

Windows: run this once, for your account:

powershell
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

Terminal
cd /path/to/your/project
codex

After 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 auth command failed, or KONG_API_KEY is not set. On Windows, use the PowerShell auth part, set the key with setx, then open Codex again.
  • Error 401, wrong key: Codex sent another key, such as OPENAI_API_KEY. Check model_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.