Codex CLI on Modelflare in depth: installer, config.toml, auth.json, and common problems
Codex talks to Modelflare over the Responses API at https://modelflare.dev/v1. The setup comes down to two files under ~/.codex, and you can let the Modelflare installer write them or create them by hand. This guide walks through both paths, root installs on a VPS, each line of the documented configuration, and the four problems the docs list.
Modelflare serves Codex through the Responses family, POST /v1/responses, the same family Grok Build uses. An earlier article summarised the Codex setup alongside five other clients. This one stays with Codex and follows the Codex setup guide step by step. Every command and file below is copied from that page.
Start with the key
Both setup paths need a Modelflare API key that can reach gpt-5.6-sol. In the console, open API Keys and create a key in any available non-default group that lists the model. The docs do not require one particular group. When the key exists, choose between the installer (Option A) and manual files (Option B). Both end with the same files under ~/.codex.
Option A: the installer
On macOS or Linux, run the installer as your normal user:
curl -fsSL https://modelflare.dev/install/codex.sh | sh
On Windows, open PowerShell as your normal user:
irm https://modelflare.dev/install/codex.ps1 | iex
The script installs or updates Codex, backs up existing files before it changes them, asks for a language and your Modelflare API key, verifies that the key can access gpt-5.6-sol, and writes the provider configuration under ~/.codex.
The docs also provide an interactive first-run guide, a simulated Mac or Windows walkthrough that does not change your computer. It shows the installer prompts in order: a language choice (English is option 3), an offer to install Codex CLI when it is not found (Install it now? [Y/n]), and a prompt to paste the API key. The input is visible while you paste. After the key passes validation the script reports gpt-5.6-sol is available and Setup complete.
Root on a VPS or in a container
The installer expects a normal user. If you are already logged in as root on a VPS or in a container, set MODELFLARE_ALLOW_ROOT=1 for the shell that runs the script:
curl -fsSL https://modelflare.dev/install/codex.sh | MODELFLARE_ALLOW_ROOT=1 sh
This is not a substitute for sudo. The docs say not to add sudo on a normal personal computer. On a workstation, run the plain command as yourself so the files are written to your own ~/.codex.
Option B: writing the files yourself
Use this path when you do not want to run the Modelflare setup script. First install Codex CLI from the upstream installer and confirm the version. On Linux or macOS:
curl -fsSL https://chatgpt.com/codex/install.sh | sh
codex --version
Then create the directory and enter it:
mkdir -p ~/.codex
cd ~/.codex
The docs give a PowerShell block for each step as well. On Windows those blocks write both files as UTF-8 without a byte-order mark.
config.toml
cat > config.toml << 'EOF'
cli_auth_credentials_store = "file"
model_provider = "modelflare"
model = "gpt-5.6-sol"
model_reasoning_effort = "xhigh"
disable_response_storage = true
model_supports_reasoning_summaries = true
[model_providers.modelflare]
name = "Modelflare"
base_url = "https://modelflare.dev/v1"
wire_api = "responses"
requires_openai_auth = true
EOF
chmod 600 config.toml
The file has two parts. The top-level keys pick the provider and model defaults:
cli_auth_credentials_store = "file"goes with the file-basedauth.jsoncreated in the next step.model_provider = "modelflare"selects the provider table defined below it,[model_providers.modelflare].model = "gpt-5.6-sol"is the default model, the same ID used in the verification command.model_reasoning_effort = "xhigh",disable_response_storage = true, andmodel_supports_reasoning_summaries = trueare the values the docs ship. This article leaves them as documented.
The provider table describes the connection:
name = "Modelflare"is the display name.base_url = "https://modelflare.dev/v1"is the OpenAI-style base URL, including/v1.wire_api = "responses"sends requests to the Responses family.requires_openai_auth = trueis required by current Codex releases for this API-key path.
auth.json
cat > auth.json << 'EOF'
{
"auth_mode": "apikey",
"OPENAI_API_KEY": "YOUR_MODELFLARE_API_KEY"
}
EOF
chmod 600 auth.json
Replace YOUR_MODELFLARE_API_KEY with the complete key from the console. The file must stay valid JSON and keep the key in the OPENAI_API_KEY field. Do not add a provider auth command block. On macOS and Linux, both files are created with mode 600, so only your user can read the key.
Verify the connection
If you used the installer, fully close every Codex CLI, IDE, or desktop session that was already open, then open a new terminal. Enter a project directory and run:
codex --model gpt-5.6-sol
Then send this prompt:
Reply with one sentence confirming the active model and provider.
A normal reply means setup is complete. The Codex App is an optional download after setup.
Common problems
The docs list four symptoms:
| Symptom | What to do |
|---|---|
401 |
Recopy the API key and confirm that it has not been deleted or disabled. |
model_not_found |
Edit the API key and choose a group that can access gpt-5.6-sol. |
| ChatGPT login appears | Fully quit every Codex session and reopen the CLI. |
codex is not found |
Open a new terminal. On Windows, try codex.cmd. |
The first two rows separate the causes: a 401 is fixed on the key value, and model_not_found on the group the key belongs to.
To keep several Codex profiles, the CC-Switch guide imports a Modelflare key into CC-Switch directly. Restart Codex when CC-Switch asks you to after you enable the imported provider. For team setups or volume usage, contact business@modelflare.dev.