Let my agent set this up
Copy this task to an agent already running on your computer:How the connection works
OpenCodex is a local proxy between Codex and model APIs. This guide uses OpenCodex 2.73.0 and Codex CLI 0.149.0. The TokenLab preset’s Chat Completions integration was released and verified end to end in 2.72.0. Version 2.73.0 keeps that integration and adds model-specific Responses and Anthropic Messages routing. The routes listed below have been checked against TokenLab with streamed text and function-call/result round trips. Codex sends Responses requests to the local OpenCodex proxy. OpenCodex then sends the selected model’s request to TokenLab. A Responses request on the local connection does not mean that the model is called through TokenLab’s Responses API.
The preset’s Base URL is
https://api.tokenlab.sh/v1. Keep it unchanged: OpenCodex builds the matching Messages or Responses URL itself. Models outside the listed Responses defaults and Claude routing use the preset’s Chat adapter.
TokenLab supports Gemini’s native API for models that declare it, but the OpenCodex 2.73.0 TokenLab preset calls Gemini through Chat Completions. Do not change the entire provider to Responses or Gemini; that would also change requests for models that do not accept that format.
Install or update
Use Node.js 18 or later for the npm installation:Add TokenLab
Create a key in TokenLab API Keys. For terminal setup, follow Quickstart to setTOKENLAB_API_KEY without putting its value in command history. Start OpenCodex from that terminal; a background service needs the variable in its own launch environment.
For a fresh OpenCodex installation, run ocx init, select TokenLab, and enter the key locally or use the literal environment reference ${TOKENLAB_API_KEY}. Review the wizard’s Codex connection and autostart choices before applying them.
For an existing installation, add the preset without replacing other providers:
tokenlab already exists, edit that provider in the dashboard instead of overwriting it with --force.
You can also choose TokenLab in the dashboard’s Add provider list and enter the key there. OpenCodex saves its configuration under $OPENCODEX_HOME/config.json, normally ~/.opencodex/config.json.
Start the proxy if it is not already running, then open its dashboard:
GET /v1/models?category=chat and keeps models with tool-use capability. Images, video, audio, embeddings, and decision models are excluded. Discovery with a key reflects that key’s model permissions and delivery policy.
Run ocx sync to connect Codex and refresh its model catalog, then start a new Codex session. This changes Codex’s proxy connection and catalog; review existing custom-provider settings and keep a backup before syncing. It does not require replacing your account or permission policy.
Select a model and verify a request
Choose thetokenlab/<model-id> entry in Codex’s model picker, or select it for one CLI launch:
tokenlab/ to select the provider; the model ID sent to TokenLab is gpt-6.1-sol. Choose an exact currently available ID from Models.
For a small connection check, send:
Keep a Responses model on Chat Completions
To use the Chat path for one of the listed Responses models, merge amodelAdapters entry into the existing providers.tokenlab object in OpenCodex’s configuration. This example keeps gpt-6-astra on Chat for Codex:
Delivery policy and other TokenLab tools
The preset does not force anX-TokenLab-Delivery-Policy header. TokenLab uses your API key’s delivery-policy default. Choosing Chat, Responses, or Messages is separate from choosing a delivery policy; see TokenLab provider settings.
Add the TokenLab MCP server for other API tools, or TokenLab Skills for integration instructions. These do not change the main model’s provider or API format.
JEV Auto in OpenCodex 2.73.0 uses TypeSafe’s decision backend. It does not offer TokenLab as that backend. Calling TokenLab’s System One API through MCP is a separate operation; do not put a TokenLab key in the TypeSafe credential field.
Troubleshooting and restoring your setup
- TokenLab is missing from the picker: check
ocx --version; this guide targets 2.73.0. Refresh the catalog withocx syncand start a new Codex session. - 401 or missing credentials: check the key is active and available to the process running OpenCodex. An environment variable in a different terminal does not update an already running service.
- Model is missing: check the exact ID, your key’s permissions, and current availability. Non-chat models and chat models without
tool-useare not included in this preset. - Unsupported request or wrong endpoint: compare the selected model with the routing table and inspect saved adapter overrides. The required format is
tokenlab.accepted_request_formatsin model details; the model list is not a substitute for that detail field. Claude and Gemini must not be sent to Responses merely because Codex uses Responses locally. - Tools or image input fail: keep the original error and Request ID. Check the model’s capabilities and the active OpenCodex route before changing settings; do not remove conversation history or tool results to hide an error.
ocx stop; OpenCodex stops the proxy and restores the native Codex connection. ocx restore restores the native connection while keeping the proxy running for other clients. Review the OpenCodex CLI reference before changing an installation shared by other clients.