Use ModelStream with OpenClaw
Run your OpenClaw agent on ModelStream — every model, every modality, one endpoint. Drop-in OpenAI-compatible, with smart routing that cuts the average bill ~18% and built-in failover so your agent keeps running when a provider goes down.
You'll need a ModelStream account (modelstream.ai — no card required) and a machine running macOS, Linux, or Windows.
How it works
OpenClaw supports any OpenAI-compatible provider through its models.providers config. ModelStream exposes a single OpenAI-compatible endpoint in front of 300+ models, so you register it once as a custom provider and then switch models by changing one string — no new auth, no code changes.
Step 1 — Install OpenClaw
Skip this if OpenClaw is already installed.
macOS / Linux / WSL2
curl -fsSL https://openclaw.ai/install.sh | bash
Windows (PowerShell)
iwr -useb https://openclaw.ai/install.ps1 | iex
The installer detects your OS, installs Node if needed (Node 24 recommended, 22.19+ minimum), and launches onboarding. Prefer managing Node yourself? npm install -g openclaw@latest && openclaw onboard --install-daemon.
Verify:
openclaw --version openclaw gateway status
Step 2 — Get your ModelStream API key
- 1Sign up at modelstream.ai.
- 2Go to Dashboard → API Keys → Create Key, name it (e.g.
openclaw), and copy it. - 3Export it where the OpenClaw gateway runs:
export MODELSTREAM_API_KEY="ms-..."
Step 3 — Register ModelStream as a provider
Add this to your OpenClaw config (~/.openclaw/openclaw.json):
{
agents: {
defaults: {
model: { primary: "modelstream/gpt-4o-mini" },
},
},
models: {
mode: "merge",
providers: {
modelstream: {
baseUrl: "https://api.modelstream.ai/v1",
apiKey: "${MODELSTREAM_API_KEY}",
api: "openai-completions",
models: [
{
id: "gpt-4o-mini",
name: "GPT-4o mini (via ModelStream)",
input: ["text", "image"],
contextWindow: 128000,
maxTokens: 16384,
},
{
id: "claude-sonnet",
name: "Claude Sonnet (via ModelStream)",
input: ["text", "image"],
contextWindow: 200000,
maxTokens: 64000,
},
{
id: "modelstream-auto",
name: "ModelStream Smart Routing",
contextWindow: 128000,
maxTokens: 16384,
},
],
},
},
},
}Notes that save you a support ticket:
mode: "merge"keeps OpenClaw's built-in provider catalog alongside ModelStream.- Every model you want to call must appear in the provider's
models[]list. If you also setagents.defaults.models(it acts as an allowlist), add eachmodelstream/<id>there too — otherwise you'll hit the classic "model not allowed" error even with a valid key. - Model refs are
provider/model, e.g.modelstream/claude-sonnet. - Set
input: ["text", "image"]on vision-capable models so image attachments are passed natively. contextWindow/maxTokensare optional (defaults: 200000 / 8192) but set real values per model.
Step 4 — Set your default model and verify
openclaw models set modelstream/gpt-4o-mini openclaw models list # ModelStream models should appear openclaw doctor # config sanity check
Then send your agent a message and run /models in the chat — your ModelStream models should be listed and selectable.
Switch models in one line. Routing the same agent to a different model is just:
openclaw models set modelstream/claude-sonnet
Or let ModelStream pick the cheapest model that meets your quality bar:
openclaw models set modelstream/modelstream-auto
Step 5 (optional) — Failover
ModelStream already does multi-region provider failover behind one model slug. For model-level fallbacks inside OpenClaw (e.g. fall back to a cheaper model if your primary is rate-limited), configure a fallback chain — see Model failover in the OpenClaw docs.
Troubleshooting
models.providers.modelstream.models[] and to agents.defaults.models if that allowlist is set.MODELSTREAM_API_KEY is set in the gateway's environment, not just your shell. Restart the gateway after changing it./v1: https://api.modelstream.ai/v1.input: ["text", "image"] to that model's entry.models.providers.modelstream.timeoutSeconds (e.g. 300).openclaw doctor, then restart: openclaw gateway restart.Next steps
- Browse the full catalog in your ModelStream dashboard and add slugs to the config as you need them.
- Estimate your monthly bill with the ModelStream cost calculator.
- Coming from OpenAI or Anthropic elsewhere in your stack? The migration is the same one-line base-URL swap — see the ModelStream migration guides.