Skip to main content
Corvex Token Factory exposes an OpenAI Responses API endpoint, which is the protocol Codex requires from a custom model provider. Add Token Factory as a provider in ~/.codex/config.toml, describe its models in a model catalog file so Codex knows their real context windows, and select a model. The Codex CLI and the Codex IDE extension read the same configuration. Verified with Codex 0.162.1, October 2026.

Prerequisites

Context window and compaction

Codex treats a model ID it doesn’t know as a 272,000-token model, and model_context_window cannot raise that ceiling. A model catalog file (model_catalog_json) gives Codex each model’s real window. Codex does not send max_output_tokens, so it reserves no output room of its own (max_tokens = 0 in the formula below). Its default compaction point is 90% of the window. A single turn with large tool results can push the context past the compaction point before compaction runs, so leave about 15% headroom: set model_auto_compact_token_limit to (context_window − max_tokens) / 1.15, rounded down: Codex counts 95% of the window as usable (373,555 tokens for a 393,216-token window); after the first turn, /status shows that usable window. GET /v1/models reports each model’s current context_window and max_output_tokens.
1

Store the key in your shell

Codex reads the API key from the environment variable named by env_key. Export it in your shell profile so both the CLI and the IDE extension can read it.
2

Create the model catalog

Build the catalog from Codex’s bundled one, so the Token Factory models keep Codex’s standard instructions. The command writes ~/.codex/token-factory-models.json:
create-catalog.sh
The catalog replaces Codex’s built-in model list, so it lists only Token Factory models.
3

Add the provider to config.toml

Create or edit ~/.codex/config.toml:
config.toml
Enter the model ID exactly as the catalog lists it, including the namespace/ prefix. Do not add a corvex/ prefix.
4

Add a profile for each other model

The compaction limit is per model, so keep one profile file per model next to config.toml. Codex layers ~/.codex/<name>.config.toml on top of config.toml when you pass --profile <name>:
deepseek.config.toml
5

Run Codex

To run a single task non-interactively:
6

Verify the connection

Ask Codex to read a file in the repository, then run /status. It shows Corvex Token Factory, the model ID, and a usable window of 95% of the model’s context window. A window of 258,400 means Codex did not load the catalog; check the model_catalog_json path.

How Token Factory serves the Responses API

POST /v1/responses accepts the Codex request shape, including instructions, input items, tools, tool_choice, max_output_tokens, temperature, and stream. The gateway translates each request to the model’s Chat Completions interface and returns Responses-shaped output, with streaming events in the Responses event order. The model’s reasoning is returned as a reasoning output item ahead of the message item. Conversation persistence is not exposed: store and previous_response_id have no effect, and there is no /v1/conversations endpoint. Codex resends the full conversation on each turn, so this does not affect normal use. Request fields that control OpenAI-hosted reasoning (reasoning, include) are accepted and ignored; the model reasons with its default settings. See the API reference for the documented request and response fields.

Compatibility notes

  • Context length. If a session exceeds the model’s window, the gateway returns context_length_exceeded. Run /compact in Codex, or start a new session. See Errors.
  • Output budget. Reasoning tokens count toward the output budget. If a response is truncated, shorten the prompt or split the task.
  • Input types. Neither model accepts image input. Do not attach images with -i; the request returns a structured error.
  • Use the OpenAI SDK — Chat Completions from Python or TypeScript.
  • Connect OpenCode — another terminal coding agent on the OpenAI-compatible surface.
  • Errors — authentication, rate-limit, and validation responses.
Last modified on October 23, 2026