|
| 1 | +# OpenClaw + Plano: Smart Model Routing for Personal AI Assistants |
| 2 | + |
| 3 | +OpenClaw is an open-source personal AI assistant that connects to WhatsApp, Telegram, Slack, and Discord. By pointing it at Plano instead of a single LLM provider, every message is automatically routed to the best model — conversational requests go to Kimi K2.5 (cost-effective), while code generation, testing, and complex reasoning go to Claude (most capable) — with zero application code changes. |
| 4 | + |
| 5 | +## Architecture |
| 6 | + |
| 7 | +``` |
| 8 | +[WhatsApp / Telegram / Slack / Discord] |
| 9 | + | |
| 10 | + [OpenClaw Gateway] |
| 11 | + ws://127.0.0.1:18789 |
| 12 | + | |
| 13 | + [Plano :12000] ──────────────> Kimi K2.5 (conversation, agentic tasks) |
| 14 | + | $0.60/M input tokens |
| 15 | + |──────────────────────> Claude (code, tests, reasoning) |
| 16 | + | |
| 17 | + [Arch-Router 1.5B] |
| 18 | + (local via Ollama, ~200ms) |
| 19 | +``` |
| 20 | + |
| 21 | +Plano's 1.5B [Arch-Router](https://arxiv.org/abs/2506.16655) model analyzes each prompt locally and selects the best backend based on configured routing preferences. |
| 22 | + |
| 23 | +## Prerequisites |
| 24 | + |
| 25 | +- **Docker** running |
| 26 | +- **Ollama** installed ([ollama.com](https://ollama.com)) |
| 27 | +- **Plano CLI**: `uv tool install planoai` or `pip install planoai` |
| 28 | +- **OpenClaw**: `npm install -g openclaw@latest` |
| 29 | +- **API keys**: |
| 30 | + - `MOONSHOT_API_KEY` — from [Moonshot AI](https://platform.moonshot.cn/) |
| 31 | + - `ANTHROPIC_API_KEY` — from [Anthropic](https://console.anthropic.com/) |
| 32 | + |
| 33 | +## Quick Start |
| 34 | + |
| 35 | +### 1. Set Environment Variables |
| 36 | + |
| 37 | +```bash |
| 38 | +export MOONSHOT_API_KEY="your-moonshot-key" |
| 39 | +export ANTHROPIC_API_KEY="your-anthropic-key" |
| 40 | +``` |
| 41 | + |
| 42 | +### 2. Start the Demo |
| 43 | + |
| 44 | +```bash |
| 45 | +cd demos/llm_routing/openclaw_routing |
| 46 | +bash run_demo.sh |
| 47 | +``` |
| 48 | + |
| 49 | +This will: |
| 50 | +- Pull the Arch-Router model into Ollama |
| 51 | +- Start Jaeger for tracing |
| 52 | +- Start Plano on port 12000 |
| 53 | + |
| 54 | +### 3. Configure OpenClaw |
| 55 | + |
| 56 | +In `~/.openclaw/openclaw.json`, set: |
| 57 | + |
| 58 | +```json |
| 59 | +{ |
| 60 | + "agent": { |
| 61 | + "model": "kimi-k2.5", |
| 62 | + "baseURL": "http://127.0.0.1:12000/v1" |
| 63 | + } |
| 64 | +} |
| 65 | +``` |
| 66 | + |
| 67 | +Then run: |
| 68 | + |
| 69 | +```bash |
| 70 | +openclaw onboard --install-daemon |
| 71 | +``` |
| 72 | + |
| 73 | +### 4. Test Routing |
| 74 | + |
| 75 | +Run the test script to verify routing decisions: |
| 76 | + |
| 77 | +```bash |
| 78 | +bash test_routing.sh |
| 79 | +``` |
| 80 | + |
| 81 | +## Demo Scenarios |
| 82 | + |
| 83 | +| # | Message | Expected Route | Why | |
| 84 | +|---|---------|---------------|-----| |
| 85 | +| 1 | "Hey, what's up? Tell me something interesting." | **Kimi K2.5** | General conversation — cheap and fast | |
| 86 | +| 2 | "Remind me tomorrow at 9am and ping Slack about the deploy" | **Kimi K2.5** | Agentic multi-step task orchestration | |
| 87 | +| 3 | "Write a Python rate limiter with the token bucket algorithm" | **Claude** | Code generation — needs precision | |
| 88 | +| 4 | "Write unit tests for the auth middleware, cover edge cases" | **Claude** | Testing & evaluation — needs thoroughness | |
| 89 | +| 5 | "Compare WebSockets vs SSE vs polling for 10K concurrent users" | **Claude** | Complex reasoning — needs deep analysis | |
| 90 | + |
| 91 | +OpenClaw's code doesn't change at all. It points at `http://127.0.0.1:12000/v1` instead of a direct provider URL. Plano's Arch-Router analyzes each prompt in ~200ms and picks the right backend. |
| 92 | + |
| 93 | +## Monitoring |
| 94 | + |
| 95 | +### Routing Decisions |
| 96 | + |
| 97 | +Watch Plano logs for model selection: |
| 98 | + |
| 99 | +```bash |
| 100 | +docker logs plano 2>&1 | grep MODEL_RESOLUTION |
| 101 | +``` |
| 102 | + |
| 103 | +### Jaeger Tracing |
| 104 | + |
| 105 | +Open [http://localhost:16686](http://localhost:16686) to see full traces of each request, including which model was selected and the routing latency. |
| 106 | + |
| 107 | +## Cost Impact |
| 108 | + |
| 109 | +For a personal assistant handling ~1000 requests/day with a 60/40 conversation-to-code split: |
| 110 | + |
| 111 | +| Without Plano (all Claude) | With Plano (routed) | |
| 112 | +|---|---| |
| 113 | +| 1000 req x Claude pricing | 600 req x Kimi K2.5 + 400 req x Claude | |
| 114 | +| ~$3.00/day input tokens | ~$0.36 + $1.20 = **$1.56/day** (~48% savings) | |
| 115 | + |
| 116 | +Same quality where it matters (code, tests), lower cost where it doesn't (chat). |
| 117 | + |
| 118 | +## Stopping the Demo |
| 119 | + |
| 120 | +```bash |
| 121 | +bash run_demo.sh down |
| 122 | +``` |
0 commit comments