Codex CLI Configuration
Codex CLI is Codex in the terminal. It is suitable for letting Codex read code, modify files, run tests, and explain errors in local projects. The desktop client's settings are on the Codex client page; this section specifically covers the terminal CLI.
What this tool is and what it is used for
Configuration File Location
| system | Example Path | Description |
|---|---|---|
| Windows | C: \Users\YourUsername\. codex\config.toml | Change the username to your own computer's username |
| macOS / Linux | ~/. codex/config.toml | If there is no file, create a new config.toml |
How to write a custom Provider
If you are only using the official account, follow the official login process first. Only add a custom provider when the provider explicitly offers Codex / OpenAI compatible configurations.
codex login codex "Please reply only: Configuration successful" model = "MODEL_ID_FROM_PROVIDER_DASHBOARD" model_provider = "mz_proxy" [model_providers.mz_proxy] name = "Example AI Provider" base_url = "https://YOUR_PROVIDER_API_URL" env_key = "MZ_PROXY_API_KEY" wire_api = "responses" | Setting | How to Fill | Attention |
|---|---|---|
| model | Model ID / Model Name in the provider Backend Model List | Do not fill in a display name you came up with yourself, and do not change the case, hyphens, or dots |
| model_provider | The name of the Provider below | must be consistent with [model_providers.xxx] the xxx in the |
| base_url | API address provided by the provider backend | Decide whether to include it according to the backend example /v1 |
| env_key | Local environment variable name | Write the variable name here, do not write the Key directly |
| wire_api | Interface protocol | Select according to the official Codex documentation and the provider's instructions |
Key and testing
The above env_key is just the variable name, the actual Key should be placed in the local environment variable. Set it temporarily for testing first, and after confirming success, consider saving it long-term.
$env:MZ_PROXY_API_KEY = "YOUR_KEY" codex "Please reply only: Configuration successful" MZ_PROXY_API_KEY="YOUR_KEY" codex "Please reply only: Configuration successful" In TOML model and model_provider Place it at the beginning of the file; do not append it under the [model_providers.xxx] section.
