Skip to content
Connect a clientCodex

Codex

OpenAI Codex CLI via Guard AI.

Set up with your own AI
Model protocol

Codex connects to Guard through your user config.toml. It also needs a local model catalog for a reliable cold start: without it, the first request can be built before Codex finishes fetching /v1/models, leaving some tools disabled.

1. Download the model catalog

Mac / Linux:

bash
mkdir -p ~/.codex
curl -fsSL https://docs.guardrelay.ai/assets/guard-codex-models.json \
  -o ~/.codex/guard-codex-models.json

Windows (PowerShell):

powershell
New-Item -ItemType Directory -Force "$HOME\.codex" | Out-Null
Invoke-WebRequest https://docs.guardrelay.ai/assets/guard-codex-models.json `
  -OutFile "$HOME\.codex\guard-codex-models.json"

2. Add the provider to config.toml

Open (or create) the file ~/.codex/config.toml — on Windows that's %USERPROFILE%\.codex\config.toml — and paste:

toml
model = "claude-sonnet-5"
model_provider = "guard"
model_catalog_json = "~/.codex/guard-codex-models.json"

[model_providers.guard]
name = "Guard AI"
base_url = "https://api.guardrelay.ai/v1"
env_key = "GUARD_API_KEY"
wire_api = "responses"

The Codex catalog contains six Claude models: claude-sonnet-5, claude-opus-5, claude-opus-4-8, claude-haiku-4-5, claude-fable-5-1 and claude-fable-5. Put the desired ID in model; Sonnet 5 is the default. Fable works without an actually applied server prompt. If a suitable prompt would apply, a Fable request is rejected before billing.

3. Set the key and run

Windows (PowerShell):

powershell
$env:GUARD_API_KEY = "gd-your-key-from-bot"
codex

Mac / Linux:

Environment variables
bash · macOS / Linux
export GUARD_API_KEY="gd-your-key-from-bot"
codex
PowerShell · Windows
$env:GUARD_API_KEY = "gd-your-key-from-bot"
codex

A one-off run without interactive mode:

bash
codex exec "check connection: reply 'ok'"

Kimi, Composer and Grok in Codex

The configuration above uses wire_api = "responses", that is POST /v1/responses.

FamilyOn /v1/responses
Kimiavailable: it accepts model, input, instructions, stream, tools, tool_choice, parallel_tool_calls, max_output_tokens, reasoning, text, temperature, top_p, prompt_cache_key, include, store, truncation and metadata
Composer, GrokAvailable: model, input, instructions, max_output_tokens, stream and client tools. Supported additional compatibility fields are listed below.
toml
model = "cursor-grok-4.6-high"
model_provider = "guard"

[model_providers.guard]
name = "Guard AI"
base_url = "https://api.guardrelay.ai/v1"
env_key = "GUARD_API_KEY"
wire_api = "responses"

Codex on a Kimi model

Codex calls the Responses surface, and Kimi serves it. The configuration is the Claude one with two differences: an exact Kimi id in model, and no model catalog. The downloaded guard-codex-models.json describes Claude models only, so leave the model_catalog_json line out for Kimi: with a foreign catalog Codex treats the model as unknown.

toml
model = "k3"
model_provider = "guard"

[model_providers.guard]
name = "Guard AI"
base_url = "https://api.guardrelay.ai/v1"
env_key = "GUARD_API_KEY"
wire_api = "responses"

The key is passed through the GUARD_API_KEY variable. Mac / Linux:

Environment variables
bash · macOS / Linux
export GUARD_API_KEY="gd-your-key-from-bot"
codex
PowerShell · Windows
$env:GUARD_API_KEY = "gd-your-key-from-bot"
codex

Windows (PowerShell):

powershell
$env:GUARD_API_KEY = "gd-your-key-from-bot"
codex

A one-off connection check without interactive mode:

bash
codex exec "check connection: reply 'ok'"

Running Composer and Grok

No catalog download is needed, simply leave the model_catalog_json line out. Put an exact id in model: Composer has composer-2.5; Grok has cursor-grok-4.6-low, -medium, -high, -xhigh. Every id also has a -fast variant: the same answer, faster and more expensive.

The key is passed through the same GUARD_API_KEY variable. Mac / Linux:

Environment variables
bash · macOS / Linux
export GUARD_API_KEY="gd-your-key-from-bot"
codex
PowerShell · Windows
$env:GUARD_API_KEY = "gd-your-key-from-bot"
codex

Windows (PowerShell):

powershell
$env:GUARD_API_KEY = "gd-your-key-from-bot"
codex

A one-off connection check without interactive mode:

bash
codex exec "check connection: reply 'ok'"

Documentation sections

On this page