Skip to main content

OpenAI Codex CLI

OpenAI's official CLI coding agent — use `antseed codex` for per-run proxy config.

Coding agentsOpenAI Chat Completions~2 min

Codex is OpenAI's terminal coding agent. Recent versions ignore `OPENAI_BASE_URL` and instead read provider config from Codex settings.

`antseed codex` supplies that provider config for one run with Codex `-c` overrides, points it at the active buyer proxy, sets the placeholder API key, and leaves your real `CODEX_HOME` untouched.

If you prefer a persistent manual setup, create `~/.codex/antseed.config.toml` and launch Codex with `codex --profile antseed`; the wrapper is still the shortest path for one-off sessions.

Run AntSeed first

Every integration assumes a buyer proxy at http://localhost:8377. One-time setup, ~2 minutes.

Step 1

Install OpenAI Codex CLI

  • Install Codex globally
    npm install -g @openai/codex
  • Verify it runs
    codex --version

Step 2

Point OpenAI Codex CLI at AntSeed

antseed codex --model claude-sonnet-4-6

Recommended: the wrapper resolves the proxy URL, injects an AntSeed model provider with `wire_api = "responses"`, sets `ANTSEED_API_KEY=antseed`, and forwards extra Codex args. Put child flags after `--` when they look like wrapper flags.

~/.codex/antseed.config.toml
# Loaded by: codex --profile antseed # Set this to a service id returned by http://localhost:8377/v1/models # after pinning an AntSeed peer. model = "claude-sonnet-4-6" model_provider = "antseed" [model_providers.antseed] name = "AntSeed" base_url = "http://localhost:8377/v1" wire_api = "responses"

Manual profile only: this must be your **user-level** `~/.codex/antseed.config.toml`, then launch with `codex --profile antseed`. If your buyer proxy uses a non-default port, update `base_url` to match it. Project-local `./.codex/config.toml` provider blocks are ignored by Codex.

No real OpenAI key is needed. The AntSeed proxy authenticates with your local buyer identity; the wrapper and manual profile both point Codex at the local proxy instead of OpenAI.

Step 3

Pick a model

claude-sonnet-4-6deepseek-v3.1kimi-k2.5qwen-3-coder-480b

Pass the peer service id to `antseed codex --model <service-id>`. For a manual profile, set top-level `model = "<service-id>"` in `~/.codex/antseed.config.toml` or override with `codex --profile antseed --model <service-id>`.

The exact list of models depends on which peer you pin. Run antseed network browse or open the live network page to see what's available right now.

Verify

Test it

  • See which service ids your pinned peer exposes
    curl -s http://localhost:8377/v1/models | jq '.data[].id'
    Example response
    "claude-opus-4-7" "claude-sonnet-4-6" "deepseek-v4-flash" "gpt-oss-120b"

    Whatever appears here is a valid value for top-level `model = ...` in `~/.codex/antseed.config.toml` (or for `codex --profile antseed --model <id>`).

  • Run Codex through the wrapper
    antseed codex --model deepseek-v4-flash

    Manual profile equivalent: `codex --profile antseed --model deepseek-v4-flash`.

  • Verify inference is actually paid through AntSeed
    open http://localhost:3118 # or: antseed buyer status
    What to look for after one real prompt
    Deposits available: 4.289391 USDC → 3.289391 USDC Deposits reserved: 0 USDC → 1 USDC

    The buyer dashboard at http://localhost:3118 is the authoritative real-time signal: a non-zero `Reserved` (channel opened) and/or a drop in `Available` (settled spend) after a real prompt confirms AntSeed served the request. The `antseed buyer status` CLI output is cached and may lag the dashboard — refresh the web view for confirmation. Do not rely on `lsof -i | grep codex` or `~/.codex/log/codex-tui.log`: Codex keeps persistent TCP connections to Cloudflare/ChatGPT IPs (e.g. 172.64.0.0/13) for non-inference purposes (the cause was not isolated during testing), and the `provider=OpenAI` lines in the TUI log are not a reliable indicator that inference went to OpenAI — the on-chain numbers can show AntSeed served the request despite that log line.

How OpenAI Codex CLI talks to AntSeed

  • Wire format sent by OpenAI Codex CLI: OpenAI Chat Completions (hits /v1/chat/completions on the buyer proxy)
  • Best-fit services: any service whose protocols array contains openai-chat-completions. That's what the peer advertises as natively-supported — zero translation overhead, no transform edge cases.
  • How to check a peer: run antseed network peer <peerId> --json and look at providerServiceApiProtocols[provider].services[service]. The browse command exposes the same field per peer.
  • What happens when protocols don't match: AntSeed's @antseed/api-adapter translates between OpenAI Chat Completions and the service's native protocol on the fly. So a request from OpenAI Codex CLI can still reach a service that only advertises anthropic-messages — just with a small transform step.
  • One known caveat: services whose only advertised protocol is openai-responses require streaming. If OpenAI Codex CLI sends a non-streaming request and the proxy routes it to one of those services, the call fails with HTTP 400: Stream must be set to true. Pick a service whose protocols includes openai-chat-completions (or another non-responses protocol) to avoid this.

If it goes wrong

Troubleshooting

  • `OPENAI_BASE_URL` / `OPENAI_API_KEY` are being ignoredExpected on recent Codex builds. Use `antseed codex --model <service-id>` so the wrapper injects the provider config for the current run, or use the manual `~/.codex/antseed.config.toml` profile above.
  • How can I tell if Codex is actually routing through AntSeed?Check the buyer dashboard at http://localhost:3118 (or `antseed buyer status`) after sending a test prompt. `Reserved` going from $0 to a non-zero value (a channel was opened) and/or `Available` dropping (spend settled) confirms AntSeed served the request. If both stay flat after a real prompt, the profile is not being applied. Do not trust `lsof` connections to Cloudflare IPs or `provider=OpenAI` lines in `~/.codex/log/codex-tui.log` — neither is a reliable routing signal.
  • Codex prints `Ignored unsupported project-local config keys … model_provider, model_providers`Provider settings must live in your **user-level** Codex profile file. For this manual flow, put the top-level `model`, `model_provider`, and `[model_providers.antseed]` block in `~/.codex/antseed.config.toml`, then relaunch with `codex --profile antseed`. Codex silently rejects provider blocks in project-local `./.codex/config.toml` and falls back to its default provider.
  • Hand-written Codex `-c` provider overrides behave inconsistentlyUse `antseed codex --model <service-id>` so AntSeed supplies the complete provider block (`base_url`, `wire_api`, and `model_provider`) for the current run. If managing config yourself, keep the full provider/profile in user-level `~/.codex/antseed.config.toml`.
  • Streaming stops after the first chunk with a manual profileUse `antseed codex`, or set `wire_api = "responses"` in the manual `[model_providers.antseed]` block.
  • `unknown profile: antseed`Codex caches profile config on launch. Make sure you saved `~/.codex/antseed.config.toml`, then start a fresh `codex --profile antseed` session.
  • Hangs forever on first messageNo peer is pinned. Run `antseed network browse`, then `antseed buyer connection set --peer <peerId>`.

Reference

Links

Same category

Related