Connect Codex CLI
This guide is for Codex CLI versions supporting custom providers and Responses. The desktop app, editor extension, or an organization-managed environment may use different configuration entry points; check your installed version.
1. Prepare a key and model
Jump to 1. Prepare a key and modelCreate an API key, then get a model ID supporting Responses and tool calling from the model catalog. Availability and capabilities depend on your account and service configuration.
2. Set an environment variable
Jump to 2. Set an environment variableReplace the placeholder with your key.
Bash or Zsh:
export KEENKIND_API_KEY='YOUR_KEENKIND_API_KEY'$env:KEENKIND_API_KEY = 'YOUR_KEENKIND_API_KEY'These values apply only to this terminal and programs launched from it. Start Codex from this terminal after the next step. Set the variable again in a new terminal.
3. Configure the provider
Jump to 3. Configure the providerBack up your user configuration file, then edit:
- macOS / Linux:
~/.codex/config.toml - Windows:
.codex\config.tomlin your user directory.
Merge this configuration with existing settings. Put model and model_provider before the first [table] header. Update existing keys instead of duplicating them. Replace YOUR_MODEL_ID with an actual model ID.
model = "YOUR_MODEL_ID"model_provider = "keenkind"
[model_providers.keenkind]name = "KeenKind"base_url = "https://api.keenkind.ai/v1"env_key = "KEENKIND_API_KEY"wire_api = "responses"request_max_retries = 0stream_max_retries = 0The example keeps the key in the environment and disables automatic retries to make initial requests easier to verify. Put provider and model settings in the user configuration. Current Codex does not load provider configuration from a project’s .codex/config.toml.
4. Start and verify
Jump to 4. Start and verifyFrom your project directory in the same terminal, run:
codexCheck that the displayed model matches your ID. Ask it to read the README and explain how to start the project. Verify file access and check the request in usage records.
Troubleshooting
Jump to Troubleshooting| Symptom | Check first |
|---|---|
| Missing environment variable | Start Codex in the terminal where the key was set. |
| Old provider or model still selected | Check user configuration and overrides from other settings or launch arguments. |
| 404 | Model ID, base URL, and duplicated /v1/v1. |
| Answers work but tools fail | Model tool support and permission to read the project. |
| Incomplete result after interruption | Check usage, then follow API troubleshooting. |
Configuration fields follow Codex advanced configuration and the configuration reference. Sources checked: 2026-10-18.