Codex + Cradler Router

How to run Codex on a cheaper API

Codex is a first-class coding agent — and it reads its endpoint from config. Point it at Cradler Router, a compatible OpenAI Responses API gateway, for GPT access up to 87% below list price with the full agent loop intact — top up by card in about a minute.

Short answer

Codex talks to any OpenAI-compatible endpoint. Add a model provider in ~/.codex/config.toml pointing at Cradler Router with wire_api = "responses", set your Router key, and Codex runs exactly as before — same agent loop, same tools — but on cheaper supply, topped up in your own currency. No OpenAI account needed.

One command, every agent

Paste your key, copy the command, run it in a terminal. It writes the config for Claude Code, Codex, and Gemini CLI — plus OpenClaw, ZCode, and Cherry Studio when they're installed — then verifies your key against the Router. Built locally; the key never leaves this page.

npx @cradler/router-setup <your-router-key>

Why route Codex

Codex is built on the OpenAI Responses API. That is the expensive part of a heavy coding day, and it assumes an OpenAI account and a card many builders outside the US do not have.

Because Codex reads its provider and key from config, you can route it through a compatible gateway. Cradler Router aggregates supply and passes the same Responses API straight through, so the agent behaves identically — you change only where the request goes and what it costs.

Connecting Codex to Cradler Router, step by step

One provider block in your Codex config — that is the integration.

  1. 01

    Create a Cradler account and get a Router key

    Sign up at cradler.ai, open the Router section, top up by card, and create an API key. The same account also runs your Cradler database and file storage.

  2. 02

    Add Cradler Router as a Codex model provider

    Fastest: run npx @cradler/router-setup with your key — it writes the provider block and verifies the key for you. Or define it manually in ~/.codex/config.toml with wire_api set to "responses".

  3. 03

    Point your key at it

    Set the environment variable your provider block references to your Router key, then run Codex. No other change to your workflow is needed.

  4. 04

    Build — with the agent loop intact

    Codex's Responses-API agent loop, shell commands, and file edits all pass through. Optionally add a fast mode for higher throughput on the models that support it.

The configuration

Add a provider block to ~/.codex/config.toml and point Codex at it:

# ~/.codex/config.toml
model = "gpt-5.5"
model_provider = "cradler"

[model_providers.cradler]
name = "Cradler Router"
base_url = "https://router.cradler.ai/v1"
wire_api = "responses"
env_key = "CRADLER_ROUTER_KEY"

Then set your key and run Codex:

export CRADLER_ROUTER_KEY="<your-router-key>"

# Run Codex as usual
codex

# …or pin a model for a run
codex --model gpt-5.6-sol

Fast mode, when you want it

For latency-sensitive work, request a fast tier on supported GPT models. It trades cost for speed — roughly 2x the price for up to about 2.5x the throughput — and is entirely optional.

# OpenAI SDK against Cradler Router
from openai import OpenAI

client = OpenAI(
    api_key="<your-router-key>",
    base_url="https://router.cradler.ai/v1",
)

resp = client.responses.create(
    model="gpt-5.6-sol",
    input="Refactor this module for readability",
    service_tier="fast",   # higher throughput, ~2x price
)
print(resp.output_text)

Gotchas worth knowing

Use the Responses API for GPT. Codex expects wire_api = "responses". The Responses endpoint serves the GPT series; send it a non-GPT model and it will reject the request.

Read the model list, don't guess it. Available model IDs are whatever /v1/models returns for your key. A name from an old doc may 404 — check the live list first.

Keep your Router key out of your repo. It is a billable credential — environment variable or secrets manager, never a committed file. Rotate it if it is ever exposed.

One account, model access and a backend

Cradler Router is part of Cradler — the same account that gives your app a managed PostgreSQL database and file storage through a typed SDK, with no SQL and no migrations. The key that makes Codex cheaper is the key that stores what Codex helps you build. One signup, one bill.

The rest of what your Cradler account includes

Router makes Codex cheaper. The same account also gives the app you're building a full backend.

Data

Managed PostgreSQL

Auto-evolving schema. No SQL, no migrations, no ALTER TABLE.

Storage

Image / video / audio storage

Through the same SDK as your data, served fast over a global CDN.

DX

Typed TypeScript SDK

@cradler/sdk — query-builder shape your AI tool was trained on.

AI-native

MCP server

@cradler/mcp — Claude and Cursor read and write your data directly.

AI-native

Agent Skill

Drop into your AI agent; it knows how to wire Cradler in.

Frequently asked questions

Do I need an OpenAI account to use Codex this way?

No. Codex only needs an OpenAI-compatible endpoint and a key. Cradler Router provides a compatible Responses API endpoint, so you point Codex at Router with your Cradler key and top up by card (Alipay and WeChat Pay coming soon). There is no separate OpenAI signup.

Which protocol does Codex use through Cradler Router?

Codex uses the OpenAI Responses API (/v1/responses). Set wire_api = "responses" in your Codex provider block. Router also exposes the Chat Completions API (/v1/chat/completions) if you need it for other tools.

Does the Codex agent loop — shell commands, file edits — still work?

Yes. Router passes the Responses API through, so Codex's full tool loop runs: it plans, runs shell commands, edits files, and iterates. We validate agent tool loops through the gateway against real CLIs, not just single requests.

What is fast mode?

Fast mode (service_tier: "fast", formerly "priority") requests higher-priority processing for supported GPT models — up to roughly 2.5x standard speed — billed at about 2x the standard rate. It is optional; leave it off for the cheapest runs, turn it on when you want lower latency.

Which GPT models are available?

The GPT-5 series is available, including fast variants. The authoritative list is always what GET /v1/models returns for your key — read that rather than hard-coding a model name, since IDs change as versions are added or retired.

How does this connect to Cradler's database?

Cradler Router and Cradler's database + file storage are two features of one account. Use Router on its own for cheaper Codex access, or use the same project to give the app you're building a managed PostgreSQL database and file storage through a typed SDK — no SQL, no migrations.

Keep reading

Run Codex for less

Create a Cradler account, get a Router key, and add one provider block to your Codex config. Free to start — top up in your own currency.