Skip to content

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:

Systemconfig.toml path
macOS/Users/<username>/.codex/config.toml
WindowsC:\Users\<username>\.codex\config.toml
Linux / WSL/home/<username>/.codex/config.toml

Open the file and add:

toml
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
FieldPurpose
model_providerUses the LAYSO AI provider ID: layso_ai
nameProvider name displayed in Codex: LAYSO AI
modelExact model ID copied from the pricing page
model_reasoning_effortReasoning effort; this example uses high
disable_response_storageDisables Responses API response storage
cli_auth_credentials_storeForces credentials to use .codex/auth.json for the current user
base_urlLAYSO AI OpenAI-compatible Base URL
wire_apiResponses request format used by a Codex custom provider
requires_openai_authUses 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:

json
{
  "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).

bash
mkdir -p ~/.codex
nano ~/.codex/auth.json
chmod 600 ~/.codex/auth.json

Paste the JSON above into the editor, save, and exit.

Windows ​

Authentication file: C:\Users\<username>\.codex\auth.json ($HOME\.codex\auth.json in PowerShell).

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).

bash
mkdir -p ~/.codex
nano ~/.codex/auth.json
chmod 600 ~/.codex/auth.json

Paste 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 ​

bash
codex

Run /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:

toml
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 ​

SymptomResolution
401 / 403Confirm that .codex/auth.json exists for the current user, contains valid JSON, and has a valid OPENAI_API_KEY
404Keep base_url = "https://api.layso.ai/v1"; do not append /v1 twice
Invalid request shapeConfirm wire_api = "responses"
Unknown modelCopy the exact ID from the pricing page
Provider not appliedConfirm model_provider = "layso_ai" and [model_providers.layso_ai], then restart Codex
Old key is still usedConfirm cli_auth_credentials_store = "file", fully quit Codex, and restart it

Next step ​

Read Codex Desktop or return to the Codex CLI overview.

LAYSO AI API 文档