Home › Guide › Codex with a cheap API

Use the Codex CLI with a cheap API: the config.toml setup

Codex charges by actual token usage — through the Cho Tai Khoan gateway you pay a fixed package from $0.72 (≈ 19.000đ) instead of per-call USD billing. Just set 1 environment variable and paste 1 configuration block into the Codex config.toml file.

Do not have Codex yet? Install it first (about 1 minute)

  1. Install the LTS version of Node.js from nodejs.org (skip this step if your machine already has Node.js).
  2. Open Terminal (macOS / Linux) or PowerShell (Windows) and run:
npm install -g @openai/codex

Check the install: run codex --version — a version number means you are good.

Step 1 — Get a key first

  1. Go to the API gateway home page, pick a package and pay (USDT, VietQR or MoMo) — the system issues a redeem code automatically.
  2. Redeem the code right on the page and receive a key starting with sk-ctk-.

Step 2 — Set the environment variable holding your key

Create an environment variable named CTK_API_KEY with your key as its value:

Open a command window: on Windows press Start, type PowerShell, press Enter. On macOS press Cmd + Space, type Terminal, press Enter.

If you have already checked your key on the home page in the same browser, the key in the boxes below is already filled in for you — just copy them as-is, no manual editing.

macOS / Linux — add to ~/.zshrc or ~/.bashrc:

export CTK_API_KEY="KEY_CUA_BAN"

Windows — PowerShell:

setx CTK_API_KEY "KEY_CUA_BAN"

Step 3 — Paste the configuration into config.toml

Open the Codex config.toml file and paste this block. The file lives in the .codex folder in your user folder: on Windows that is C:\Users\<your name>\.codex, on macOS / Linux it is ~/.codex/. If the folder or file does not exist yet, create it.

Windows note: if you create the file with Notepad, in the save dialog set "Save as type" to All Files and name the file exactly config.toml — with the default setting Notepad saves it as config.toml.txt and Codex cannot read it.

model_provider = "chotaikhoan"
model = "gpt-6-astra"

[model_providers.chotaikhoan]
name = "Cho Tai Khoan API"
base_url = "https://api.chotaikhoan.com/v1"
env_key = "CTK_API_KEY"
wire_api = "responses"

The model line is the default model — switch it to any model in the list of 26 models (Claude, GPT, Gemini, DeepSeek…) and it runs on the same key.

Step 4 — Check

Reopen Codex (fully close the command window and open it again so the environment variable takes effect) and type: "Reply with exactly one word: running". An answer of "running" means you are done.

Common errors

Using Claude Code instead of Codex? See the Claude Code guide — same key, 2 more lines and it runs.

Test Codex with the $0.72 package

The Starter package is enough to set up and test Codex, Claude Code, Cursor and Cline on a single key. Happy with it? Top up later — quota stacks, nothing you bought is lost.

View packages — from $0.72🔑 Redeem a code for a key
Chợ Tài Khoản — api.chotaikhoan.com · Support on Telegram: @chotaikhoandotcom · Bot: @chotaikhoan_api_bot

API gateway home (English)API pricing (English)Setup guide (English)Redeem a codeClaude Code guideCodex guideCursor guideCline guideVS Code guideOpenClaw guideFAQWarranty & refundsIs this shop trustworthy?Trang chủ cổng API (Tiếng Việt)Bảng giá API (Tiếng Việt)Chợ Tài Khoản main store