Set up Codex CLI with a custom provider
Codex CLI is OpenAI's terminal coding assistant. One provider entry in your user config connects it to a WinkAPI key, and usage is paid from your prepaid credit, with no ChatGPT account or OpenAI key. This guide covers installation, config.toml, the key and the errors people hit most.
1. Install Codex CLI
npm (any system):
macOS with Homebrew:
Install script for macOS and Linux:
Windows PowerShell:
If you installed with npm, update with npm install -g @openai/codex@latest.
2. Add WinkAPI to config.toml
Open ~/.codex/config.toml (on Windows %USERPROFILE%\.codex\config.toml; create it if it does not exist) and add:
model_providertells Codex to send requests to the provider with the IDwinkapi.env_keyis the name of the environment variable that holds the key; do not write the key itself in this file.wire_api = "responses"means Codex uses the Responses API, which WinkAPI serves at/v1/responses.
Most errors come from one of these two points:
- Put this in your user config only. Codex ignores
model_provider,model_providersandopenai_base_urlin a project's.codex/config.toml. - IDs such as
openai,ollamaandlmstudioare reserved and cannot be redefined, which is why the provider is calledwinkapi.
3. Set the key
Create a key under API keys in the dashboard and put it in the WINKAPI_KEY variable. Then run codex in the same terminal.
macOS and Linux (to keep it, add the first line to ~/.bashrc or ~/.zshrc):
Windows PowerShell:
To keep it on Windows, run setx WINKAPI_KEY "hg-YOUR-KEY" once and open a new terminal.
4. Check the connection and change models
Run /status in Codex to see the session's settings and active model. Then send a short message and confirm the request appears in your WinkAPI dashboard usage. To run Codex with another model, change model in the file or pass the ID with --model:
Common errors and fixes
| Message or symptom | Usual cause | Fix |
|---|---|---|
403 with unsupported_country_region_territory | Requests still go straight to OpenAI: the provider is in a project file, the model_provider line is missing, or Codex is signed in with ChatGPT. | Move the settings to ~/.codex/config.toml; see the guide to this error |
| A warning at startup that settings were ignored | The provider keys are in the project's .codex/config.toml. | Move that block to your user config. |
An error that WINKAPI_KEY is missing | The variable is not set in the terminal that started Codex. | Set it and open Codex in the same terminal. |
401 invalid_api_key | The key is wrong or revoked. | Copy the key from the dashboard again. |
404 model_not_found | The model ID is wrong or the model is inactive. | Copy an ID from the table below. |
429 insufficient_quota | Your credit has run out. | Top up in the dashboard. |
GPT models you can use
| Model | Input $/1M | Output $/1M |
|---|---|---|
gpt-6.2-solGPT-6.2 Sol | 2.00 | 10.00 |
gpt-6.2-astraGPT-6.2 Astra | 8.00 | 40.00 |
gpt-6.1-solGPT-6.1 Sol | 2.00 | 10.00 |
gpt-6.1-terraGPT-6.1 Terra | 1.00 | 5.00 |
gpt-6-astraGPT-6 Astra | 10.00 | 50.00 |
gpt-6-solGPT-6 Sol | 2.00 | 10.00 |
gpt-6-lunaGPT-6 Luna | 0.10 | 0.50 |
gpt-5.6-solGPT-5.6 Sol | 4.00 | 20.00 |
gpt-5.6-terraGPT-5.6 Terra | 2.00 | 12.00 |
gpt-5.6-lunaGPT-5.6 Luna | 0.20 | 1.20 |
gpt-image-2.6-flareGPT Image 2.6 Flare | 5.00 | 30.00 |
gpt-image-2.6-sunburstGPT Image 2.6 Sunburst | 5.00 | 30.00 |
gpt-image-2.5-flareGPT Image 2.5 Flare | 5.00 | 30.00 |
gpt-image-2.5-sunburstGPT Image 2.5 Sunburst | 5.00 | 30.00 |
For Claude Code, see the Claude Code setup guide. Cline, OpenCode and other tools are covered in the documentation.