Codex クイックスタート

Windows、macOS、Linux に Codex をインストールし、Modelflare APIキーを接続して Responses API リクエストを確認します。

このガイドでは、Codex を Modelflare に接続して最初のリクエストを成功させます。最短で設定する場合は方法 A を使います。設定を一つずつ作成する場合は、方法 B の各ステップで自分の OS のコマンドを実行してください。

1. APIキーを作成

Modelflare コンソールにログインし、APIキー を開いて gpt-5.6-sol にアクセスできるキーを作成します。このモデルを含む default 以外の任意のルートを選択してください。指定された唯一のルートはありません。

作成した APIキーは、次の手順で一度だけ貼り付けます。

2. 設定方法を選択

方法 A: インストーラーを実行

macOS または Linux

通常のユーザーで次を実行します。

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

VPS やコンテナですでに root としてログインしている場合は、次を実行します。

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

通常のパソコンでは sudo を付けないでください。

Windows PowerShell

通常の Windows ユーザーで PowerShell を開き、次を実行します。

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

インストーラーは言語と Modelflare APIキーの入力を求め、gpt-5.6-sol へのアクセスを確認します。既存ファイルは変更前にバックアップされます。完了したら「接続を確認」に進んでください。

方法 B: Codex の設定を一つずつ作成

Modelflare のセットアップスクリプトを実行しない場合は、次の順序で設定します。各ステップで、自分の OS に対応するコマンドだけを実行してください。

方法 B では、ユーザーの .codex ディレクトリに config.tomlmodelflare_api_key の 2 ファイルを作成します。

ステップ 1: 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

ステップ 2: .codex ディレクトリを作成して移動

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

ステップ 3: 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

ステップ 4: modelflare_api_key を作成

自分の OS のコマンドを実行する前に、コードブロック内の YOUR_MODELFLARE_API_KEY を Modelflare コンソールで作成した完全な APIキーに置き換えてください。ファイルには Key だけを保存し、プレースホルダー、引用符、バッククォート、空白は残さないでください。

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

ステップ 5: 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. 接続を確認

インストーラーを使用した場合は、開いている Codex CLI、IDE、デスクトップセッションを完全に終了してください。新しいターミナルを開き、プロジェクトのディレクトリで次を実行します。

codex --model gpt-5.6-sol

Codex に次のように入力します。

現在使用中のモデルと provider を一文で確認してください。

通常の応答が返れば設定完了です。

よくある問題

症状 対処
401 APIキーをコピーし直し、削除または無効化されていないことを確認します。
model_not_found APIキーを編集し、gpt-5.6-sol にアクセスできるルートを選択します。
ChatGPT ログインが表示される Codex の全セッションを完全に終了して開き直します。
codex が見つからない 新しいターミナルを開きます。Windows では codex.cmd も試してください。