Codex
Codex CLI can be configured to use AI Bridge by setting up a custom model provider.
Configuration
Note
When running Codex CLI inside a Coder workspace, use the configuration below to route requests through AI Bridge.
To configure Codex CLI to use AI Bridge, set the following configuration options in your Codex configuration file (e.g., ~/.codex/config.toml):
[model_providers.aibridge]
name = "AI Bridge"
base_url = "${data.coder_workspace.me.access_url}/api/v2/aibridge/openai/v1"
env_key = "OPENAI_API_KEY"
wire_api = "responses"
[profiles.aibridge]
model_provider = "aibridge"
model = "gpt-5.2-codex"
Run Codex with the aibridge profile:
codex --profile aibridge
If configuring within a Coder workspace, you can also use the Codex CLI module and set the following variables:
module "codex" {
source = "registry.coder.com/coder-labs/codex/coder"
version = "~> 4.1"
agent_id = coder_agent.main.id
workdir = "/path/to/project" # Set to your project directory
enable_aibridge = true
}
Authentication
To authenticate with AI Bridge, get your Coder session token and set it in your environment:
export OPENAI_API_KEY="<your-coder-session-token>"
References: Codex CLI Configuration


