Skip to content

OpenClaw

OpenClaw is an open-source, self-hosted personal AI assistant platform that connects messaging apps (Telegram, Discord, WhatsApp, iMessage, …) to AI agents on your own hardware. Add WRouter as a custom provider in openclaw.json and every wrouter-routed model becomes available to your agents.

Prerequisites

ItemRequirement
Node.js≥ 22
OpenClawlatest
WRouterA working sk- token

Install & bootstrap

bash
curl -fsSL https://openclaw.ai/install.sh | bash
openclaw onboard --install-daemon

The wizard sets up auth, the Gateway, and optional channels. Other install paths (Docker, manual) are in OpenClaw's Getting Started.

Configure WRouter via models.providers

OpenClaw discovers model providers from openclaw.json. You declare WRouter as a custom provider, list the models you want exposed, and then point your agent's default model at it.

Many built-in provider plugins ship a default catalog. Only declare an explicit models.providers.<id> entry when you want to override the base URL, headers, or model list — which is exactly what we're doing here.

1. Provide the API key

In your shell, service env, or an .env file readable by OpenClaw:

bash
export WROUTER_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

2. Edit openclaw.json

Add (or merge into) the following:

js
{
  models: {
    mode: "merge",
    providers: {
      wrouter: {
        baseUrl: "https://wrouter.ai/v1",
        apiKey: "${WROUTER_API_KEY}",
        api: "openai-completions",
        models: [
          { id: "claude-sonnet-4-6", name: "Claude Sonnet 4.6" },
          { id: "gemini-2.5-flash", name: "Gemini 2.5 Flash" },
          // multimodal model — pass images as native input
          { id: "gpt-5.4", name: "GPT-4o", input: ["text", "image"] },
        ],
      },
    },
  },

  agents: {
    defaults: {
      model: {
        primary:   "wrouter/claude-sonnet-4-6",
        fallbacks: ["wrouter/gemini-2.5-flash"],
      },
      models: {
        "wrouter/claude-sonnet-4-6": { alias: "sonnet" },
        "wrouter/gemini-2.5-flash":  { alias: "flash" },
      },
    },
  },
}

Key fields

FieldNotes
models.modeUse "merge" so WRouter is added alongside OpenClaw's built-in providers, not replacing them
models.providers.wrouter.baseUrlWRouter base URL; must include /v1
models.providers.wrouter.apiKey${WROUTER_API_KEY} reads from env — avoids hard-coding the secret
models.providers.wrouter.api"openai-completions" for an OpenAI-compatible gateway like WRouter
models.providers.wrouter.models[]Each entry's id must match WRouter's actual model ID exactly
models.providers.wrouter.models[].inputSet to ["text", "image"] on models that accept image input — lets WebChat and node attachments pass images as native input rather than text references
agents.defaults.model.primaryPrimary model — format is provider/model-id (e.g. wrouter/claude-sonnet-4-6)
agents.defaults.model.fallbacksOrdered fallback list when the primary fails
agents.defaults.modelsOptional aliases / per-model metadata — visibility-only, does not register a runtime model. Custom-provider models must also appear in models.providers.<provider>.models[]

Verify

Send a message via any connected channel (Telegram, Discord, web UI). The agent should respond via WRouter using the primary model; failures auto-fall back per your config.

ModelUse
claude-sonnet-4-6Daily driver across channels
gpt-5.4Multimodal (image attachments) — set input: ["text", "image"]
gemini-2.5-flashLong conversation history
tts-1 + whisper-1Voice channels (TTS + STT)

Common pitfalls

SymptomLikely cause
404 from upstreambaseUrl is missing /v1
Model "not registered" at runtimeModel only declared under agents.defaults.models — must also be in models.providers.<provider>.models[]
Image attachments arrive as text referencesinput: ["text", "image"] not set on that model entry
Fallback never triggersfallbacks IDs don't match any models.providers.wrouter.models[].id

Known limitations

  • Channel integrations (Telegram bot, Discord webhook, WhatsApp Business) require separate setup with each platform.
  • OpenClaw runs on your hardware; uptime and security are your responsibility.
  • Voice quality depends on the OS (macOS / iOS / Android have differing STT/TTS support).