Codex Integration
Codex is an agentic coding assistant from OpenAI that communicates via the Responses API and supports custom providers configured in ~/.codex/config.toml.
Prerequisites
Section titled “Prerequisites”- Install Environment: Install Codex CLI (
npm install -g @openai/codex) and run it at least once to initialize the~/.codexdirectory. - Obtain API Key: Go to AlphaTech Sign Up & API Keys to generate your API Key (
sk-xxxx). - Verify Models: Review Models and pricing to choose an active model compatible with Responses API (e.g.
gpt-6-luna,gpt-5.6-luna, ordeepseek-v4.1-flash).
Configuration Steps
Section titled “Configuration Steps”1. Edit config.toml
Section titled “1. Edit config.toml”Open the configuration file at ~/.codex/config.toml (located at %USERPROFILE%\.codex\config.toml on Windows):
model = "gpt-6-luna"model_provider = "alphatech"model_reasoning_effort = "high"
[model_providers.alphatech]name = "AlphaTech"base_url = "https://alphatech.net.cn/v1"wire_api = "responses"experimental_bearer_token = "sk-xxxx"Menu / Path Reference: Navigate to your home directory, reveal the hidden
.codex/folder, and editconfig.tomlwith any text editor.
2. Environment Variable Authentication (Optional)
Section titled “2. Environment Variable Authentication (Optional)”If you prefer not storing your key in plaintext within config.toml, replace experimental_bearer_token with env_key:
[model_providers.alphatech]name = "AlphaTech"base_url = "https://alphatech.net.cn/v1"wire_api = "responses"env_key = "ALPHATECH_API_KEY"Then export the key in your terminal:
export ALPHATECH_API_KEY="sk-xxxx"3. Launch Codex
Section titled “3. Launch Codex”Navigate to your workspace directory and run:
cd /path/to/your-projectcodexVerifying the Setup
Section titled “Verifying the Setup”- Check the startup status in Codex. It should display model
gpt-6-lunaunder provideralphatech. - Issue a sample instruction:
Write a Bash script to inspect local port usage and print corresponding process names.- If Codex generates the plan and streams the implementation, and AlphaTech console logs show requests to
/v1/responses, configuration is successful.
Troubleshooting
Section titled “Troubleshooting”1. wire_api = "chat" is no longer supported error
Section titled “1. wire_api = "chat" is no longer supported error”Codex no longer supports legacy Chat Completions format. Ensure your provider section explicitly states wire_api = "responses".
2. 404 Not Found or HTML responses
Section titled “2. 404 Not Found or HTML responses”This happens if the Base URL lacks /v1. Setting https://alphatech.net.cn causes Codex to request https://alphatech.net.cn/responses, which falls back to the frontend SPA instead of the API gateway. Always use https://alphatech.net.cn/v1.
3. 401 Unauthorized
Section titled “3. 401 Unauthorized”Check that experimental_bearer_token has no typos or missing characters. If using env_key, confirm echo $ALPHATECH_API_KEY prints your key in the active shell.
Reference: OpenAI Codex Documentation
Last verified on 2026-11-04