Codex Quick Start

Install Codex on Windows, macOS, or Linux, connect a Modelflare API key, and verify a Responses API request.

This guide gets Codex connected to Modelflare and running its first request. Use Option A for automated setup. Use Option B to install Codex first, then create each required file yourself.

1. Create an API key

Sign in to the Modelflare console, open API Keys, and create a key that can access gpt-5.6-sol. Choose any available non-default group that lists the model; there is no single required group.

Keep the key ready. You can use the installer or configure the same files manually.

2. Choose a setup method

Option A: run the installer

macOS or Linux

Run this command as your normal user:

curl -fsSL https://modelflare.dev/install/codex.sh | sh

When you are already logged in as root on a VPS or container, use:

curl -fsSL https://modelflare.dev/install/codex.sh | MODELFLARE_ALLOW_ROOT=1 sh

Do not add sudo on a normal personal computer. The script installs or updates Codex, backs up existing files, asks for your Modelflare API key, and writes the provider configuration under ~/.codex.

Windows PowerShell

Open PowerShell as your normal Windows user and run:

irm https://modelflare.dev/install/codex.ps1 | iex

The installer asks for a language and your Modelflare API key, verifies access to gpt-5.6-sol, and backs up existing files before changing them. When it finishes, continue to Verify the connection.

Option B: create each Codex file yourself

Use this option when you do not want to run the Modelflare setup script. Follow the steps in order and use the command block for your operating system in every step.

Option B creates two files under your user-level .codex directory: config.toml and modelflare_api_key.

Step 1: install Codex CLI

Windows PowerShell

irm https://chatgpt.com/codex/install.ps1 | iex
codex --version

Linux

curl -fsSL https://chatgpt.com/codex/install.sh | sh
codex --version

macOS

curl -fsSL https://chatgpt.com/codex/install.sh | sh
codex --version

Step 2: create and enter the .codex directory

Windows PowerShell

New-Item -ItemType Directory -Force "$HOME\.codex" | Out-Null
Set-Location "$HOME\.codex"

Linux

mkdir -p ~/.codex
cd ~/.codex

macOS

mkdir -p ~/.codex
cd ~/.codex

Step 3: create config.toml

Windows PowerShell

$config = @'
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"

[model_providers.modelflare.auth]
command = "powershell.exe"
args = ["-NoProfile", "-NonInteractive", "-Command", "Get-Content -LiteralPath (Join-Path (Join-Path $HOME '.codex') 'modelflare_api_key') -Raw"]
'@
$utf8NoBom = New-Object System.Text.UTF8Encoding -ArgumentList $false
[System.IO.File]::WriteAllText(
  (Join-Path (Get-Location) "config.toml"),
  $config,
  $utf8NoBom
)

Linux

cat > config.toml << 'EOF'
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"

[model_providers.modelflare.auth]
command = "sh"
args = ["-lc", "cat ~/.codex/modelflare_api_key"]
EOF
chmod 600 config.toml

macOS

cat > config.toml << 'EOF'
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"

[model_providers.modelflare.auth]
command = "sh"
args = ["-lc", "cat ~/.codex/modelflare_api_key"]
EOF
chmod 600 config.toml

Step 4: create modelflare_api_key

Before running the command for your system, replace YOUR_MODELFLARE_API_KEY with the complete API key you created in the Modelflare console. The file must contain only the key itself—do not keep the placeholder or add quotes, backticks, or spaces.

Windows PowerShell

$apiKey = @'
YOUR_MODELFLARE_API_KEY
'@
$apiKey = $apiKey.Trim()
$utf8NoBom = New-Object System.Text.UTF8Encoding -ArgumentList $false
[System.IO.File]::WriteAllText(
  (Join-Path (Get-Location) "modelflare_api_key"),
  $apiKey,
  $utf8NoBom
)
$apiKey = $null

Linux

cat > modelflare_api_key << 'EOF'
YOUR_MODELFLARE_API_KEY
EOF
chmod 600 modelflare_api_key

macOS

cat > modelflare_api_key << 'EOF'
YOUR_MODELFLARE_API_KEY
EOF
chmod 600 modelflare_api_key

Step 5: start Codex

Windows PowerShell

Set-Location $HOME
New-Item -ItemType Directory -Force "my-codex-project" | Out-Null
Set-Location "my-codex-project"
codex --model gpt-5.6-sol

Linux

cd ~
mkdir -p my-codex-project
cd my-codex-project
codex --model gpt-5.6-sol

macOS

cd ~
mkdir -p my-codex-project
cd my-codex-project
codex --model gpt-5.6-sol

3. Verify the connection

If you used the installer, fully close any Codex CLI, IDE, or desktop session that was already open. Open a new terminal, enter a project directory, and run:

codex --model gpt-5.6-sol

Then ask Codex:

Reply with one sentence confirming the active model and provider.

A normal response means setup is complete.

Common problems

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.