Codex CLI Integration
Configuration method for integrating OpenAI Codex CLI with 1折AI (model_providers in ~/.codex/config.toml), calling GPT models via the Responses API.
OpenAI / GPT models are now live. Codex CLI uses the OpenAI Responses API (/v1/responses) and connects using the API key from this site. For available models and pricing, see the model catalog.
First, let’s clarify how to configure a custom provider for Codex. The format comes from the official Codex configuration documentation.
Configuration File
Section titled “Configuration File”Codex’s configuration lives in ~/.codex/config.toml. Custom providers can only be written in this user-level file; the .codex/config.toml setting model_provider in a project will be ignored.
model_provider = "onezhe"model = "gpt-6-astra"
[model_providers.onezhe]name = "1折AI"base_url = "https://1zheai.com/v1"env_key = "ONEZHE_API_KEY"wire_api = "responses"The example uses gpt-6-astra, which can be replaced with any other GPT model ID supported by your key.
Meaning of each field:
| Field | Description |
|---|---|
model_provider | Which provider to use, corresponding to the id under [model_providers.<id>] below. openai, ollama, lmstudio are reserved names and cannot be used |
base_url | Must include /v1 |
env_key | Codex reads the API key from this environment variable; the name must exactly match what you export |
wire_api | The official documentation states that currently only responses is supported; it is also the default when omitted |
Then put the API key into an environment variable:
export ONEZHE_API_KEY="sk-你的Key"[Environment]::SetEnvironmentVariable("ONEZHE_API_KEY", "sk-你的Key", "User")Installing Codex
Section titled “Installing Codex”The following commands come from the official Codex documentation:
npm install -g @openai/codexbrew install --cask codexcurl -fsSL https://chatgpt.com/codex/install.sh | shpowershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"401?
The variable name in env_key does not match what you actually exported, or you opened the terminal before setting the environment variable. Double-check the names on both sides, then reopen the terminal and try again.
Can I change wire_api to chat?
No. The official Codex configuration documentation states that wire_api only accepts responses. Services that only provide a Chat Completions API need an additional protocol conversion tool to connect to Codex.
How do I choose a GPT model?
Check the current models in the model catalog and fill the model ID into model. After starting Codex, make a short request and verify the model and status in the call log.
