OpenRouter with OpenClaw

One API for 30+ models — Claude, GPT, Gemini, Llama, Mistral

OpenRouter is an aggregation layer: one API key gives you access to dozens of models (Claude, GPT, Gemini, Llama, Mistral, and more) from multiple providers. OpenClaw integrates with OpenRouter so you can switch models or try new ones without managing separate API keys for each provider. Good for experimentation, cost comparison, and failover across vendors.

Why OpenRouter

  • One API key — No need for separate Anthropic, OpenAI, Google keys
  • 30+ models — Claude, GPT, Gemini, Llama, Mistral, and more
  • Failover — Automatic fallback if one model is down
  • Cost comparison — Compare pricing across providers
  • Experiment easily — Try new models without new credentials

Authentication

Create an API key at openrouter.ai. Store in ~/.openclaw/credentials or via openclaw secrets. The same key works for all models on OpenRouter.

Beta: OpenRouter OAuth onboarding is available on stable v2026.6.6+; API keys still work on all builds.

Basic Configuration

Use the OpenRouter provider and specify the model ID. Model IDs follow the format provider/model-name (e.g. openai/gpt-4, anthropic/claude-opus-4). Check openrouter.ai/models for the full list.

OpenRouter config
{
  "agent": {
    "model": "anthropic/claude-opus-4",
    "provider": "openrouter"
  }
}

When to Use OpenRouter

  • Multi-provider setup — Want Claude, GPT, and others without separate keys
  • Experimentation — Try new models quickly
  • Failover — Built-in redundancy across vendors
  • Cost optimization — Compare and switch based on pricing

If you prefer automatic per-request routing (cheapest model that can handle each query), see ClawRouter in the Providers overview—we don't endorse third-party tools.

Multi-provider routing playbook

OpenClaw can use OpenRouter as an aggregator or talk directly to Anthropic, OpenAI, Ollama, and others. This section is about how to choose, not duplicate provider setup steps.

When OpenRouter is the better fit

OpenRouter helps when you want one credential surface and to swap model IDs often (A/B quality, trying new releases, or pointing cron at a cheaper model while chat stays on a flagship). You still pay upstream pricing through their layer; the win is operational: fewer keys and one place to audit model strings. It fits households or small teams that accept traffic via an aggregator and want iteration speed.

When to prefer a direct provider

Use direct Anthropic or OpenAI (OAuth or API key per upstream docs) when you want the shortest line between contract, billing, and data handling, or when infosec already standardizes on one vendor. Finance often prefers one vendor invoice. Debugging rate limits is simpler without a second hop between you and the API.

Local models alongside cloud

For jobs where API cost or offline use matters, pair Ollama with cloud models for the steps that need frontier quality. A common split: local for heartbeats, summarization, or classification; cloud for long reasoning or tool-heavy sessions.

Cost and latency checklist

  1. Measure — Note input and output tokens for a typical busy day (one active group chat is enough).
  2. Split workloads — Separate interactive chat from cron or automation so you can assign cheaper models where your config allows.
  3. Watch cold start — First message after idle may load a large context; oversized system prompts cost on every channel.
  4. Pin after experiments — Record the exact model string and provider in configuration notes or your runbook so upgrades do not drift silently.

Failover expectations

Automatic failover between unrelated vendors is rarer than marketing suggests. Treat routing as your process: keep a tested secondary model string, document the switch (Upgrading / Migrating), and run openclaw doctor after changes. OpenRouter makes swapping IDs fast; you still own correctness and cost.

Exact JSON keys and flags drift—use docs.openclaw.ai and llms.txt as source of truth. Also see Example setups & model routing and Tips and best practices.