Skip to main content

ChatGPT Codex with UniKey on Windows

Codex is now part of the ChatGPT product experience. On Windows, install the ChatGPT desktop app for the visual project/task experience, and install the Codex CLI when you want to run Codex from PowerShell.

This guide configures Codex CLI to use UniKey through the OpenAI-compatible API.

Base URL: https://www.getunikey.ai/v1
API key: your UniKey API key
Model: gpt-5.4, gpt-5.4-mini, or another model available in UniKey

1. Install ChatGPT and Codex

ChatGPT desktop app

Install the official ChatGPT desktop app from the ChatGPT download page, or install it from Microsoft Store with winget:

winget install --id 9PLM9XGG6VKS -s msstore

The desktop app is useful for project views, local files, longer tasks, and switching between ChatGPT and Codex work.

Codex CLI

Open PowerShell and run:

irm https://chatgpt.com/codex/install.ps1 | iex

Close and reopen PowerShell, then verify:

codex --version

If codex is not found, restart PowerShell once. If it still fails, check whether the installer directory was added to your user PATH.

2. Create a UniKey API key

  1. Open https://www.getunikey.ai/.
  2. Log in.
  3. Open the API key or token page.
  4. Create a new API key.
  5. Store it privately.

Never commit or share the key. In the examples below, replace sk-... with your own key.

This is the clearest setup for most users: the secret is saved as a Windows user environment variable, and Codex reads provider settings from %USERPROFILE%\.codex\config.toml.

Set the API key

Run this in PowerShell:

[Environment]::SetEnvironmentVariable("UNIKEY_API_KEY", "sk-...", "User")

Close and reopen PowerShell, then confirm:

$env:UNIKEY_API_KEY

If it prints nothing, the current PowerShell window did not reload the user environment. Open a new PowerShell window and try again.

Edit config.toml

Create the Codex folder and open the config file:

New-Item -ItemType Directory -Force "$env:USERPROFILE\.codex"
notepad "$env:USERPROFILE\.codex\config.toml"

Add or update this block:

model = "gpt-5.4"
model_provider = "unikey"

[model_providers.unikey]
name = "UniKey"
base_url = "https://www.getunikey.ai/v1"
env_key = "UNIKEY_API_KEY"
wire_api = "responses"

Save the file, then start Codex:

codex

Ask:

Reply with one sentence confirming Codex is using UniKey.

4. Optional file method: config.toml and auth.json

Codex keeps user configuration in:

C:\Users\<your-name>\.codex\config.toml

When file-based credential storage is enabled, login credentials can also live in:

C:\Users\<your-name>\.codex\auth.json

For UniKey, prefer the config.toml + UNIKEY_API_KEY environment variable method above. It avoids putting the UniKey secret directly in config.toml and avoids manually editing auth.json.

Only touch auth.json if you are intentionally managing Codex login credentials and have made a backup first:

Copy-Item "$env:USERPROFILE\.codex\auth.json" "$env:USERPROFILE\.codex\auth.json.bak"

If auth.json becomes invalid, restore the backup or run:

codex logout

Then sign in again. Do not paste auth.json into support tickets, screenshots, or public chats.

5. Verify UniKey before debugging Codex

Run:

curl.exe https://www.getunikey.ai/v1/models `
-H "Authorization: Bearer $env:UNIKEY_API_KEY"

If this returns a model list, your UniKey key and base URL are working.

Common issues

ProblemFix
codex command not foundRestart PowerShell. Confirm the Codex install directory is in your user PATH.
$env:UNIKEY_API_KEY is emptyOpen a new PowerShell window after setting the user environment variable.
401 unauthorizedThe key is missing, expired, copied incorrectly, or has extra spaces.
404 model not foundChange model in config.toml to a model your UniKey account can use.
Config changes do not applyConfirm the file is %USERPROFILE%\.codex\config.toml, then restart Codex.
PowerShell blocks a scriptStart PowerShell normally, not from a restricted corporate shell, or ask your device admin about execution policy.
Desktop app and CLI behave differentlyThe ChatGPT desktop app and Codex CLI can ship different Codex versions. Check codex --version and restart the desktop app after config changes.
Network or TLS errorsTry the /v1/models curl test first. If curl fails too, check network, proxy, VPN, and certificate settings before changing Codex.