OpenCode 設定
將 OpenCode 作為 OpenAI 相容提供者連接至 Modelflare,並在支援的模型與模型群組間切換。
1. 建立 API 金鑰
建立一個Modelflare API金鑰,其非預設群組可以存取gpt-5.6-sol。
2. 安裝 OpenCode
Windows PowerShell
choco install opencode
opencode --version
Linux 或 macOS
curl -fsSL https://opencode.ai/install | bash
opencode --version
3. 建立 opencode.json
輸入您的專案目錄,然後執行適合您的系統的命令。
Windows PowerShell
$config = @'
{
"$schema": "https://opencode.ai/config.json",
"model": "modelflare/gpt-5.6-sol",
"provider": {
"modelflare": {
"npm": "@ai-sdk/openai-compatible",
"name": "Modelflare",
"options": { "baseURL": "https://modelflare.dev/v1" },
"models": {
"gpt-5.6-sol": { "name": "GPT 5.6 Sol" }
}
}
}
}
'@
$utf8NoBom = New-Object System.Text.UTF8Encoding -ArgumentList $false
[System.IO.File]::WriteAllText(
(Join-Path (Get-Location) "opencode.json"),
$config,
$utf8NoBom
)
Linux 或 macOS
cat > opencode.json << 'EOF'
{
"$schema": "https://opencode.ai/config.json",
"model": "modelflare/gpt-5.6-sol",
"provider": {
"modelflare": {
"npm": "@ai-sdk/openai-compatible",
"name": "Modelflare",
"options": { "baseURL": "https://modelflare.dev/v1" },
"models": {
"gpt-5.6-sol": { "name": "GPT 5.6 Sol" }
}
}
}
}
EOF
4. 連接您的 API 金鑰
在同一專案目錄中啟動OpenCode:
opencode
輸入 /connect,選擇 其他,將提供者 ID 設定為 modelflare,然後貼上您的 Modelflare API 金鑰。
5. 選擇模型並測試
輸入/models,選擇modelflare/gpt-5.6-sol,發送:
回覆一句簡短的問候。
正常回覆表示設定完成。