OpenClaw 🦞
OpenClaw 是一款開源的本地 AI 助手,透過 WhatsApp、Telegram、Slack 等訊息應用與你交互,能執行實際操作 — 管理郵件、日歷、航班值機、瀏覽網頁等。它完全在本地執行,資料不離開你的裝置。
為什麼搭配 OfoxAI?
- 100+ 模型統一呼叫 — 一個 API Key 存取 Claude、GPT、Gemini、Qwen、豆包等所有主流模型
- 靈活的 Agent 策略 — 不同 Agent 分配不同模型,主力用 Sonnet、推理用 Opus、輕量用 Haiku
- 99.9% SLA — 多節點冗餘,自動故障切換
- 成本可控 — 統一計費面板,即時監控 Token 消耗
OpenClaw 作為 Agentic AI 助手,單次任務的 Token 消耗較大(通常 10K-100K+ tokens)。建議根據任務複雜度選擇模型,避免不必要的成本。本文提供三種設定方案供參考。
安裝
curl -sSL https://openclaw.ai/install.sh | bash& ([scriptblock]::Create((iwr -useb https://openclaw.ai/install.ps1)))快速開始
1. 取得 API Key
前往 OfoxAI 控制台 建立 API Key。
2. 執行設定嚮導
OpenClaw 提供交互式嚮導,輸入以下命令即可快速完成設定:
openclaw onboard在嚮導中選擇 Custom Provider,填入以下資訊:
| 設定項 | 值 |
|---|---|
| Provider Type | anthropic-messages |
| Base URL | https://api.ofox.ai/anthropic |
| API Key | 你的 OfoxAI API Key |
| Model | anthropic/claude-sonnet-4.5 |
3. 啟動驗證
openclaw start向 OpenClaw 傳送一條訊息測試連通性。如果收到正常回覆,設定成功。
嚮導會自動生成 openclaw.json 設定文件。如果你需要更細粒度的控制,請參考下方的完整設定。
完整設定
OpenClaw 透過 ~/.openclaw/openclaw.json 管理所有設定(支援 JSON5 格式,可寫註解)。
Provider 設定
Provider 定義在 models.providers 下,每個 Provider 需要指定 API 協議類型、位址和金鑰:
{
"models": {
"providers": {
"ofoxai-anthropic": {
"baseUrl": "https://api.ofox.ai/anthropic",
"apiKey": "${OFOXAI_API_KEY}",
"api": "anthropic-messages",
"models": []
},
"ofoxai-openai": {
"baseUrl": "https://api.ofox.ai/v1",
"apiKey": "${OFOXAI_API_KEY}",
"api": "openai-responses",
"models": []
},
"ofoxai-gemini": {
"baseUrl": "https://api.ofox.ai/gemini",
"apiKey": "${OFOXAI_API_KEY}",
"api": "google-generative-ai",
"models": []
}
}
}
}apiKey 支援 ${ENV_VAR} 語法引用環境變數,避免明文寫入設定文件。三種協議對應不同模型系列:Claude 使用 ofoxai-anthropic(anthropic-messages),OpenAI 使用 ofoxai-openai(openai-responses),Gemini 使用 ofoxai-gemini(google-generative-ai),其餘模型可透過 ofoxai-openai 接入。
Models 設定
模型定義在對應 Provider 的 models 陣列中。我們提供三套方案,根據你的需求選擇:
最強設定
全 Claude 陣容 — 追求最強能力,適合高要求場景。
{
"models": {
"providers": {
"ofoxai-anthropic": {
"baseUrl": "https://api.ofox.ai/anthropic",
"apiKey": "${OFOXAI_API_KEY}",
"api": "anthropic-messages",
"models": [
{
"id": "anthropic/claude-sonnet-4.5",
"name": "Claude Sonnet 4.5",
"input": ["text", "image", "file"],
"contextWindow": 200000,
"maxTokens": 64000
},
{
"id": "anthropic/claude-opus-4.6",
"name": "Claude Opus 4.6",
"reasoning": true,
"input": ["text", "image", "file"],
"contextWindow": 200000,
"maxTokens": 128000
},
{
"id": "anthropic/claude-haiku-4.5",
"name": "Claude Haiku 4.5",
"input": ["text", "image", "file"],
"contextWindow": 200000,
"maxTokens": 64000
}
]
}
}
}
}| 模型 | 角色定位 | 適用場景 |
|---|---|---|
anthropic/claude-sonnet-4.5 | 主力模型 | 日常對話、任務執行、程式碼生成 |
anthropic/claude-opus-4.6 | 深度推理 | 複雜分析、長鏈推理、研究任務 |
anthropic/claude-haiku-4.5 | 快速回應 | 簡單查詢、快速回覆、輕量任務 |
Agents 設定
OpenClaw 透過 agents.defaults 設定全局預設,透過 agents.list 陣列定義不同 Agent,每個 Agent 可覆蓋預設設定:
{
"agents": {
"defaults": {
"model": {
"primary": "ofoxai-anthropic/anthropic/claude-sonnet-4.5",
"fallbacks": ["ofoxai-anthropic/anthropic/claude-haiku-4.5"]
},
"models": {
"ofoxai-anthropic/anthropic/claude-opus-4.6": { "alias": "opus" },
"ofoxai-anthropic/anthropic/claude-sonnet-4.5": { "alias": "sonnet" },
"ofoxai-anthropic/anthropic/claude-haiku-4.5": { "alias": "haiku" }
},
"thinkingDefault": "low",
"timeoutSeconds": 600,
"maxConcurrent": 3
},
"list": [
{
"id": "main",
"default": true
},
{
"id": "research",
"model": {
"primary": "ofoxai-anthropic/anthropic/claude-opus-4.6"
}
},
{
"id": "quick",
"model": {
"primary": "ofoxai-anthropic/anthropic/claude-haiku-4.5"
}
}
]
}
}| Agent | 模型 | 用途 |
|---|---|---|
| main | claude-sonnet-4.5(繼承 defaults) | 預設 Agent,日常所有任務 |
| research | claude-opus-4.6 | 深度研究、複雜推理、長文分析 |
| quick | claude-haiku-4.5 | 簡單問答、快速回應、低成本 |
模型引用格式為 provider名/model-id(如 ofoxai-anthropic/anthropic/claude-sonnet-4.5)。defaults 中的 models 欄位定義模型別名,可在對話中用 /model opus 快速切換。list 中的 Agent 會繼承 defaults 的所有設定,只需覆蓋需要變更的欄位。
完整設定示例
以下是一份完整的 openclaw.json,整合了 Provider、Models 和 Agents 設定(最強設定方案):
{
"models": {
"providers": {
"ofoxai-anthropic": {
"baseUrl": "https://api.ofox.ai/anthropic",
"apiKey": "${OFOXAI_API_KEY}",
"api": "anthropic-messages",
"models": [
{
"id": "anthropic/claude-sonnet-4.5",
"name": "Claude Sonnet 4.5",
"input": ["text", "image", "file"],
"contextWindow": 200000,
"maxTokens": 64000
},
{
"id": "anthropic/claude-opus-4.6",
"name": "Claude Opus 4.6",
"reasoning": true,
"input": ["text", "image", "file"],
"contextWindow": 200000,
"maxTokens": 128000
},
{
"id": "anthropic/claude-haiku-4.5",
"name": "Claude Haiku 4.5",
"input": ["text", "image", "file"],
"contextWindow": 200000,
"maxTokens": 64000
}
]
},
"ofoxai-gemini": {
"baseUrl": "https://api.ofox.ai/gemini",
"apiKey": "${OFOXAI_API_KEY}",
"api": "google-generative-ai",
"models": [
{
"id": "models/google/gemini-2.5-flash",
"name": "Gemini 2.5 Flash",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 1000000,
"maxTokens": 64000
},
{
"id": "models/google/gemini-2.5-pro",
"name": "Gemini 2.5 Pro",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 1000000,
"maxTokens": 64000
}
]
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "ofoxai-anthropic/anthropic/claude-sonnet-4.5",
"fallbacks": ["ofoxai-anthropic/anthropic/claude-haiku-4.5"]
},
"models": {
"ofoxai-anthropic/anthropic/claude-opus-4.6": { "alias": "opus" },
"ofoxai-anthropic/anthropic/claude-sonnet-4.5": { "alias": "sonnet" },
"ofoxai-anthropic/anthropic/claude-haiku-4.5": { "alias": "haiku" }
},
"thinkingDefault": "low",
"timeoutSeconds": 600,
"maxConcurrent": 3
},
"list": [
{
"id": "main",
"default": true
},
{
"id": "research",
"model": {
"primary": "ofoxai-anthropic/anthropic/claude-opus-4.6"
}
},
{
"id": "quick",
"model": {
"primary": "ofoxai-anthropic/anthropic/claude-haiku-4.5"
}
}
]
}
}使用場景
設定完成後,透過訊息應用向 OpenClaw 傳送指令:
- 郵件管理 — “幫我整理今天未讀的郵件,按優先級排序”
- 日程安排 — “明天下午 3 點安排一個團隊會議”
- 資訊檢索 — “搜尋最近關於 AI Agent 的技術文章,總結要點”
- 程式碼輔助 — “幫我 review 這段 Python 程式碼,檢查安全問題”
- 工作流自動化 — “每天早上 9 點傳送團隊日报到 Slack #general 頻道”
故障排除
無法連線 OfoxAI
確認 baseUrl 設定正確:
- Anthropic 協議:
https://api.ofox.ai/anthropic - OpenAI-Response 協議:
https://api.ofox.ai/v1 - Gemini 協議:
https://api.ofox.ai/gemini
模型不存在
確認模型 ID 格式正確。在 models.providers 中定義模型時,id 使用 OfoxAI 回傳的完整 ID(如 anthropic/claude-sonnet-4.5)。在 agents 中引用模型時需要加 Provider 名前綴:ofoxai-anthropic/anthropic/claude-sonnet-4.5。
Token 消耗過高
OpenClaw 單次任務消耗較大,建議:
- 日常任務使用
claude-haiku-4.5或性價比模型 - 僅在複雜任務時切換到
researchAgent(使用claude-opus-4.6) - 在 OfoxAI 控制台 監控用量
如何快速切換模型
在對話中使用別名切換:/model opus、/model sonnet、/model haiku(需要在 agents.defaults.models 中設定別名)。