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.

Last checked: · Official reference: Codex: advanced configuration

1. Install Codex CLI

npm (any system):

npm install -g @openai/codex

macOS with Homebrew:

brew install --cask codex

Install script for macOS and Linux:

curl -fsSL https://chatgpt.com/codex/install.sh | sh

Windows PowerShell:

powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"

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 = "gpt-6.2-astra" model_provider = "winkapi" [model_providers.winkapi] name = "WinkAPI" base_url = "https://api.winkapi.net/v1" env_key = "WINKAPI_KEY" wire_api = "responses"

Most errors come from one of these two points:

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):

export WINKAPI_KEY="hg-YOUR-KEY" codex

Windows PowerShell:

$env:WINKAPI_KEY = "hg-YOUR-KEY" codex

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:

codex --model "gpt-6.2-astra"

Common errors and fixes

Message or symptomUsual causeFix
403 with unsupported_country_region_territoryRequests 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 ignoredThe provider keys are in the project's .codex/config.toml.Move that block to your user config.
An error that WINKAPI_KEY is missingThe variable is not set in the terminal that started Codex.Set it and open Codex in the same terminal.
401 invalid_api_keyThe key is wrong or revoked.Copy the key from the dashboard again.
404 model_not_foundThe model ID is wrong or the model is inactive.Copy an ID from the table below.
429 insufficient_quotaYour credit has run out.Top up in the dashboard.

GPT models you can use

ChatGPT (OpenAI) API pricing, per million tokens
ModelInput $/1MOutput $/1M
gpt-6.2-solGPT-6.2 Sol2.0010.00
gpt-6.2-astraGPT-6.2 Astra8.0040.00
gpt-6.1-solGPT-6.1 Sol2.0010.00
gpt-6.1-terraGPT-6.1 Terra1.005.00
gpt-6-astraGPT-6 Astra10.0050.00
gpt-6-solGPT-6 Sol2.0010.00
gpt-6-lunaGPT-6 Luna0.100.50
gpt-5.6-solGPT-5.6 Sol4.0020.00
gpt-5.6-terraGPT-5.6 Terra2.0012.00
gpt-5.6-lunaGPT-5.6 Luna0.201.20
gpt-image-2.6-flareGPT Image 2.6 Flare5.0030.00
gpt-image-2.6-sunburstGPT Image 2.6 Sunburst5.0030.00
gpt-image-2.5-flareGPT Image 2.5 Flare5.0030.00
gpt-image-2.5-sunburstGPT Image 2.5 Sunburst5.0030.00

For Claude Code, see the Claude Code setup guide. Cline, OpenCode and other tools are covered in the documentation.