跳至主要內容
所有用戶端
Multi-Provider TUI · 1M Context & Variants1M Context · ZDR

OpenCode

內建多供應商註冊表的開源終端代理。

基礎網址
https://api.bf16.ai/v1
協定
openai-completions

適用對象
同時設定多個模型供應商、依任務隨時切換模型的開發者。

架構原理與接入優勢

OpenCode (~/.config/opencode/opencode.json) connected to api.bf16.ai/v1 with 1M context, vision modalities, and reasoning effort variants
OpenCode loads bf16 alongside your existing providers from ~/.config/opencode/opencode.json, exposing /models switching and Ctrl+T reasoning variants.

OpenCode is a fast open-source terminal coding agent built around a declarative provider registry (`~/.config/opencode/opencode.json`). Developers love OpenCode because you can keep Anthropic, OpenAI, and bf16 configured side-by-side and switch to an uncensored 1M-context model mid-project with `/models` whenever a stock provider refuses a security audit or binary reverse-engineering task.

When signed in on this page, the JSON snippet below dynamically includes every active model on your bf16.ai account — complete with `attachment: true`, `modalities`, `limit: { context: 1048576 }`, and `ctrl+t` reasoning effort variants.

指令預設顯示 $BF16_API_KEY。登入並建立金鑰後會自動填入你的真實金鑰。

一鍵快速配置

One-Command Non-Destructive OpenCode Config Merge

Backs up ~/.config/opencode/opencode.json if it exists, merges the complete `provider.bf16` block without touching your other providers, and tests `/v1/models`.

export BF16_API_KEY="sk-bf16-v1-..."
mkdir -p ~/.config/opencode
node -e '
const fs = require("fs"), os = require("os"), path = require("path");
const file = path.join(os.homedir(), ".config/opencode/opencode.json");
const snippet = "{\n  \"$schema\": \"https://opencode.ai/config.json\",\n  \"provider\": {\n    \"bf16\": {\n      \"npm\": \"@ai-sdk/openai-compatible\",\n      \"name\": \"bf16.ai\",\n      \"options\": {\n        \"baseURL\": \"https://api.bf16.ai/v1\",\n        \"apiKey\": \"{env:BF16_API_KEY}\"\n      },\n      \"models\": {\n        \"zai-org/glm-5.3-uncensored\": {\n          \"name\": \"Uncensored GLM-5.3\",\n          \"reasoning\": true,\n          \"temperature\": true,\n          \"tool_call\": true,\n          \"modalities\": { \"input\": [\"text\"], \"output\": [\"text\"] },\n          \"limit\": { \"context\": 1048576, \"output\": 131072 }\n        },\n        \"zai-org/glm-5.3-flash-uncensored\": {\n          \"name\": \"Uncensored GLM-5.3 Flash Vision\",\n          \"attachment\": true,\n          \"reasoning\": true,\n          \"temperature\": true,\n          \"tool_call\": true,\n          \"modalities\": { \"input\": [\"text\", \"image\"], \"output\": [\"text\"] },\n          \"limit\": { \"context\": 1048576, \"output\": 131072 }\n        },\n        \"deepseek/deepseek-v4.1-flash-uncensored\": {\n          \"name\": \"Uncensored DeepSeek V4.1 Flash\",\n          \"attachment\": true,\n          \"reasoning\": true,\n          \"temperature\": true,\n          \"tool_call\": true,\n          \"modalities\": { \"input\": [\"text\", \"image\"], \"output\": [\"text\"] },\n          \"limit\": { \"context\": 1048576, \"output\": 130000 }\n        },\n        \"deepseek/deepseek-v4.1-flash-uncensored-fast\": {\n          \"name\": \"Uncensored DeepSeek V4.1 Flash Fast\",\n          \"attachment\": true,\n          \"reasoning\": true,\n          \"temperature\": true,\n          \"tool_call\": true,\n          \"modalities\": { \"input\": [\"text\", \"image\"], \"output\": [\"text\"] },\n          \"limit\": { \"context\": 1048576, \"output\": 130000 }\n        },\n        \"bf16/deepseek-v4.1-flash-1017-exl3-2.5bpw\": {\n          \"name\": \"DeepSeek V4.1 Flash 1017 EXL3 2.5bpw (bf16)\",\n          \"attachment\": true,\n          \"reasoning\": true,\n          \"temperature\": true,\n          \"tool_call\": true,\n          \"modalities\": { \"input\": [\"text\", \"image\"], \"output\": [\"text\"] },\n          \"limit\": { \"context\": 524288, \"output\": 65536 }\n        },\n        \"moonshotai/kimi-k3.1-pro-uncensored\": {\n          \"name\": \"Uncensored Kimi K3.1 Pro\",\n          \"attachment\": true,\n          \"reasoning\": true,\n          \"temperature\": true,\n          \"tool_call\": true,\n          \"modalities\": { \"input\": [\"text\", \"image\"], \"output\": [\"text\"] },\n          \"limit\": { \"context\": 1048576, \"output\": 131072 }\n        }\n      }\n    }\n  }\n}";
const incoming = JSON.parse(snippet);
let current = { "$schema": "https://opencode.ai/config.json", provider: {} };
if (fs.existsSync(file)) {
  fs.copyFileSync(file, file + ".bak");
  try { current = JSON.parse(fs.readFileSync(file, "utf8")); } catch {}
}
current.provider = Object.assign({}, current.provider || {}, incoming.provider);
fs.writeFileSync(file, JSON.stringify(current, null, 2) + "\n");
console.log("Merged provider.bf16 into " + file);
' && curl -fsS "https://api.bf16.ai/v1/models" -H "Authorization: Bearer $BF16_API_KEY" >/dev/null && echo "Ready! Run: opencode --model bf16/zai-org/glm-5.3-uncensored"
  1. 1

    匯出你的 API 金鑰

    OpenCode 會讀取環境變數 BF16_API_KEY。

    export BF16_API_KEY=sk-bf16-v1-...
  2. 2

    將 bf16 加入設定檔

    全新檔案可直接整段貼上;若已有設定檔,只需將 bf16 區塊貼進現有 "provider" 物件內。

    ~/.config/opencode/opencode.json
    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "bf16": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "bf16.ai",
          "options": {
            "baseURL": "https://api.bf16.ai/v1",
            "apiKey": "{env:BF16_API_KEY}"
          },
          "models": {
            "zai-org/glm-5.3-uncensored": {
              "name": "Uncensored GLM-5.3",
              "reasoning": true,
              "temperature": true,
              "tool_call": true,
              "modalities": { "input": ["text"], "output": ["text"] },
              "limit": { "context": 1048576, "output": 131072 }
            },
            "zai-org/glm-5.3-flash-uncensored": {
              "name": "Uncensored GLM-5.3 Flash Vision",
              "attachment": true,
              "reasoning": true,
              "temperature": true,
              "tool_call": true,
              "modalities": { "input": ["text", "image"], "output": ["text"] },
              "limit": { "context": 1048576, "output": 131072 }
            },
            "deepseek/deepseek-v4.1-flash-uncensored": {
              "name": "Uncensored DeepSeek V4.1 Flash",
              "attachment": true,
              "reasoning": true,
              "temperature": true,
              "tool_call": true,
              "modalities": { "input": ["text", "image"], "output": ["text"] },
              "limit": { "context": 1048576, "output": 130000 }
            },
            "deepseek/deepseek-v4.1-flash-uncensored-fast": {
              "name": "Uncensored DeepSeek V4.1 Flash Fast",
              "attachment": true,
              "reasoning": true,
              "temperature": true,
              "tool_call": true,
              "modalities": { "input": ["text", "image"], "output": ["text"] },
              "limit": { "context": 1048576, "output": 130000 }
            },
            "bf16/deepseek-v4.1-flash-1017-exl3-2.5bpw": {
              "name": "DeepSeek V4.1 Flash 1017 EXL3 2.5bpw (bf16)",
              "attachment": true,
              "reasoning": true,
              "temperature": true,
              "tool_call": true,
              "modalities": { "input": ["text", "image"], "output": ["text"] },
              "limit": { "context": 524288, "output": 65536 }
            },
            "moonshotai/kimi-k3.1-pro-uncensored": {
              "name": "Uncensored Kimi K3.1 Pro",
              "attachment": true,
              "reasoning": true,
              "temperature": true,
              "tool_call": true,
              "modalities": { "input": ["text", "image"], "output": ["text"] },
              "limit": { "context": 1048576, "output": 131072 }
            }
          }
        }
      }
    }
  3. 3

    選擇模型並測試對話

    opencode --model bf16/zai-org/glm-5.3-flash-uncensored
OpenCode — ~/.config/opencode/opencode.json
介面與設定檔欄位對照
provider.bf16 · @ai-sdk/openai-compatible

關鍵參數核對清單

Config Path (macOS/Linux)
~/.config/opencode/opencode.json

Windows: %USERPROFILE%\.config\opencode\opencode.json

options.baseURL
https://api.bf16.ai/v1
options.apiKey
{env:BF16_API_KEY}

Note: if you previously ran /connect, re-run /connect after key rotation.

Cycle Reasoning Effort
Ctrl + T (low → high → max)
OpenCode sends raw clipboard screenshots without client-side compression; bf16.ai downscales oversized PNGs in RAM automatically so sessions never error.

推薦模型分層配置

架構規劃使用旗艦模型,高頻子任務與螢幕截圖使用 Flash 模型以節省開銷。

工作流角色模型 ID選型說明USD / 1M Tokens
Primary Coding & Security Auditszai-org/glm-5.3-uncensoredFlagship multi-file tool calling with low/high/max reasoning variants (`Ctrl+T`).$1.35 in / $0.25 cached / $4.20 out
2.8T Multimodal Architecture & Visionmoonshotai/kimi-k3.1-pro-uncensoredAccepts UI mockups + 1M-token repositories simultaneously.$1.95 in / $0.28 cached / $6.90 out
Fast Exploration & Screenshotsdeepseek/deepseek-v4.1-flash-uncensoredHigh-throughput tool loops + Vision input at $0.26 / $1.00 per 1M.$0.26 in / $0.045 cached / $1.00 out

如何確認設定成功

  • OpenCode 的 /models 清單中出現 bf16。
  • 傳送 "Say ok." 後,控制台日誌即會出現該筆請求。
  • curl https://api.bf16.ai/v1/models -H "Authorization: Bearer $BF16_API_KEY"

生產環境護欄與預算隔離

  • Remember top-level key is singular `"provider"` in opencode.json (never `"providers"`).
  • If you store credentials via `/connect` inside OpenCode, OpenCode caches that token in `~/.local/share/opencode/auth.json` with higher priority than `{env:BF16_API_KEY}`.

常見錯誤

現象
輪換金鑰後出現 Invalid API key。
原因
OpenCode 另外儲存了先前輸入的金鑰,且優先於設定檔。
解法
建立新金鑰後,請透過 OpenCode 內建的 connect 流程重新輸入一次。
現象
模型清單為空白。
原因
baseURL 缺少結尾的 /v1。
解法
請使用 https://api.bf16.ai/v1。

還沒安裝?

curl -fsSL https://opencode.ai/install | bash
官方文件