Melious
Integrations

OpenClaw

Self-hosted AI gateway that bridges chat apps (Telegram, Discord, WhatsApp) to coding agents — register Melious as a custom OpenAI-compatible provider

OpenClaw
by Peter Steinbergeropenclaw.ai

OpenClaw is a self-hosted AI agent gateway. It connects chat apps — Telegram, Discord, WhatsApp, Slack — to coding agents like Pi and routes their model traffic through whatever providers you configure. The gateway itself isn't a coding agent; it's the wiring between user-facing chat surfaces and the agent runtimes that actually do the work. Adding Melious is a single block in ~/.openclaw/openclaw.json and one env var.

Setup

Install OpenClaw

OpenClaw needs Node 22+ (24 recommended). The installer handles Node setup if missing.

macOS, Linux, WSL2:

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

Windows PowerShell:

iwr -useb https://openclaw.ai/install.ps1 | iex

Or via npm / pnpm / bun:

npm install -g openclaw@latest && openclaw onboard --install-daemon
pnpm add -g openclaw@latest          # then: pnpm approve-builds -g
bun add -g openclaw@latest

The shell installer runs openclaw onboard --install-daemon for you. With npm/pnpm/bun, run it once after install — it sets up the user-level daemon that keeps the gateway alive across reboots.

Verify:

openclaw --version
openclaw doctor

Add Melious as a model provider

OpenClaw config lives at ~/.openclaw/openclaw.json (JSON5, comments and trailing commas allowed). The provider block itself can stay minimal — models[] under the provider is optional. Aliases for switching live under agents.defaults.models.

~/.openclaw/openclaw.json
{
  models: {
    providers: {
      melious: {                                         
        api: "openai-completions",                       
        baseUrl: "https://api.melious.ai/v1",            
        apiKey: "${MELIOUS_API_KEY}",                    
        timeoutSeconds: 300,                             
      }                                                  // [!code ++]
    }
  },
  agents: {
    defaults: {
      model: "melious/<MODEL_ID>",                       
      models: {                                          
        "melious/<MODEL_ID>":         { alias: "main" }, 
        "melious/<LIGHTWEIGHT_ID>":   { alias: "fast" }, 
        "melious/<MODEL_ID>:eco":     { alias: "eco" },  
      }                                                  // [!code ++]
    }
  }
}

api: "openai-completions" tells OpenClaw to send Chat Completions-shaped requests, which Melious serves natively. apiKey resolves ${VAR} from ~/.openclaw/.env or the launching environment. Model refs follow the pattern <provider>/<model-id>.

agents.defaults.model accepts either a direct string (shown above) or the object form { primary: "melious/<MODEL_ID>" }. The models map registers aliases for /models <alias> switching mid-conversation.

If you want to pin per-model metadata (cost, context window, capabilities), add an explicit models[] array on the provider — full schema in Custom OpenAI-compatible providers. Defaults apply when omitted: reasoning: false, input: ["text"], cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, contextWindow: 200000, maxTokens: 8192. Browse melious.ai/hub/models for current IDs.

Store your key and reload the gateway

Drop the key in ~/.openclaw/.env:

echo 'MELIOUS_API_KEY=sk-mel-<YOUR_API_KEY>' >> ~/.openclaw/.env

Apply the config change (the gateway daemon is already running after openclaw onboard --install-daemon):

openclaw gateway restart
openclaw gateway status

Verify the provider registered and switch the default model:

openclaw models list
openclaw models set melious/<MODEL_ID>

models list shows every provider/model combination with auth status. Inside an active session, the /models <alias> slash command switches mid-conversation using the aliases you defined above.

Steering routing

Append a flavor suffix to the model id wherever you reference it. The flavor suffix lives on the right side of the slash:

agents: {
  defaults: {
    model: "melious/<MODEL_ID>:eco",
    models: {
      "melious/<MODEL_ID>:eco":   { alias: "eco" },
      "melious/<MODEL_ID>:speed": { alias: "fast" },
      "melious/<MODEL_ID>:price": { alias: "cheap" },
    }
  }
}
  • :speed — latency-biased provider selection
  • :price — cheapest available provider
  • :eco — greenest energy mix
  • (no suffix) — balanced, our default

Switch flavors per turn with /models eco, /models fast, /models cheap. See Routing for the full decision table.

What's different

  • Aliases live in agents.defaults.models, not on the provider. The provider block stays minimal (api, baseUrl, apiKey). Aliases for the /models slash command sit under agents.defaults.models keyed by the canonical <provider>/<model-id> reference.
  • Tool calling on supported models only. OpenClaw forwards OpenAI-shape tool_calls to our Chat Completions endpoint. Not every open-weight model handles tools — check _meta.capabilities.tool_use on GET /v1/models?include_meta=true or filter at melious.ai/hub/models.
  • Custom response fields. environment_impact and billing_cost ride on raw responses. OpenClaw doesn't surface them in chat replies, but they're logged on our side and aggregated in your usage dashboard.
  • Compatibility flags forced. OpenClaw sets compat.supportsDeveloperRole: false for non-native OpenAI proxies and skips OpenAI-specific request shaping (service tiers, attribution headers). No action needed on your side — we handle the standard Chat Completions shape.

When it breaks

  • Provider 'melious' not found — the JSON5 config didn't reload, or the block is malformed. Run openclaw doctor and check the file with cat ~/.openclaw/openclaw.json. Apply changes with openclaw gateway restart.
  • 401 Unauthorized from Melious${MELIOUS_API_KEY} didn't resolve. Confirm ~/.openclaw/.env has the key and the daemon was restarted after the file change (openclaw gateway restart).
  • /models slash command shows no Melious aliases — your aliases under agents.defaults.models don't match a registered model id, or the provider id has a typo. The keys must follow <provider>/<model-id> and the provider id must match models.providers.<id> exactly.
  • agents.defaults.model rejected as invalid — both string form ("melious/<MODEL_ID>") and object form ({ primary: "melious/<MODEL_ID>" }) are accepted, but typos in either silently fall back to OpenClaw's built-in default. openclaw models status shows the resolved active model.

Errors and retry patterns: Errors.

On this page