What is OpenClaw?
OpenClaw (formerly Moltbot, formerly Clawdbot) is an open-source AI agent platform that brings conversational AI to multiple messaging channels including Telegram, Discord, Slack, Signal, iMessage, and WhatsApp. It supports multiple LLM providers and allows you to run AI agents that can interact across all these platforms.Setup
Recommended: Use the OpenClaw Setup Wizard
The easiest way to configure OpenClaw with OpenRouter is using the built-in setup wizard:- Choosing OpenRouter as your provider
- Entering your API key
- Selecting your preferred model
- Configuring messaging channels
Quick Start (CLI)
If you already have your OpenRouter API key and want to skip the wizard, use this one-line command:openrouter/auto).
Manual Configuration
If you need to manually edit your OpenClaw configuration file, follow these steps:Step 1: Get Your OpenRouter API Key
- Sign up or log in at OpenRouter
- Navigate to your API Keys page
- Create a new API key
- Copy your key (starts with
sk-or-...)
Step 2: Set Your API Key
Add your OpenRouter API key to your~/.openclaw/openclaw.json:
That’s it! OpenClaw has built-in support for OpenRouter. You don’t need to configure
models.providers - just set your API key and reference models with the openrouter/<author>/<slug> format.Step 3: Choose Your Model
Update theprimary model and add it to the models list. Here are some popular options:
Anthropic Claude:
Step 4: Start OpenClaw
After updating your configuration, start or restart OpenClaw:Model Format
OpenClaw uses the formatopenrouter/<author>/<slug> for OpenRouter models (prefix the author with ~ to track the latest version in a family). For example:
openrouter/~anthropic/claude-sonnet-latestopenrouter/~google/gemini-pro-latestopenrouter/~moonshotai/kimi-latestopenrouter/openrouter/auto(Auto router that picks the most cost effective model for your prompt)
Multiple Models with Fallbacks
OpenClaw supports model fallbacks. If the primary model is unavailable, it will try the fallback models in order:Using Auto Model for Cost Optimization
OpenClaw agents perform many different types of actions, from simple heartbeat processing to complex reasoning tasks. Using a powerful model for every action wastes money on tasks that don’t require advanced capabilities. The OpenRouter Auto Model (openrouter/openrouter/auto) automatically selects the most cost-effective model based on your prompt. This is ideal for OpenClaw because it routes simple tasks like heartbeats and status checks to cheaper models while using more capable models only when needed for complex interactions.
To configure Auto Model as your primary model:
Using Auth Profiles
For more secure credential management, you can use OpenClaw’s auth profiles instead of environment variables. This is automatically configured when you use theopenclaw onboard command.
To manually create an auth profile, add this to your openclaw.json:
Monitoring Usage
Track your OpenClaw usage in real-time:- Visit the OpenRouter Activity Dashboard
- See requests, costs, and token usage across all your OpenClaw agents
- Filter by model, time range, or other criteria
- Export usage data for billing or analysis
Common Errors
”No API key found for provider ‘openrouter’”
OpenClaw can’t find your OpenRouter API key. Fix:- Ensure the
OPENROUTER_API_KEYenvironment variable is set:echo $OPENROUTER_API_KEY - Or verify your auth profile exists:
openclaw auth list - Run the onboard command:
openclaw onboard --auth-choice apiKey --token-provider openrouter --token "$OPENROUTER_API_KEY"
Authentication errors (401/403)
If you see authentication errors: Fix:- Verify your API key is valid at openrouter.ai/keys
- Check that you have sufficient credits in your account
- Ensure your key hasn’t expired or been revoked
Model not working
If a specific model isn’t working: Fix:- Verify the model ID is correct on the OpenRouter models page
- Use the format
openrouter/<author>/<slug>, optionally prefixing the author with~for the latest version in a family (e.g.,openrouter/~anthropic/claude-sonnet-latest) - Add the model to
agents.defaults.modelsin your config