Local-First LLM
/install local-first-llm
Local-First LLM
Route requests to a local LLM first; fall back to cloud only when necessary. Track every decision to show real token and cost savings.
Quick Start
1. Check if a local LLM is running
python3 skills/local-first-llm/scripts/check_local.py
Returns JSON: { "any_available": true, "best": { "provider": "ollama", "models": [...] } }
2. Route a request
python3 skills/local-first-llm/scripts/route_request.py \
--prompt "Summarize this meeting transcript" \
--tokens 800 \
--local-available \
--local-provider ollama
Returns: { "decision": "local", "reason": "...", "complexity_score": -1 }
3. Log the outcome
After executing the request, record it:
python3 skills/local-first-llm/scripts/track_savings.py log \
--tokens 800 \
--model gpt-4o \
--routed-to local
4. Show the dashboard
python3 skills/local-first-llm/scripts/dashboard.py
Full Routing Workflow
┌─────────────────────────────────────────────────────┐
│ 1. check_local.py → is a local provider running? │
│ │
│ 2. route_request.py → local or cloud? │
│ - sensitivity check (private data → local) │
│ - complexity score (high score → cloud) │
│ - availability gate (no local → cloud) │
│ │
│ 3. Execute with the chosen provider │
│ │
│ 4. track_savings.py log → record the outcome │
│ │
│ 5. dashboard.py → show cumulative savings │
└─────────────────────────────────────────────────────┘
Routing Rules (Summary)
| Condition | Route |
|---|---|
| No local provider available | ☁️ Cloud |
Prompt contains sensitive data (password, secret, api key, ssn, etc.) |
🏠 Local |
| Complexity score ≥ 3 | ☁️ Cloud |
| Complexity score \x3C 3 | 🏠 Local |
For full scoring details, see references/routing-logic.md.
Executing with a Local Provider
Once route_request.py returns "decision": "local", send the request:
Ollama
curl http://localhost:11434/api/generate \
-d '{"model": "llama3.2", "prompt": "YOUR_PROMPT", "stream": false}'
LM Studio / llamafile (OpenAI-compatible)
curl http://localhost:1234/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "local-model", "messages": [{"role": "user", "content": "YOUR_PROMPT"}]}'
Dashboard
The dashboard reads from ~/.openclaw/local-first-llm/savings.json (auto-created).
┌─────────────────────────────────────────┐
│ 🧠 Local-First LLM — Dashboard │
├─────────────────────────────────────────┤
│ Local LLM: ✅ ollama (llama3.2...) │
├─────────────────────────────────────────┤
│ Total requests: 42 │
│ Routed locally: 31 (73.8%) │
│ Routed to cloud: 11 │
├─────────────────────────────────────────┤
│ Tokens saved: 84,200 │
│ Cost saved: $0.4210 │
└─────────────────────────────────────────┘
Reset savings data:
python3 skills/local-first-llm/scripts/track_savings.py reset
Additional References
- Routing scoring details: references/routing-logic.md
- Local provider setup (Ollama, LM Studio, llamafile): references/local-providers.md
- Token estimation & cloud cost table: references/token-estimation.md
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install local-first-llm - 安装完成后,直接呼叫该 Skill 的名称或使用
/local-first-llm触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
Local-First LLM 是什么?
Routes LLM requests to a local model (Ollama, LM Studio, llamafile) before falling back to cloud APIs. Tracks token savings and cost avoidance in a persisten... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 601 次。
如何安装 Local-First LLM?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install local-first-llm」即可一键安装,无需额外配置。
Local-First LLM 是免费的吗?
是的,Local-First LLM 完全免费(开源免费),可自由下载、安装和使用。
Local-First LLM 支持哪些平台?
Local-First LLM 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Local-First LLM?
由 joelnishanth(@joelnishanth)开发并维护,当前版本 v1.0.0。