š Local First Llm OpenClaw Plugin & Skill | ClawHub
Looking to integrate Local First Llm into your AI workflows? This free OpenClaw plugin from ClawHub helps you automate coding agents & ides tasks instantly, without having to write custom tools from scratch.
What this skill does
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 persistent dashboard. Use when: (1) user asks to run a task with a local model first, (2) user wants to reduce cloud API costs or keep requests private, (3) user asks to see their token savings or LLM routing dashboard, (4) any request where local-vs-cloud routing should be decided automatically. Supports Ollama, LM Studio, and llamafile as local providers.
Install
openclaw skills install @joelnishanth/local-first-llmnpx clawhub@latest install local-first-llmFull SKILL.md
Open original| name | description |
|---|---|
| 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 persistent dashboard. Use when: (1) user asks to run a task with a local model first, (2) user wants to reduce cloud API costs or keep requests private, (3) user asks to see their token savings or LLM routing dashboard, (4) any request where local-vs-cloud routing should be decided automatically. Supports Ollama, LM Studio, and llamafile as local providers. |
SKILL.md content below is scrollable.
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 < 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