| | --- |
| | license: mit |
| | tags: |
| | - tutorial |
| | - crazyrouter |
| | - openclaw |
| | - ai-agent |
| | - chatbot |
| | - telegram |
| | - discord |
| | - whatsapp |
| | - llm |
| | language: |
| | - en |
| | - zh |
| | --- |
| | |
| | # ๐ค OpenClaw + Crazyrouter: Build Your AI Agent in Minutes |
| |
|
| | > Use Crazyrouter as the LLM backend for [OpenClaw](https://github.com/openclaw/openclaw) โ an open-source AI agent that lives in your Telegram, Discord, WhatsApp, and more. |
| |
|
| | ## What is OpenClaw? |
| |
|
| | [OpenClaw](https://docs.openclaw.ai) is an open-source autonomous AI agent framework. It connects to messaging platforms (Telegram, Discord, WhatsApp, Slack, Signal, iMessage...) and gives you a personal AI assistant that can: |
| |
|
| | - ๐ฌ Chat naturally across all your messaging apps |
| | - ๐ง Execute code, browse the web, manage files |
| | - โฐ Run scheduled tasks (cron jobs, reminders) |
| | - ๐ง Maintain persistent memory across sessions |
| | - ๐ Extend with custom skills and plugins |
| |
|
| | **Crazyrouter** is the perfect backend โ one API key gives OpenClaw access to 624+ models from OpenAI, Anthropic, Google, DeepSeek, and more. |
| |
|
| | --- |
| |
|
| | ## Quick Start |
| |
|
| | ### Step 1: Install OpenClaw |
| |
|
| | ```bash |
| | # macOS / Linux |
| | curl -fsSL https://openclaw.ai/install.sh | bash |
| | |
| | # Windows (PowerShell) |
| | iwr -useb https://openclaw.ai/install.ps1 | iex |
| | ``` |
| |
|
| | Requires Node.js 22+. |
| |
|
| | ### Step 2: Get Your Crazyrouter API Key |
| |
|
| | 1. Go to [crazyrouter.com](https://crazyrouter.com/?utm_source=huggingface&utm_medium=tutorial&utm_campaign=dev_community) |
| | 2. Sign up and get your API key (`sk-...`) |
| |
|
| | ### Step 3: Run the Onboarding Wizard |
| |
|
| | ```bash |
| | openclaw onboard --install-daemon |
| | ``` |
| |
|
| | When prompted for auth, choose **API key** and enter your Crazyrouter key. |
| |
|
| | Or set it up non-interactively: |
| |
|
| | ```bash |
| | openclaw onboard \ |
| | --auth-choice apiKey \ |
| | --token-provider crazyrouter \ |
| | --token "sk-your-crazyrouter-key" |
| | ``` |
| |
|
| | ### Step 4: Verify |
| |
|
| | ```bash |
| | openclaw gateway status |
| | openclaw dashboard # Opens the web UI |
| | ``` |
| |
|
| | --- |
| |
|
| | ## Configuration |
| |
|
| | Edit `~/.openclaw/openclaw.json` (JSON5 format): |
| |
|
| | ### Minimal Config (Crazyrouter Only) |
| |
|
| | ```json5 |
| | { |
| | models: { |
| | providers: { |
| | crazyrouter: { |
| | baseUrl: "https://crazyrouter.com/v1", |
| | apiKey: "sk-your-crazyrouter-key", |
| | api: "openai-completions", |
| | models: [ |
| | { |
| | id: "claude-opus-4-6", |
| | name: "Claude Opus 4.6", |
| | reasoning: false, |
| | input: ["text", "image"], |
| | contextWindow: 200000, |
| | maxTokens: 8192, |
| | }, |
| | ], |
| | }, |
| | }, |
| | }, |
| | agents: { |
| | defaults: { |
| | model: { primary: "crazyrouter/claude-opus-4-6" }, |
| | workspace: "~/.openclaw/workspace", |
| | }, |
| | }, |
| | } |
| | ``` |
| |
|
| | ### Full Config with Multiple Models |
| |
|
| | ```json5 |
| | { |
| | models: { |
| | providers: { |
| | crazyrouter: { |
| | baseUrl: "https://crazyrouter.com/v1", |
| | apiKey: "sk-your-crazyrouter-key", |
| | api: "openai-completions", |
| | models: [ |
| | // Flagship - best for complex tasks |
| | { |
| | id: "claude-opus-4-6", |
| | name: "Claude Opus 4.6", |
| | reasoning: false, |
| | input: ["text", "image"], |
| | contextWindow: 200000, |
| | maxTokens: 8192, |
| | }, |
| | // Great all-rounder |
| | { |
| | id: "gpt-4o", |
| | name: "GPT-4o", |
| | reasoning: false, |
| | input: ["text", "image"], |
| | contextWindow: 128000, |
| | maxTokens: 8192, |
| | }, |
| | // Fast and cheap |
| | { |
| | id: "gpt-4o-mini", |
| | name: "GPT-4o Mini", |
| | reasoning: false, |
| | input: ["text", "image"], |
| | contextWindow: 128000, |
| | maxTokens: 8192, |
| | }, |
| | // Strong reasoning |
| | { |
| | id: "deepseek-reasoner", |
| | name: "DeepSeek R1", |
| | reasoning: true, |
| | input: ["text"], |
| | contextWindow: 64000, |
| | maxTokens: 8192, |
| | }, |
| | // Budget coding |
| | { |
| | id: "deepseek-chat", |
| | name: "DeepSeek V3", |
| | reasoning: false, |
| | input: ["text"], |
| | contextWindow: 64000, |
| | maxTokens: 8192, |
| | }, |
| | // Speed king |
| | { |
| | id: "gemini-2.0-flash", |
| | name: "Gemini 2.0 Flash", |
| | reasoning: false, |
| | input: ["text", "image"], |
| | contextWindow: 1000000, |
| | maxTokens: 8192, |
| | }, |
| | ], |
| | }, |
| | }, |
| | }, |
| | agents: { |
| | defaults: { |
| | model: { |
| | primary: "crazyrouter/claude-opus-4-6", |
| | fallbacks: ["crazyrouter/gpt-4o"], |
| | }, |
| | models: { |
| | "crazyrouter/gpt-4o-mini": { alias: "Mini" }, |
| | "crazyrouter/deepseek-chat": { alias: "DeepSeek" }, |
| | }, |
| | workspace: "~/.openclaw/workspace", |
| | }, |
| | }, |
| | } |
| | ``` |
| |
|
| | ### Add a Telegram Channel |
| |
|
| | ```json5 |
| | { |
| | // ... models config above ... |
| | channels: { |
| | telegram: { |
| | enabled: true, |
| | botToken: "123456:ABC-your-telegram-bot-token", |
| | dmPolicy: "allowlist", |
| | allowFrom: ["tg:YOUR_TELEGRAM_USER_ID"], |
| | }, |
| | }, |
| | } |
| | ``` |
| |
|
| | ### Add Discord |
| |
|
| | ```json5 |
| | { |
| | channels: { |
| | discord: { |
| | enabled: true, |
| | botToken: "your-discord-bot-token", |
| | dmPolicy: "pairing", |
| | }, |
| | }, |
| | } |
| | ``` |
| |
|
| | --- |
| |
|
| | ## Switch Models On-the-fly |
| |
|
| | Once configured, you can switch models in chat: |
| |
|
| | ``` |
| | /model crazyrouter/gpt-4o |
| | /model crazyrouter/deepseek-chat |
| | /model crazyrouter/gemini-2.0-flash |
| | ``` |
| |
|
| | Or use aliases: |
| |
|
| | ``` |
| | /model Mini |
| | /model DeepSeek |
| | ``` |
| |
|
| | --- |
| |
|
| | ## Why Crazyrouter + OpenClaw? |
| |
|
| | | Feature | Benefit | |
| | |---------|---------| |
| | | **624+ models** | Switch between any model without changing config | |
| | | **One API key** | No need to manage separate keys for each provider | |
| | | **OpenAI-compatible** | Native support in OpenClaw โ zero custom code | |
| | | **Competitive pricing** | Run your agent 24/7 without breaking the bank | |
| | | **Fallback support** | If one model is down, auto-switch to another | |
| | | **All channels** | Same backend powers Telegram, Discord, WhatsApp, Slack... | |
| |
|
| | --- |
| |
|
| | ## Cost Optimization Tips |
| |
|
| | 1. **Use cheap models for sub-agents** โ Set `gpt-4o-mini` or `deepseek-chat` for background tasks |
| | 2. **Use powerful models for main chat** โ `claude-opus-4-6` or `gpt-4o` for direct conversations |
| | 3. **Enable compaction** โ Reduces token usage for long conversations: |
| |
|
| | ```json5 |
| | { |
| | agents: { |
| | defaults: { |
| | compaction: { mode: "safeguard" }, |
| | }, |
| | }, |
| | } |
| | ``` |
| |
|
| | 4. **Set concurrent limits** โ Control parallel sub-agent runs: |
| |
|
| | ```json5 |
| | { |
| | agents: { |
| | defaults: { |
| | maxConcurrent: 4, |
| | subagents: { maxConcurrent: 8 }, |
| | }, |
| | }, |
| | } |
| | ``` |
| |
|
| | --- |
| |
|
| | ## Environment Variables (Alternative) |
| |
|
| | Instead of putting the API key in the config file: |
| |
|
| | ```bash |
| | export CRAZYROUTER_API_KEY="sk-your-crazyrouter-key" |
| | ``` |
| |
|
| | Then reference it in config: |
| |
|
| | ```json5 |
| | { |
| | models: { |
| | providers: { |
| | crazyrouter: { |
| | baseUrl: "https://crazyrouter.com/v1", |
| | apiKey: "${CRAZYROUTER_API_KEY}", |
| | api: "openai-completions", |
| | // ... |
| | }, |
| | }, |
| | }, |
| | } |
| | ``` |
| |
|
| | --- |
| |
|
| | ## Troubleshooting |
| |
|
| | ### Check Gateway Status |
| |
|
| | ```bash |
| | openclaw gateway status |
| | openclaw doctor |
| | ``` |
| |
|
| | ### View Logs |
| |
|
| | ```bash |
| | openclaw logs |
| | openclaw logs --tail |
| | ``` |
| |
|
| | ### Test the API Connection |
| |
|
| | ```bash |
| | curl https://crazyrouter.com/v1/models \ |
| | -H "Authorization: Bearer sk-your-crazyrouter-key" \ |
| | | head -20 |
| | ``` |
| |
|
| | ### Common Issues |
| |
|
| | | Issue | Fix | |
| | |-------|-----| |
| | | "Model not found" | Check model ID matches exactly (e.g. `claude-opus-4-6`) | |
| | | Auth error | Verify API key at [crazyrouter.com](https://crazyrouter.com/?utm_source=huggingface&utm_medium=tutorial&utm_campaign=dev_community) | |
| | | Slow responses | Try a faster model like `gemini-2.0-flash` | |
| | | Gateway won't start | Run `openclaw doctor --fix` | |
| |
|
| | --- |
| |
|
| | ## Links |
| |
|
| | - ๐ [Crazyrouter](https://crazyrouter.com/?utm_source=huggingface&utm_medium=tutorial&utm_campaign=dev_community) โ Get your API key |
| | - ๐ [OpenClaw Docs](https://docs.openclaw.ai) โ Full documentation |
| | - ๐ [OpenClaw GitHub](https://github.com/openclaw/openclaw) โ Source code |
| | - ๐ค [Crazyrouter Demo](https://huggingface.co/spaces/xujfcn/Crazyrouter-Demo) โ Try models live |
| | - ๐ฐ [Pricing](https://huggingface.co/spaces/xujfcn/Crazyrouter-Pricing) โ Model pricing comparison |
| | - ๐ฌ [Telegram Community](https://t.me/crazyrouter) |
| | - ๐ฆ [Twitter @metaviiii](https://twitter.com/metaviiii) |
| | - ๐ฎ [OpenClaw Discord](https://discord.com/invite/clawd) |
| |
|