Codex is OpenAI's coding agent. The basic workflow is to install Codex CLI, which runs in the terminal (npm install -g @openai/codex), run codex in the repository you want to work in, and make a request in Korean. There are two ways to get started: sign in with a ChatGPT plan (Plus, Pro, Business, etc.) and use Codex within its usage limits, or run it with an API key and pay only for the tokens you use. Most Korean guides cover only the first option, so this article focuses on the second: setting up Codex CLI without a subscription, choosing a model for each task, and the actual cost of a task. Plan limits and options for when you run out are covered separately in Codex usage limits.
Codex is an agent that reads and edits files and runs tests and commands in your repository; it isn't a tool for pasting code into a chat window. You can control what it does without confirmation after each step with /permissions.
Two ways to use Codex
| Sign in with a ChatGPT plan | API key (pay-as-you-go) | |
|---|---|---|
| Billing | Monthly fee (included in plan) | Pay for the tokens you use. No monthly fee |
| Limits | Plan usage limits | Balance, plus a monthly limit you set for each key |
| Model | Models included in the plan by OpenAI | Choose a model for each task from those offered by the endpoint |
| Getting started | Sign in via browser with codex login | One config.toml block plus an environment variable |
API key billing is separate from the usage in a ChatGPT plan. You can use an OpenAI API key, but this guide covers connecting to a Responses API-compatible endpoint. You can switch between models from GPT-6 Astra to GPT-5.6 Terra using the same key. For example, GPT-5.6 Sol costs $2.00 / $12.00 per 1M tokens, compared with OpenAI's public price of $5.00 / $30.00 (OpenAI currently offers it at the promotional price of $4.00 / $20.00, and according to the pricing page, it will remain available at least until November 21, 2026) (rates are read directly from the catalog).
Install Codex — npm or Homebrew
# npm (Node.js만 있으면 macOS / Linux / Windows 공통)
npm install -g @openai/codex
# Homebrew (macOS)
brew install --cask codexBoth methods are listed in OpenAI's official README. The npm command also installs on Windows. Once installed, enter codex in the repository directory you want to work in. If you're using Codex with ChatGPT, you're done here; you don't need the settings below.
Get and configure a Codex API key — one config.toml block
First, sign up and add at least $10 to your balance, then create a key on the API keys page. The key is shown only once, so save it right away. Then add a provider block to the Codex configuration file.
# ~/.codex/config.toml (없으면 새로 만듭니다)
model = "gpt-5-6-sol"
model_provider = "kunavo"
[model_providers.kunavo]
name = "Kunavo"
base_url = "https://api.kunavo.com/v1"
env_key = "KUNAVO_API_KEY" # 키 자체가 아니라 「환경 변수 이름」
wire_api = "responses" # 유일하게 유효한 값. 생략해도 같습니다The most common mistake is with env_key. Enter the name of the environment variable containing the key, not the key itself. The key is not in the configuration file, so config.toml is safe to commit or paste into a help request.
# env_key에 적은 이름의 변수에 키를 넣습니다 (키는 sk-kn-으로 시작)
export KUNAVO_API_KEY="sk-kn-..."
# 매번 export하지 않도록, 쓰는 셸의 설정 파일에 추가해 둡니다
echo 'export KUNAVO_API_KEY="sk-kn-..."' >> ~/.zshrcIf you're using Windows PowerShell, run setx KUNAVO_API_KEY sk-kn-... and then open a new terminal. The configuration file is located at %USERPROFILE%\.codex\config.toml. Before running Codex, send one request to check the key and endpoint; this makes it easier to narrow down any problem.
# 코덱스를 의심하기 전에, 키와 엔드포인트만 요청 한 번으로 확인합니다
curl https://api.kunavo.com/v1/responses \
-H "Authorization: Bearer $KUNAVO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-5-6-sol", "input": "OK라고만 답해줘"}'If JSON is returned, the key and endpoint are working; the remaining issue is on the config.toml side. Configuration options are covered in the Codex CLI integration documentation (English), and a guide that also explains how to call Claude models from Codex is in the Codex CLI API key guide (English).
First task
# 1. 작업할 저장소로 들어가 실행합니다
cd ~/work/my-app
codex
# 2. AGENTS.md 초안을 만들게 합니다 (테스트 실행법이나 규칙을 적는 파일)
> /init
# 3. 이후엔 한국어로 요청합니다. 파일 경로를 붙일수록 빠르고 싸게 끝납니다
> src/utils/date.test.ts가 실패해. 원인을 찾아서 고치고 테스트가 통과하는지 확인해줘/init creates a AGENTS.md that records rules you can't learn just by reading the code, such as how to run tests, which libraries to use, and which paths not to touch. Codex reads it automatically in later sessions. The generated content is a draft, so review and refine it yourself.
The tips for making requests are the same as for Claude Code: include file paths and don't bundle large tasks into a single request. This reduces tokens spent exploring, making results faster and more accurate while lowering costs. Tips for working with Claude Code are in How to use Claude Code.
Choose a model for each task — the actual cost of one task
The biggest advantage of using an API key is that you can choose a model suited to the task. model is just a model name provided by the endpoint, so switching does not require a new key or additional configuration.
# config.toml의 기본값(gpt-5-6-sol)은 그대로 두고, 이번 실행만 모델을 바꿉니다
codex -m gpt-6-astra # 원인을 모르는 버그, 여러 모듈에 걸친 변경
codex -m gpt-5-6-terra # 정형화된 수정, 일괄 치환, 로그 요약 같은 가벼운 작업| Task | Model | Input / output (per 1M tokens) | Per task |
|---|---|---|---|
| Unknown bug · changes across multiple modules | gpt-6-astra | $4.00 / $20.00 | $2.48 |
| Default — everyday implementation and fixes | gpt-5-6-sol | $2.00 / $12.00 | $1.29 |
| Add tests · routine fixes · bulk replacements · log summaries | gpt-5-6-terra | $0.70 / $4.20 | $0.451 |
The estimate for one task assumes 20 steps to fix one failing test. One step uses 25,000 input tokens (system prompt + conversation history + files read) and 1,200 output tokens (one change or explanation), so one task uses 500,000 input and 24,000 output tokens. GPT-5.6 Sol comes to $1.29, for the same tokens billed directly by OpenAI at the current promotional price: $2.48 (or $3.22 at the regular price). Cheaper models may need more back-and-forth to fix and refine the result, so if it doesn't finish in one go, moving up one tier is a practical approach. To enter your own token counts, use the cost calculator.
This calculation does not account for caching. Codex resends the conversation history at every step, so cached input is billed at 0.10 times the input rate (GPT-5.6 Sol: $0.20 per 1M tokens), while the portion newly written to the cache costs 1.25 times the input rate. GPT-5.6 models and GPT-6 Astra also bill the entire request at 2× input and 1.5× output if the prompt exceeds 272K tokens. It's safer to start a new run for each task rather than pack too much into one session. Reasoning tokens from reasoning models are billed as output, so harder tasks also use more output tokens. Check the actual amount in the response's usage and usage details. Model specifications are on the GPT-5.6 Sol model page; full rates are on the pricing page, and a side-by-side comparison of token rates for the GPT models used by Codex is on GPT API pricing.
Common errors
| Symptom | Cause and resolution |
|---|---|
401(authentication_error) | The key is incorrect, or the variable in env_key is empty in the shell where Codex is running. Check that you exported it before running Codex and that you did not put the key itself in env_key. |
Configuration not read · wire_api error | wire_api = "chat" found in older guides is invalid in current Codex. Replace it with "responses" or remove the line. |
404 “Model … is not available” | Enter model names with hyphens as they appear in the catalog (gpt-5-6-sol). The OpenAI name gpt-5.6-sol will not be found as written. A model name that is no longer offered causes the same error. |
All requests return 404 | End base_url with /v1. Codex adds /responses automatically, so including it will result in duplication. |
402(insufficient_quota) | Your balance is too low or you've reached the monthly cap set for the key. The error message tells you which. |
403(permission_error) | Your current IP address is not on the key's IP allowlist. |
Honestly: when a ChatGPT plan is a better fit
If you spend several hours a day working interactively with Codex, a flat-rate plan is generally cheaper. Pay-per-token costs scale directly with token volume, so the higher and more consistent your usage, the greater the advantage of a flat rate. The calculation is “monthly fee ÷ cost per task,” and Codex pricing works out the break-even point for a plan.
There are two more things to know. OpenAI's documentation says that features relying on a ChatGPT workspace or cloud are limited or unavailable when using an API key. Also, Kunavo's route uses shared capacity, so it has no dedicated quota or contractual SLA. If you need a guaranteed limit or SLA, it makes sense to contract directly with OpenAI.
An API key is a better fit if your usage varies a lot from day to day, you want to choose a model for each task, you want to set limits and separate usage by key across a team, or you want to continue working only on days when you've reached your plan limit. The two options can be used together. Remove the model_provider line from config.toml to return to ChatGPT sign-in, or use Codex's --profile if you want to switch for each run.
Kunavo top-ups can be paid with cards, Apple Pay, Google Pay, and other methods; when the payment screen is displayed in Korean won, KakaoPay, Naver Pay, PAYCO, Samsung Pay, and domestic cards (including cards that do not have international payments enabled) also appear. Toss is not supported. Balances do not expire, and failed requests are not charged. If you are deciding between Codex and Claude Code, see Codex vs. Claude Code.
Frequently asked questions
How do I get started with Codex?
Install Codex CLI (npm install -g @openai/codex; on macOS, brew install --cask codex is also an option), run codex from the repository directory you want to work in, and make a request in Korean. There are two authentication options: sign in with a ChatGPT plan and use Codex within its usage limits, or use an API key and pay per token. For an API key, add a provider block to ~/.codex/config.toml and pass the key through an environment variable.
How do I install Codex CLI?
npm install -g @openai/codex is the method for macOS, Linux, and Windows; on macOS, you can also install it with brew install --cask codex. Once installed, run codex from the repository directory you want to work in.
Can I use Codex without a ChatGPT subscription?
Yes. Codex CLI also works with an API key; in that case, you're billed for the tokens you use rather than drawing on your ChatGPT plan's usage. In addition to providing an OpenAI API key, you can register a Responses API-compatible endpoint under model_providers in config.toml. For Kunavo, the base_url is https://api.kunavo.com/v1, and the default model is gpt-5-6-sol.
Is Codex free?
Codex CLI itself is distributed for free, but running models costs money. You can either use the usage included in a ChatGPT plan (Plus, Pro, Business, etc.) or pay per token with an API key. With pay-per-token billing there is no monthly fee, so in a month when you don't use it, the charge is $0.
Can I use Codex in VS Code with an API key?
Yes. The Codex IDE extension reads the same ~/.codex/config.toml as the CLI, so the model_providers block applies there too. Restart the editor after changing the settings.
Which model should I use with Codex CLI?
The default, gpt-5-6-sol (per 1M tokens: $2.00 / $12.00), is sufficient. Upgrade to gpt-6-astra ($4.00 / $20.00) only for unknown bugs or changes across multiple modules, and use gpt-5-6-terra ($0.70 / $4.20) for routine fixes and lighter tasks like replacements or summaries. Switch with codex -m <model name>; this applies only to that run.
Why am I getting a 401 error in Codex CLI?
Almost always, the key hasn't been passed to Codex. In config.toml, env_key should contain the name of the environment variable (for example, KUNAVO_API_KEY), not the key itself, and you must run codex from a shell where that variable has been exported. A common cause is exporting it in another terminal tab or starting Codex before exporting it.
Can I pay with KakaoPay or Toss?
KakaoPay can be used for Kunavo balance top-ups through the API-key route, while Toss is not supported. When Stripe Checkout is displayed in Korean won, KakaoPay, Naver Pay, PAYCO, Samsung Pay, and domestic cards (including cards that do not have international payments enabled) appear as payment methods. The converted-won amount includes Stripe's currency-conversion fee paid by the purchaser (2–4%). Paying in dollars avoids this fee, but the domestic methods above appear only for won payments. Cards (Visa, Mastercard, Amex, JCB, UnionPay), Apple Pay, and Google Pay are also supported. These methods are for topping up Kunavo, not for paying for ChatGPT plans. Top up in advance from $10; balances do not expire, and failed requests are not charged.