Configure Codex CLI Model Provider
Codex CLI stores the model and provider in config.toml and the API key separately in auth.json. Both files live in the current system user's .codex directory.
Step 1: Choose a model
Open LAYSO AI models and pricing ↗, compare price, context length, and capabilities, then copy the exact model ID shown on the page.
The example below uses gpt-5.5. To switch models later, change only model.
Step 2: Add the model provider
Locate the current user's configuration file for your operating system:
| System | config.toml path |
|---|---|
| macOS | /Users/<username>/.codex/config.toml |
| Windows | C:\Users\<username>\.codex\config.toml |
| Linux / WSL | /home/<username>/.codex/config.toml |
Open the file and add:
model_provider = "layso_ai"
model = "gpt-5.5"
model_reasoning_effort = "high"
disable_response_storage = true
cli_auth_credentials_store = "file"
[model_providers.layso_ai]
name = "LAYSO AI"
base_url = "https://api.layso.ai/v1"
wire_api = "responses"
requires_openai_auth = true| Field | Purpose |
|---|---|
model_provider | Uses the LAYSO AI provider ID: layso_ai |
name | Provider name displayed in Codex: LAYSO AI |
model | Exact model ID copied from the pricing page |
model_reasoning_effort | Reasoning effort; this example uses high |
disable_response_storage | Disables Responses API response storage |
cli_auth_credentials_store | Forces credentials to use .codex/auth.json for the current user |
base_url | LAYSO AI OpenAI-compatible Base URL |
wire_api | Responses request format used by a Codex custom provider |
requires_openai_auth | Uses OPENAI_API_KEY from the Codex authentication file |
Step 3: Write the API key to the authentication file
Create and copy a key from the LAYSO AI API Keys page ↗. Do not place the key in config.toml; create auth.json for your device.
The authentication file uses the same content on all three systems:
{
"OPENAI_API_KEY": "sk-..."
}Replace sk-... with the full LAYSO AI API key.
macOS
Authentication file: /Users/<username>/.codex/auth.json (the same as ~/.codex/auth.json).
mkdir -p ~/.codex
nano ~/.codex/auth.json
chmod 600 ~/.codex/auth.jsonPaste the JSON above into the editor, save, and exit.
Windows
Authentication file: C:\Users\<username>\.codex\auth.json ($HOME\.codex\auth.json in PowerShell).
New-Item -ItemType Directory -Force "$HOME\.codex"
notepad "$HOME\.codex\auth.json"Paste the JSON above into Notepad. When saving, make sure the file is named auth.json, not auth.json.txt.
Linux / WSL
Authentication file: /home/<username>/.codex/auth.json (the same as ~/.codex/auth.json).
mkdir -p ~/.codex
nano ~/.codex/auth.json
chmod 600 ~/.codex/auth.jsonPaste the JSON above into the editor, save, and exit. WSL uses the Linux home directory, not the Windows user directory.
auth.json stores only the API key; config.toml stores the model and provider. Never share, screenshot, or commit authentication data from these files.
Step 4: Start and verify
codexRun /status inside Codex and confirm that the provider is LAYSO AI and the model ID matches your pricing-page selection.
Switch models
Return to LAYSO AI models and pricing ↗, copy another exact model ID, and update:
model = "<MODEL_ID>"Restart Codex after saving. One LAYSO AI API key can access platform models. Successful requests have itemized charges; failed tasks are not charged.
Authentication troubleshooting
| Symptom | Resolution |
|---|---|
401 / 403 | Confirm that .codex/auth.json exists for the current user, contains valid JSON, and has a valid OPENAI_API_KEY |
404 | Keep base_url = "https://api.layso.ai/v1"; do not append /v1 twice |
| Invalid request shape | Confirm wire_api = "responses" |
| Unknown model | Copy the exact ID from the pricing page |
| Provider not applied | Confirm model_provider = "layso_ai" and [model_providers.layso_ai], then restart Codex |
| Old key is still used | Confirm cli_auth_credentials_store = "file", fully quit Codex, and restart it |
Next step
Read Codex Desktop or return to the Codex CLI overview.
