OpenClaw
Self-hosted AI gateway that bridges chat apps (Telegram, Discord, WhatsApp) to coding agents — register Melious as a custom OpenAI-compatible provider
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 | bashWindows PowerShell:
iwr -useb https://openclaw.ai/install.ps1 | iexOr 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@latestThe 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 doctorAdd 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.
{
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/.envApply the config change (the gateway daemon is already running after openclaw onboard --install-daemon):
openclaw gateway restart
openclaw gateway statusVerify 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/modelsslash command sit underagents.defaults.modelskeyed by the canonical<provider>/<model-id>reference. - Tool calling on supported models only. OpenClaw forwards OpenAI-shape
tool_callsto our Chat Completions endpoint. Not every open-weight model handles tools — check_meta.capabilities.tool_useonGET /v1/models?include_meta=trueor filter at melious.ai/hub/models. - Custom response fields.
environment_impactandbilling_costride 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: falsefor 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. Runopenclaw doctorand check the file withcat ~/.openclaw/openclaw.json. Apply changes withopenclaw gateway restart.401 Unauthorizedfrom Melious —${MELIOUS_API_KEY}didn't resolve. Confirm~/.openclaw/.envhas the key and the daemon was restarted after the file change (openclaw gateway restart)./modelsslash command shows no Melious aliases — your aliases underagents.defaults.modelsdon'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 matchmodels.providers.<id>exactly.agents.defaults.modelrejected 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 statusshows the resolved active model.
Errors and retry patterns: Errors.