Flatrouter

OpenClaw Setup

Add Flatrouter as a custom OpenClaw provider and drive the local assistant with Claude, GPT or Gemini.

OpenClaw is an open-source local AI assistant. It talks to you over WhatsApp, Telegram, Slack and similar apps, and it can take real actions — mail, calendar, flight check-in, browsing, and more. It runs entirely on your device; data does not leave the machine.

  • Flexible agent policy — give each agent a different model: Sonnet for daily work, Opus for reasoning, Haiku for light tasks
  • 99.9% SLA — multi-node redundancy with automatic failover
  • Predictable cost — one billing dashboard, live token usage

As an agentic assistant, OpenClaw burns a lot of tokens per task (often 10K–100K+). Pick models by task complexity so you do not overspend. This guide covers three setup paths.

Install

curl -sSL https://openclaw.ai/install.sh | bash

Windows (PowerShell):

& ([scriptblock]::Create((iwr -useb https://openclaw.ai/install.ps1)))

Quick start

1. Get an API key

Create a key in the Flatrouter console.

2. Run the setup wizard

OpenClaw ships an interactive wizard:

openclaw onboard

Choose Custom Provider and fill in:

FieldValue
Provider Typeanthropic-messages
Base URLhttps://api.flatrouter.com/anthropic
API KeyYour API key
Modelanthropic/claude-sonnet-4.6

3. Send a test message

Send OpenClaw a message. A normal reply means the connection works.

The wizard writes openclaw.json for you. For finer control, use the full config below.

Full configuration

OpenClaw stores everything in ~/.openclaw/openclaw.json (JSON5, comments allowed).

Provider config

Providers live under models.providers. Each one needs a protocol, URL and key:

{
  "models": {
    "providers": {
      "flatrouter-anthropic": {
        "baseUrl": "https://api.flatrouter.com/anthropic",
        "apiKey": "${FLATROUTER_API_KEY}",
        "api": "anthropic-messages",
        "models": []
      },
      "flatrouter-openai": {
        "baseUrl": "https://api.flatrouter.com/v1",
        "apiKey": "${FLATROUTER_API_KEY}",
        "api": "openai-responses",
        "models": []
      },
      "flatrouter-gemini": {
        "baseUrl": "https://api.flatrouter.com/gemini",
        "apiKey": "${FLATROUTER_API_KEY}",
        "api": "google-generative-ai",
        "models": []
      }
    }
  }
}

apiKey accepts `${ENV_VAR}` so you do not paste secrets into the file. Map protocols to model families: Claude on flatrouter-anthropic (anthropic-messages), OpenAI on flatrouter-openai (openai-responses), Gemini on flatrouter-gemini (google-generative-ai). Everything else can go through flatrouter-openai.

Models (full Claude lineup)

Models sit in each provider's models array. Full Claude lineup — strongest capability, for demanding work:

{
  "models": {
    "providers": {
      "flatrouter-anthropic": {
        "baseUrl": "https://api.flatrouter.com/anthropic",
        "apiKey": "${FLATROUTER_API_KEY}",
        "api": "anthropic-messages",
        "models": [
          {
            "id": "anthropic/claude-sonnet-4.6",
            "name": "Claude Sonnet 4.6",
            "input": ["text", "image", "file"],
            "contextWindow": 200000,
            "maxTokens": 64000
          },
          {
            "id": "anthropic/claude-opus-4.8",
            "name": "Claude Opus 4.8",
            "reasoning": true,
            "input": ["text", "image", "file"],
            "contextWindow": 200000,
            "maxTokens": 128000
          },
          {
            "id": "anthropic/claude-haiku-4.5",
            "name": "Claude Haiku 4.5",
            "input": ["text", "image", "file"],
            "contextWindow": 200000,
            "maxTokens": 64000
          }
        ]
      }
    }
  }
}
ModelRoleBest for
anthropic/claude-sonnet-4.6Daily driverChat, task execution, code generation
anthropic/claude-opus-4.8Deep reasoningHard analysis, long chains, research
anthropic/claude-haiku-4.5Fast repliesSimple queries, quick answers, light work

Agents

Set global defaults with agents.defaults, then define agents in agents.list. Each agent can override the defaults:

{
  "agents": {
    "defaults": {
      "model": {
        "primary": "flatrouter-anthropic/anthropic/claude-sonnet-4.6",
        "fallbacks": ["flatrouter-anthropic/anthropic/claude-haiku-4.5"]
      },
      "models": {
        "flatrouter-anthropic/anthropic/claude-opus-4.8": { "alias": "opus" },
        "flatrouter-anthropic/anthropic/claude-sonnet-4.6": { "alias": "sonnet" },
        "flatrouter-anthropic/anthropic/claude-haiku-4.5": { "alias": "haiku" }
      },
      "thinkingDefault": "low",
      "timeoutSeconds": 600,
      "maxConcurrent": 3
    },
    "list": [
      {
        "id": "main",
        "default": true
      },
      {
        "id": "research",
        "model": {
          "primary": "flatrouter-anthropic/anthropic/claude-opus-4.8"
        }
      },
      {
        "id": "quick",
        "model": {
          "primary": "flatrouter-anthropic/anthropic/claude-haiku-4.5"
        }
      }
    ]
  }
}
AgentModelUse
mainclaude-sonnet-4.6 (inherits defaults)Default agent, everyday work
researchclaude-opus-4.8Deep research, hard reasoning, long analysis
quickclaude-haiku-4.5Simple Q&A, fast replies, low cost

Model refs are provider-name/model-id (for example flatrouter-anthropic/anthropic/claude-sonnet-4.6). defaults.models defines aliases so you can type /model opus in chat. Agents in list inherit every default and only override what they need.

Full config example

A complete openclaw.json with providers, models and agents (the strongest layout):

{
  "models": {
    "providers": {
      "flatrouter-anthropic": {
        "baseUrl": "https://api.flatrouter.com/anthropic",
        "apiKey": "${FLATROUTER_API_KEY}",
        "api": "anthropic-messages",
        "models": [
          {
            "id": "anthropic/claude-sonnet-4.6",
            "name": "Claude Sonnet 4.6",
            "input": ["text", "image", "file"],
            "contextWindow": 200000,
            "maxTokens": 64000
          },
          {
            "id": "anthropic/claude-opus-4.8",
            "name": "Claude Opus 4.8",
            "reasoning": true,
            "input": ["text", "image", "file"],
            "contextWindow": 200000,
            "maxTokens": 128000
          },
          {
            "id": "anthropic/claude-haiku-4.5",
            "name": "Claude Haiku 4.5",
            "input": ["text", "image", "file"],
            "contextWindow": 200000,
            "maxTokens": 64000
          }
        ]
      },
      "flatrouter-gemini": {
        "baseUrl": "https://api.flatrouter.com/gemini",
        "apiKey": "${FLATROUTER_API_KEY}",
        "api": "google-generative-ai",
        "models": [
          {
            "id": "models/google/gemini-3.5-flash",
            "name": "Gemini 3.5 Flash",
            "reasoning": true,
            "input": ["text", "image"],
            "contextWindow": 1000000,
            "maxTokens": 64000
          },
          {
            "id": "models/google/gemini-3.1-pro-preview",
            "name": "Gemini 3.1 Pro",
            "reasoning": true,
            "input": ["text", "image"],
            "contextWindow": 1000000,
            "maxTokens": 64000
          }
        ]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "flatrouter-anthropic/anthropic/claude-sonnet-4.6",
        "fallbacks": ["flatrouter-anthropic/anthropic/claude-haiku-4.5"]
      },
      "models": {
        "flatrouter-anthropic/anthropic/claude-opus-4.8": { "alias": "opus" },
        "flatrouter-anthropic/anthropic/claude-sonnet-4.6": { "alias": "sonnet" },
        "flatrouter-anthropic/anthropic/claude-haiku-4.5": { "alias": "haiku" }
      },
      "thinkingDefault": "low",
      "timeoutSeconds": 600,
      "maxConcurrent": 3
    },
    "list": [
      {
        "id": "main",
        "default": true
      },
      {
        "id": "research",
        "model": {
          "primary": "flatrouter-anthropic/anthropic/claude-opus-4.8"
        }
      },
      {
        "id": "quick",
        "model": {
          "primary": "flatrouter-anthropic/anthropic/claude-haiku-4.5"
        }
      }
    ]
  }
}

What you can ask

Once it is set up, send commands from your messaging app:

  • Mail — "Sort today's unread mail by priority"
  • Calendar — "Book a team meeting tomorrow at 3pm"
  • Research — "Find recent articles on AI agents and summarize the points"
  • Code — "Review this Python snippet for security issues"
  • Automation — "Every weekday at 9am, post the team standup to Slack #general"

Troubleshooting

Cannot reach Flatrouter

Check baseUrl:

  • Anthropic: https://api.flatrouter.com/anthropic
  • OpenAI Responses: https://api.flatrouter.com/v1
  • Gemini: https://api.flatrouter.com/gemini

Model not found

Check the ID format. When you define a model under models.providers, id is the full Flatrouter ID (for example anthropic/claude-sonnet-4.6). When you reference it under agents, prefix the provider name: flatrouter-anthropic/anthropic/claude-sonnet-4.6.

Token usage is too high

OpenClaw tasks are expensive. Try:

  1. Use claude-haiku-4.5 or a cheaper model for daily work
  2. Switch to the research agent (claude-opus-4.8) only for hard tasks
  3. Watch usage in the Flatrouter console

Switch models quickly

Use aliases in chat: /model opus, /model sonnet, /model haiku (define them under agents.defaults.models).

On this page