Codex CLI
Configure OpenAI Codex CLI to use the Model Gate Responses endpoint.
No current prepared translation is available. The English source is shown without machine translation.
Codex CLI through Model Gate
Codex uses the OpenAI Responses protocol. Its provider base_url includes /v1.
1. Install Codex
npm install -g @openai/codex
codex --version
Check the current official installation instructions at https://developers.openai.com/codex/.
2. Configure the provider
Edit:
- Linux or macOS:
~/.codex/config.toml - Windows:
%USERPROFILE%\.codex\config.toml
model = "gpt-5.4"
model_provider = "model_gate"
model_reasoning_effort = "high"
[model_providers.model_gate]
name = "Model Gate"
base_url = "https://api.model-gate.com/v1"
wire_api = "responses"
env_key = "MODEL_GATE_API_KEY"
wire_api = "responses" sends requests to /v1/responses.
3. Set the API key
Linux or macOS
export MODEL_GATE_API_KEY="mg_live_..."
To make it permanent, add the export to your shell profile or secret manager.
Windows PowerShell
[Environment]::SetEnvironmentVariable(
"MODEL_GATE_API_KEY",
"mg_live_...",
"User"
)
Open a new terminal after setting a persistent variable.
4. Start Codex
codex
Reasoning effort
model_reasoning_effort = "low"
low: faster and shorter.medium: balanced.high: more thorough for complex work.
The upstream model must support the requested reasoning controls.
Troubleshooting
| Problem | Resolution |
|---|---|
| Authentication error | Confirm MODEL_GATE_API_KEY is visible in the same terminal. |
| Codex uses OpenAI directly | Confirm model_provider = "model_gate" and the provider section name matches. |
| Unsupported endpoint | Confirm wire_api = "responses" and base_url ends with /v1. |
| Model not found | Query /v1/models for a canonical ID, or use an enabled alias confirmed by your administrator. |
Do not set requires_openai_auth = true for this provider: that option selects OpenAI account authentication instead of the custom env_key.