NNexithDocs
StatusDashboard ↗
Overview & quickstartModel catalogGuidesAPI referenceIntegrationsOAuth2 / OIDC

Using Nexith with Codex CLI

The new Codex only speaks the OpenAI Responses protocol (POST /v1/responses). The Nexith gateway has this adapter: it recognizes Codex by request shape, internally translates the request into the chat pipeline for execution, and translates the result back into Responses shape — routing, billing, egress scrubbing, and other protocols all share one path.

Configuration#

Add to ~/.codex/config.toml:

model = "nexith-core"
model_provider = "nexith"

[model_providers.nexith]
name = "Nexith"
base_url = "https://gateway.nexith.ai/v1"
env_key = "NEXITH_API_KEY"
wire_api = "responses"

Then:

export NEXITH_API_KEY="nx-你的key"
codex

base_url must include /v1 (Codex appends /responses after it). This is the opposite of Anthropic clients, so don't mix them up. api.nexith.ai/v1 also works.

Supported endpoints#

Endpoint Purpose
POST /v1/responses Codex's main path; supports streaming and function_call
POST /v1/chat/completions Used when wire_api is set to chat
GET /v1/models Model list

Tool calling (apply_patch, etc.)#

Verified points:

  • Request side: function_call items → the assistant's tool_calls; function_call_output → a tool role message. call_id is preserved throughout as tool_call_id, so pairs are never scrambled.
  • Response side: upstream tool_calls → function_call items in output, with arguments kept as strings (Codex consumes strings; no object round trip).
  • Streaming: argument slices are forwarded as they arrive from the upstream; after concatenation they match the upstream exactly.

Known limitation: built-in tools in Responses requests whose type is not function (such as Codex's own local_shell, web_search) are currently dropped and not forwarded upstream. When using Codex, prefer custom function tools.

Billing and long tasks#

  • 120-second limit per request (currently); a single turn of a very long agent loop is truncated if it exceeds it — being worked on.
  • nexith-core requests over 32k context are automatically escalated to a stronger upstream and billed at the escalated tier.

Troubleshooting#

upstream rejected / 400 Usually incomplete tool-call pairing in the history. The gateway performs an adjacency repair at the entrance (inserting placeholders or dropping orphans), but the real fix is for the client to guarantee that function_call and function_call_output come in pairs.

408 / reconnects Upstream timeout. If a particular upstream is frequently slow, the gateway fails over; if this keeps happening, report the specific task type.

401 The environment variable pointed to by env_key is not set, or the key does not start with nx-.