Configure Codex
Codex CLI connects to InOneAPI through the OpenAI Responses protocol. After setup, Codex still reads and edits code locally, while model requests go to InOneAPI and the gateway selects an available provider for the chosen public model according to the routing strategy.
Before you start
- Create a project and an API key in the console, and restrict the models it may call and its budget.
- Copy the model ID from the model detail page exactly as shown.
YOUR_MODEL_IDis only a placeholder in this document. - Install the Codex CLI and confirm that
codexruns in your terminal.
Do not write a real key into config.toml. The configuration file should only reference an environment variable.
Configure the model provider
Create or open ~/.codex/config.toml and merge the following into your existing configuration:
model = "YOUR_MODEL_ID"
model_provider = "inoneapi"
[model_providers.inoneapi]
name = "InOneAPI"
base_url = "https://api.inoneapi.com/v1"
env_key = "INONEAPI_API_KEY"
wire_api = "responses"
Root fields model and model_provider must come before the first [table]. If they already exist, update their values instead of appending duplicates. When CODEX_HOME is set, the configuration lives in that directory.
wire_api must be responses. Copy the model ID exactly; the display name alone does not work.
Set the API key
macOS or Linux:
export INONEAPI_API_KEY="ioa_sk_..."
codex
To keep it long-term, add the export line to ~/.zshrc or ~/.bashrc, then reopen the terminal. Windows PowerShell:
[Environment]::SetEnvironmentVariable("INONEAPI_API_KEY", "ioa_sk_...", "User")
Reopen PowerShell after setting it.
Verify the configuration
Start Codex in a test repository and run a read-only task first:
Read the README and summarize how to start the project. Do not modify any files.
Then check the InOneAPI console for the matching request, model ID and X-Gateway-Trace-ID. During the first verification, do not grant high-risk command permissions.
Common issues
401: the current terminal did not readINONEAPI_API_KEY, or the key has been revoked.404:base_urlis missing/v1, or the model ID does not exist.- Responses parameter error: confirm
wire_api = "responses"and select a model that supports Responses and tool calling. 402: check balance and budget;429: check rate limits and upstream capacity. Do not let the agent retry without a limit.
For production use, create a dedicated sub-key for Codex and set its budget, model restrictions and alerts. See Team keys and usage.
Optional: import into CC Switch
On the model detail page, select this tool and an API key, then click “Open CC Switch and import”. Use the official CC Switch release; the import link already contains the current model ID, so you do not need to enter it again. After confirming the import, finish the connection by enabling the provider and setting the default model for this tool. If it reports that this app is unsupported, update CC Switch or follow the manual steps in this document.
The import link only adds a provider. It does not mean the model is already the default or that a request succeeded. The link contains an API key, so do not share it. Use either the manual setup or the CC Switch import, not both.
Official reference: Codex configuration options.