Guides / How to connect a Codex key

How to connect a Codex key: Codex CLI and IDEs

A key with a token limit for OpenAI's Codex. Plugs into Codex CLI, the VS Code extension or any app that speaks the OpenAI API.

5 minutes · read

1. What's in the order

Keep the key like a password: anyone with it can spend your limit.

2. Install Codex CLI

You need Node.js 18 or newer. In a terminal:

npm install -g @openai/codex

3. Put the key in

macOS and Linux:

echo 'export OPENAI_API_KEY="your-key"' >> ~/.zshrc
source ~/.zshrc

Windows (PowerShell):

setx OPENAI_API_KEY "your-key"

After setx, open the terminal again.

4. If the order has an API address

Open ~/.codex/config.toml (on Windows %USERPROFILE%\.codex\config.toml; no file or folder, create it) and add:

model_provider = "apex"

[model_providers.apex]
name = "Apex"
base_url = "address-from-the-order"
env_key = "OPENAI_API_KEY"

No address in the order, skip this step.

5. Run it

Open a terminal in your project folder and run codex. If Codex offers to sign in with ChatGPT, pick the API key option. Give it a task, like "explain what this project does".

The Codex extension for VS Code and Cursor uses the same setup: the key from OPENAI_API_KEY and the provider from config.toml.

Warranty

The warranty term is in the product description (usually 1–2 days). If the key stops working within it, write to support with the order number and we replace the key. A used-up limit isn't a warranty case. Check the key as soon as you get it.

Errors and what to do

Still stuck, write to support @Volarchik: the order number and the error text.

Products this guide is for

API 10M Token Codex · 1 day warranty$2.50API 50M Token Codex · 2 days warranty$4.50

Other guides

How to buy: balance, payment, deliveryHow to sign in to a ready ChatGPT Plus accountRenewing a plan on your own account: ChatGPT, Claude, GrokHow to connect a Claude API key: Claude Code, Cursor, your own codeHow to sign in to a ready Grok accountHow to activate Google AI Pro (Gemini) with a linkCHow to sign in to a CapCut Pro account