Integrations

Codex

Run OpenAI's coding agent on any model in the AI Pass catalog.

Codex is OpenAI's coding agent for the terminal and IDE. Point it at AI Pass's Responses endpoint to run it on any tool-capable model in the catalog, with one balance and per-key spend limits.

1. Install Codex

Terminal
npm install -g @openai/codex

2. Export your key

Create a key, then export it in the shell that launches Codex.

~/.zshrc or ~/.bashrc
export AIPASS_KEY=ap-live-YOUR-KEY-HERE

3. Add the provider

Add AI Pass to your user-level config.

~/.codex/config.toml
model = "openai/gpt-4.1-mini"
model_provider = "aipass"
web_search = "live"

[model_providers.aipass]
name = "AI Pass"
base_url = "https://api.aipass.xyz/v1"
wire_api = "responses"
auth = { command = "sh", args = ["-c", "echo $AIPASS_KEY"] }

4. Start a session

Terminal
codex

Send one prompt, then open Activity. The request lists its model, tokens and exact cost.

Switch models

Native search requires a supported OpenAI model on a Vercel route. Set web_search = "disabled" when switching to other models or routers. /model lists:

  1. Routers: aipass/fusion, then aipass/auto and its :smart, :cheap and :code intents.
  2. Your presets, as @preset/your-slug.
  3. Every tool-capable model, frontier models first.
/model
Inside a session.
codex -m aipass/auto:code
One run.
model = "openai/gpt-4.1-mini"
The default, in ~/.codex/config.toml.

Pin a model per project

A trusted project can choose its own model. The provider stays in your user config.

.codex/config.toml
model = "@preset/your-slug"

A preset lets you change the model from the dashboard without touching the repository.

Run headless

codex exec runs one task without the TUI. Use it in scripts and CI, or see Automatic code review for a pull request workflow.

Terminal
codex exec -m openai/gpt-4.1-mini \
  --sandbox workspace-write \
  --json "Run the tests and fix failures"
--sandbox workspace-write
Allows edits. The default is read-only.
--json
Prints events as JSON Lines.
--ephemeral
Keeps no session files.

Keep spend in check

Restrict models or filter content with Guardrails.

Troubleshooting

Codex ignores the AI Pass provider block

Project .codex/config.toml ignores model_provider, model_providers and profiles, and loads only in trusted projects. Put the provider block in ~/.codex/config.toml.

Codex calls Chat Completions or reports an unsupported wire API

Set wire_api to responses. AI Pass exposes the Responses route at /v1/responses; Codex appends /responses to the configured base URL.

Error: 400 invalid_request.

Codex prints "provider auth command sh produced an empty token"

AIPASS_KEY is not exported in the shell that launched Codex. Run export AIPASS_KEY=… in that shell, or add the export to your shell profile, then start Codex again. Without the token Codex also skips the AI Pass model list, so the fallback-metadata notice follows.

Codex prints "Model metadata … not found. Defaulting to fallback metadata"

Codex 0.153 and later load a third-party model list only through a command-backed auth entry. Replace env_key with the auth line above; with env_key the notice is expected and harmless.

401 on every request

Wrong or rotated key. Keys start with ap-live-; after a rotation the old key keeps working for 24 hours, then dies.

Error: 401 invalid_api_key.

402 before any tokens arrive

Balance below the estimated cost of the request. Top up (from $0.50 with direct Solana payments), and watch the x-aipass-balance-usd header, the low-balance signal every response carries.

Error: 402 insufficient_credits.

Every error code, with its fix: Errors.

Next steps

Esc