Codex API Redeem and Setup Guide

Redeem a Codex API code, create a key, edit config.toml and connect Codex CLI, Cursor or VS Code, with models and quota checks.

What this guide covers

This guide covers the Codex API 10M / 50M / 100M token packs. They are valid for 1 / 2 / 3 days, counted from redemption. The endpoint is OpenAI-compatible and works with Codex CLI, Cursor, the Cline or Roo Code extension for VS Code, 9router and your own scripts.

Before you start

Copy the redeem code from your order details.

Make sure Node.js 18 or later is installed: node -v prints a version. Codex CLI installs through npm.

Step 1 — redeem the code

Open paste the code and redeem. Success looks like: an active plan, remaining tokens and an expiry date.

If the code is rejected, check for extra spaces and for letter O vs digit 0, then compare it with your order. If it still fails, contact support. Do not keep resubmitting.

Step 2 — create an API key

Open

Pick your tool in the App dropdown, such as Codex CLI, and a model in the model dropdown, such as gpt-5.6-sol.

Click generate and copy the sk- key and the config text shown on the page. Save both; you need the config text next.

Step 3 — configure Codex CLI

Open or create the config file: ~/.codex/config.toml on macOS / Linux, C:\Users\<you>\.codex\config.toml on Windows.

Paste the config text. The minimal version looks like this; you can rename the env_key variable:

model = "gpt-5.6-sol"

model_provider = "custom"

[model_providers.custom]

name = "custom"

base_url = "

env_key = "CODEX_API_KEY"

wire_api = "responses"

Put the key in an environment variable with that name:

macOS / Linux: export CODEX_API_KEY="sk-your-key"

PowerShell: $env:CODEX_API_KEY="sk-your-key"

To keep it, add the line to ~/.zshrc / ~/.bashrc or your system environment.

No environment variable? Replace the env_key line with experimental_bearer_token = "sk-your-key". The key is then stored in plain text, so never commit that file.

Run codex in a project and ask it to list the files in the current folder. A normal answer means you are connected.

Errors: 401 usually means a wrong key or an unloaded variable, so open a new terminal; 404 means base_url has a missing or extra /v1; model not found means the model does not match your plan, so copy it again from the config page.

Step 4 — Cursor / VS Code / 9router

Cursor

Settings → Models, expand OpenAI API Key.

Enter the sk-... key, turn on Override OpenAI Base URL and set

Add the model name by hand, such as gpt-5.6-sol, select it and send a test message.

VS Code + Cline / Roo Code

Install the extension, open its settings and set API Provider to OpenAI Compatible.

Base URL: API key: sk-....

Model ID: gpt-5.6-sol or another listed model. Save and test.

9router

Provider → Add OpenAI Compatible, enter the base URL and key, click Create.

Save once Add API Key shows Valid, then click Import Model to load the models.

Step 5 — check quota and expiry

See tokens used, remaining balance and expiry at Service stops at expiry even if tokens remain.

Available models

gpt-6-astra

gpt-6-sol

gpt-5.6-luna

gpt-5.6-terra

gpt-5.6-sol

Use the names in the config page dropdown; a name not on it returns model not found.

Troubleshooting

Codex still asks you to sign in to ChatGPT: the config was not read. Make sure the file is in ~/.codex/ and named exactly config.toml, not config.toml.txt, and that model_provider matches the [model_providers.xxx] section name.

Changes have no effect: Codex CLI reads the config only at startup. Quit and relaunch.

401 / 403: expired key, variable not loaded, or quotes copied into the value. Generate a new key.

Timeouts or cut-off replies: the context is too large. Split the task or use a lighter model.

One key on several computers? Possible, but the quota is shared. One key per person is better.

Good to know

Keep the key only in local environment variables or the config file. Never put it in Git or public channels.

Test the whole setup right after redeeming so problems do not surface near expiry.

Requests are rejected once tokens run out or the plan expires.

Still stuck? Contact support with your order number, plan and an error screenshot.