程式設計助手
Codex 設定
使用安裝程式或使用 Modelflare 金鑰和 Responses 相容模型手動配置 Codex。
本指南將 Codex 連接到 Modelflare 並執行其第一個請求。使用選項 A 進行自動設定。首先使用選項 B 安裝 Codex,然後自行建立每個所需的檔案。
1.建立API金鑰
Section titled “1.建立API金鑰”登入 Modelflare 控制台,開啟 API Keys,然後建立可以存取 gpt-5.6-sol 的金鑰。選擇列出模型的任何可用的非預設組;沒有單一的必需組。
準備好鑰匙。您可以使用安裝程式或手動設定相同的檔案。
2. 選擇設定方法
Section titled “2. 選擇設定方法”選項 A:執行安裝程序
Section titled “選項 A:執行安裝程序”還不熟悉終端?從互動式首次運行指南開始。這只是一個視覺排練,不會改變您的電腦。
以一般使用者身分執行此指令:
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。該腳本會安裝或更新 Codex、備份現有檔案、詢問您的 Modelflare API 金鑰,並在 ~/.codex 下寫入提供者設定。
以一般 Windows 使用者身分開啟 PowerShell 並執行:
irm https://modelflare.dev/install/codex.ps1 | iex安裝程式會要求您提供語言和 Modelflare API 金鑰,驗證對 gpt-5.6-sol 的存取權限,並在變更之前備份現有檔案。完成後,繼續驗證連線。
选项 B:自己创建每个 Codex 文件
Section titled “选项 B:自己创建每个 Codex 文件”當您不想執行 Modelflare 設定腳本時,請使用此選項。按順序執行步驟,並在每個步驟中使用適合您的作業系統的命令區塊。
選項 B 在使用者層級 .codex 目錄下建立兩個檔案:config.toml 和 auth.json。
第 1 步:安裝 Codex CLI
Section titled “第 1 步:安裝 Codex CLI”irm https://chatgpt.com/codex/install.ps1 | iexcodex --versioncurl -fsSL https://chatgpt.com/codex/install.sh | shcodex --versioncurl -fsSL https://chatgpt.com/codex/install.sh | shcodex --version第二步:建立並進入.codex目錄
Section titled “第二步:建立並進入.codex目錄”New-Item -ItemType Directory -Force "$HOME\.codex" | Out-NullSet-Location "$HOME\.codex"mkdir -p ~/.codexcd ~/.codexmkdir -p ~/.codexcd ~/.codex第3步:建立config.toml
Section titled “第3步:建立config.toml”$config = @'cli_auth_credentials_store = "file"model_provider = "modelflare"model = "gpt-5.6-sol"model_reasoning_effort = "xhigh"disable_response_storage = truemodel_supports_reasoning_summaries = true
[model_providers.modelflare]name = "Modelflare"base_url = "https://modelflare.dev/v1"wire_api = "responses"requires_openai_auth = true'@$utf8NoBom = New-Object System.Text.UTF8Encoding -ArgumentList $false[System.IO.File]::WriteAllText( (Join-Path (Get-Location) "config.toml"), $config, $utf8NoBom)cat > config.toml << 'EOF'cli_auth_credentials_store = "file"model_provider = "modelflare"model = "gpt-5.6-sol"model_reasoning_effort = "xhigh"disable_response_storage = truemodel_supports_reasoning_summaries = true
[model_providers.modelflare]name = "Modelflare"base_url = "https://modelflare.dev/v1"wire_api = "responses"requires_openai_auth = trueEOFchmod 600 config.tomlcat > config.toml << 'EOF'cli_auth_credentials_store = "file"model_provider = "modelflare"model = "gpt-5.6-sol"model_reasoning_effort = "xhigh"disable_response_storage = truemodel_supports_reasoning_summaries = true
[model_providers.modelflare]name = "Modelflare"base_url = "https://modelflare.dev/v1"wire_api = "responses"requires_openai_auth = trueEOFchmod 600 config.toml第4步:創建auth.json
Section titled “第4步:創建auth.json”將 JSON 物件中的 YOUR_MODELFLARE_API_KEY 替換為您在 Modelflare 控制台中建立的完整 API 金鑰。該檔案必須保持有效的 JSON 並使用 OPENAI_API_KEY 欄位;不要新增提供者auth命令區塊。目前 Codex 版本需要 requires_openai_auth = true 作為此 API 金鑰路徑。
$authJson = @'{ "auth_mode": "apikey", "OPENAI_API_KEY": "YOUR_MODELFLARE_API_KEY"}'@$utf8NoBom = New-Object System.Text.UTF8Encoding -ArgumentList $false[System.IO.File]::WriteAllText( (Join-Path (Get-Location) "auth.json"), $authJson, $utf8NoBom)cat > auth.json << 'EOF'{ "auth_mode": "apikey", "OPENAI_API_KEY": "YOUR_MODELFLARE_API_KEY"}EOFchmod 600 auth.jsoncat > auth.json << 'EOF'{ "auth_mode": "apikey", "OPENAI_API_KEY": "YOUR_MODELFLARE_API_KEY"}EOFchmod 600 auth.json第5步:啟動Codex
Section titled “第5步:啟動Codex”Set-Location $HOMENew-Item -ItemType Directory -Force "my-codex-project" | Out-NullSet-Location "my-codex-project"codex --model gpt-5.6-solcd ~mkdir -p my-codex-projectcd my-codex-projectcodex --model gpt-5.6-solcd ~mkdir -p my-codex-projectcd my-codex-projectcodex --model gpt-5.6-sol3. 驗證連接
Section titled “3. 驗證連接”如果您使用了安裝程序,請完全關閉所有已開啟的 Codex CLI、IDE 或桌面工作階段。開啟一個新終端,進入專案目錄,然後執行:
codex --model gpt-5.6-sol完成設定後,您也可以下載Codex App。
然後問Codex:
Reply with one sentence confirming the active model and provider.正常響應表示設定完成。
| 症狀 | 該怎麼辦 |
|---|---|
401 |
重新複製 API 金鑰並確認其未被刪除或停用。 |
model_not_found |
編輯API金鑰並選擇可以存取gpt-5.6-sol的群組。 |
| ChatGPT 登入出現 | 完全退出每個 Codex 會話並重新開啟 CLI。 |
codex |
開啟一個新終端。在 Windows 上,試試 codex.cmd。 |