OpenCode
複数プロバイダを登録できるオープンソースのターミナルエージェント。
https://api.bf16.ai/v1openai-completions対象ユーザー
複数のプロバイダを併用し、用途に応じてモデルを切り替える開発者向け。
アーキテクチャと bf16.ai 連携の利点
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.
セットアップ
サインインしてAPIキーを自動入力 →コマンドには $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
APIキーをエクスポート
OpenCode は環境変数 BF16_API_KEY からキーを読み込みます。
export BF16_API_KEY=sk-bf16-v1-... - 2
設定ファイルに bf16 を追加
新規作成なら全体を貼り付け、既存ファイルがある場合は "provider" 内に bf16 ブロックだけを追加します。
~/.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
モデルを指定して起動
opencode --model bf16/zai-org/glm-5.3-flash-uncensored
入力パラメータ早見表
~/.config/opencode/opencode.jsonWindows: %USERPROFILE%\.config\opencode\opencode.json
https://api.bf16.ai/v1{env:BF16_API_KEY}Note: if you previously ran /connect, re-run /connect after key rotation.
Ctrl + T (low → high → max)用途別おすすめモデル構成
設計・監査には Flagship モデル、並列サブタスクや画面認識には Flash モデルを組み合わせます。
| 役割 | モデル ID | 選定理由 | USD / 1M トークン |
|---|---|---|---|
| Primary Coding & Security Audits | zai-org/glm-5.3-uncensored | Flagship 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 & Vision | moonshotai/kimi-k3.1-pro-uncensored | Accepts UI mockups + 1M-token repositories simultaneously. | $1.95 in / $0.28 cached / $6.90 out |
| Fast Exploration & Screenshots | deepseek/deepseek-v4.1-flash-uncensored | High-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}`.