Skip to main content

Run OpenAI Codex CLI on any model

OpenAI's official CLI coding agent - add your Antseed gateway as a Codex provider, or launch it with antseed codex.

Coding agentsOpenAI Responses~2 min

Codex is OpenAI's terminal coding agent. Recent versions ignore OPENAI_BASE_URL and instead read provider config from Codex settings, so Antseed plugs in as a custom model provider that speaks the Responses API.

The recommended endpoint is a gateway: add it as a provider in your user-level ~/.codex/config.toml, with the gateway key in ANTSEED_API_KEY. That works from any machine and gives Codex its own budget and usage log.

When Codex runs on the same computer as a buyer, antseed codex supplies the provider config for one run with Codex -c overrides, points it at the local buyer proxy, and leaves your real CODEX_HOME untouched.

Run Antseed first

Every integration needs an Antseed endpoint: a gateway, best on a small server so every tool on every machine can reach it, or the local buyer proxy (same computer only). One-time setup, a few 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

Recommended: a gateway

ANTSEED_BASE_URLhttps://gateway.example.com/v1
ANTSEED_API_KEYantseed_…
Show as shell exports
export ANTSEED_BASE_URL="https://gateway.example.com/v1" export ANTSEED_API_KEY="antseed_…"

Your gateway's base URL, ending in /v1, and an API key from the Keys page of its console. Recommended: a gateway on a server, which every machine can reach. A gateway on this computer is http://localhost:8379/v1; publish it with a tunnel (antseed tunnel start) for other machines. No gateway yet: see Run Antseed first above. Export both in the shell that starts Codex.

~/.codex/config.toml
model = "@preset/coder" model_provider = "antseed" # Codex doesn't know open model ids; set the model's context length so it compacts in time. model_context_window = 128000 [model_providers.antseed] name = "Antseed gateway" base_url = "https://gateway.example.com/v1" env_key = "ANTSEED_API_KEY" wire_api = "responses"

Set base_url to your gateway URL ending in /v1; Codex reads the key from ANTSEED_API_KEY. @preset/coder is a gateway preset (create one under Presets in the console): with a raw model name, Codex can switch to a tool format some providers drop. A model id from GET /v1/models works too. Provider settings must live in your user-level config; Codex ignores them in a project-local ./.codex/config.toml.

Same computer, no gateway: the local buyer proxy

antseed codex --model deepseek-v4.1-flash

The wrapper resolves the local proxy URL, injects an Antseed model provider with wire_api = "responses", sets a placeholder ANTSEED_API_KEY, and forwards extra Codex args. Put child flags after -- when they look like wrapper flags. To route to a specific peer, prefix the model with its peer id: antseed codex --model <peerId>@deepseek-v4.1-flash.

Step 3

Pick a model

deepseek-v4.1-flashglm-5.3-flashglm-5.2kimi-k3

Set top-level model = "<model-id>" in ~/.codex/config.toml, or override per run with codex --model <model-id>. With the wrapper, pass antseed codex --model <model-id>. Route to a specific peer by prefixing its advertised service id: <peerId>@<service-id>.

The full list is every model on the network. Run GET /v1/models on your endpoint, antseed network browse, or open the live network page to see what's available right now.

Verify

Test it

  • List every model on the network
    curl -s "$ANTSEED_BASE_URL/models" -H "Authorization: Bearer $ANTSEED_API_KEY" | jq '.data[].id'
    Example response
    "deepseek/deepseek-v4.1-flash" "moonshotai/kimi-k3" "z-ai/glm-5.2" "z-ai/glm-5.3-flash"

    Whatever appears here, or the short name without the vendor prefix (deepseek-v4.1-flash), is a valid model value. Against the local buyer proxy: curl -s http://localhost:8377/v1/models.

  • Run Codex
    codex

    Through the local buyer proxy instead: antseed codex --model deepseek-v4.1-flash.

  • Verify inference is actually paid through Antseed
    antseed buyer balance # local buyer proxy only
    What to look for after one real prompt
    Deposits available: 4.289391 USDC → 3.289391 USDC Deposits reserved: 0 USDC → 1 USDC

    On a gateway, the request shows up in the console under Logs, with the seller, tokens and cost. With the local buyer proxy, a non-zero Reserved (channel opened) and/or a drop in Available (settled spend) after a real prompt confirms Antseed served the request. Do not rely on lsof -i | grep codex or ~/.codex/log/codex-tui.log: Codex keeps persistent TCP connections to Cloudflare/ChatGPT IPs for non-inference purposes, and the provider=OpenAI lines in the TUI log are not a reliable indicator that inference went to OpenAI.

How OpenAI Codex CLI talks to Antseed

  • Wire format sent by OpenAI Codex CLI: OpenAI Responses (hits /v1/responses on your gateway or buyer proxy)
  • Best-fit services: any service whose protocols array contains openai-responses. 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 Responses and the service's native protocol on the fly, inside the buyer. So a request from OpenAI Codex CLI can still reach a service that only advertises anthropic-messages - just with a small transform step.

If it goes wrong

Troubleshooting

  • OPENAI_BASE_URL / OPENAI_API_KEY are being ignoredExpected on recent Codex builds. Add the [model_providers.antseed] block above to ~/.codex/config.toml, or use antseed codex --model <model-id> with a local buyer proxy.
  • 401 from the gatewayExport ANTSEED_API_KEY with your gateway key in the shell that starts Codex, and keep env_key = "ANTSEED_API_KEY" in the provider block.
  • How can I tell if Codex is actually routing through Antseed?On a gateway, check Logs in the console after a test prompt. With the local buyer proxy, check antseed buyer balance: Reserved going from $0 to a non-zero value and/or Available dropping confirms Antseed served the request. Do not trust lsof connections to Cloudflare IPs or provider=OpenAI lines in ~/.codex/log/codex-tui.log.
  • Codex prints Ignored unsupported project-local config keys … model_provider, model_providersProvider settings must live in your user-level ~/.codex/config.toml. Codex rejects provider blocks in a project-local ./.codex/config.toml and falls back to its default provider.
  • Tool calls fail or Codex switches tool formats mid-sessionUse a gateway preset as the model (model = "@preset/coder"), as recommended in the gateway API docs.
  • Streaming stops after the first chunkSet wire_api = "responses" in the [model_providers.antseed] block (the wrapper does this for you).
  • Model metadata for … not found. Defaulting to fallback metadataExpected for open model ids. antseed codex sets a context window for you; in ~/.codex/config.toml, set model_context_window to the model's context length.
  • Hangs forever on first messageCheck the endpoint answers: curl -s "$ANTSEED_BASE_URL/models" -H "Authorization: Bearer $ANTSEED_API_KEY". With the local buyer proxy, also check antseed buyer status; if a stale session pin points at an offline peer, clear it with antseed buyer connection clear.

Reference

Links

Same category

Related

Run OpenAI Codex CLI on the open market

Run a gateway, point this tool at it, and pay per request.

All integrationsGateway API