Codex CLI setup without an OpenAI account: APIKing in three steps
Updated 2026-11-27简体中文繁體中文日本語한국어DeutschFrançaisEspañolPortuguês (Brasil)ItalianoРусский
The Codex CLI is OpenAI’s coding agent for the terminal, and it asks for a ChatGPT login or an OpenAI key. With APIKing you need no OpenAI account, can top up with Alipay and pay per token. The setup is one TOML file and one environment variable.
1. Edit the config file
Merge the settings below into ~/.codex/config.toml. Keep model and model_provider at the top, before the first [table]; if an APIKing provider block exists, update it.
# ~/.codex/config.toml
model = "gpt-6-sol"
model_provider = "apiking"
[model_providers.apiking]
name = "APIKing"
base_url = "https://apiking.ai/v1"
env_key = "APIKING_API_KEY"
wire_api = "responses"
supports_websockets = true2. Set the key and start
Set the key in the terminal you start Codex from, then run codex:
export APIKING_API_KEY="sk-YOUR_KEY"
codex$env:APIKING_API_KEY = "sk-YOUR_KEY". Codex uses the Responses API, so pick a model that supports /v1/responses; every GPT model does.3. Check
- Run
/statusin Codex and check that the provider is APIKing and the model is right. - Switch models with
/model, or start a session withcodex -m MODEL_ID. - Send a message, then find the call on the usage page of the console.
Prices of models that suit Codex
| Model | Price | Official price (per 1M tokens) |
|---|---|---|
| GPT-6 Sol | $0.10 in · $0.50 out / 1M | $2.00 in · $10.00 out / 1M |
| GPT-6.2 Astra | $0.40 in · $2.00 out / 1M | $8.00 in · $40.00 out / 1M |
| GPT-6.2 Sol | $0.10 in · $0.50 out / 1M | $2.00 in · $10.00 out / 1M |
| GPT-6 Luna | $0.0784 in · $0.392 out / 1M | $0.10 in · $0.50 out / 1M |
To use Claude in Claude Code, see the Claude Code setup guide.
Questions
Can the Codex CLI run without an OpenAI account?
Yes. Add a provider whose base_url points to APIKing in ~/.codex/config.toml and set the APIKING_API_KEY environment variable.
Which models work in Codex?
Codex uses the Responses API, so pick a model that supports /v1/responses; every GPT model does.
How do I set the key on Windows?
Run $env:APIKING_API_KEY = "sk-YOUR_KEY" in PowerShell, then start codex.