Codex
One settings file serves the Codex CLI, the Codex app and the VS Code extension alike.
Setup
- Install the CLI:
npm install -g @openai/codex. The app and the extension have no use for the CLI; the file from step 2 is enough for them. - Open
~/.codex/config.toml(on Windows%USERPROFILE%\.codex\config.toml) and add:
model = "gpt-6-sol"
model_reasoning_effort = "high"
model_provider = "codexkey"
[model_providers.codexkey]
name = "codexkey"
base_url = "https://api.codexkey.online/v1"
wire_api = "responses"
requires_openai_auth = true- Put your key in
~/.codex/auth.json:
{ "OPENAI_API_KEY": "sk_cdx_YOUR_KEY" }- Start
codex. You can choose a model on the fly:codex --profile astraorcodex --model gpt-6.1-sol.
In Codex 0.134.0 and newer, a profile lives in its own file such as ~/.codex/astra.config.toml, with the same top-level keys. Codex reads config.toml and layers the profile over it, so --profile astra takes its settings from ~/.codex/astra.config.toml. Newer versions ignore [profiles.*] tables in config.toml, and the old profile = "..." selector is no longer supported, so remove any that remain. Before 0.134.0, profiles were set as tables in config.toml. The codexkey provider stays in config.toml.
model = "gpt-6-astra"model = "gpt-6-luna"Important: The address in base_url is written with /v1, and wire_api = "responses" switches on the Responses API format.
model_reasoning_effort sets how deeply the model reasons. To save money, set "medium" or delete the line. The app and the extension read the file at startup, so restart them completely after editing.
Settings reference
| Setting | Description | Example |
|---|---|---|
model_provider | The provider used for requests. Its name must match the table name in model_providers. | "codexkey" |
model | Default model ID. | "gpt-6-sol" |
model_reasoning_effort | Reasoning depth. | "medium", "high" |
base_url | The codexkey API address with /v1. | https://api.codexkey.online/v1 |
wire_api | Request format: Responses API. | "responses" |
requires_openai_auth | Take the key from ~/.codex/auth.json. | true |
Key in an environment variable
To keep the key out of the file, replace requires_openai_auth with env_key and set the CODEX_KEY variable:
[model_providers.codexkey]
name = "codexkey"
base_url = "https://api.codexkey.online/v1"
wire_api = "responses"
env_key = "CODEX_KEY"export CODEX_KEY="sk_cdx_YOUR_KEY"When something goes wrong
Authentication errors
Look at the OPENAI_API_KEY field in auth.json: the key starts with sk_cdx_ and must be active in the API Keys section. Restart Codex after editing.
Model not found
Codex passes the model value to codexkey unchanged, so it has to match an ID from the catalog, for example gpt-6-sol.
404 or unexpected response
Make sure base_url ends with /v1 and wire_api equals "responses".