OpenClaw: an agent on your own machine

If you want to hand off a job and walk away, this gets it running and keeps its bill in your hands.

10 minLesson 6 of 80 of 3 steps

OpenClaw is another open-source agent by other developers. It runs on your own system, has its own web panel and can carry a job through. It works on IranRouter with an ir- key, and its cost comes off the same wallet.

Installing

You need Node.js 24.16 or newer; check with node --version. Then, on Linux or macOS:

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

The installer opens a setup wizard. Anything it asks can be changed later; we'll set the model through a file in the next step.

Connecting to IranRouter

The usual two variables aren't enough for OpenClaw. Its default model is gpt-6-astra, sent without a prefix, so it gets a 404. Add IranRouter as a provider in ~/.openclaw/openclaw.json, set primary to iranrouter/ followed by the full model id, and list each model by its full id:

JSON
{
  "agents": { "defaults": { "model": { "primary": "iranrouter/anthropic/claude-sonnet-5" } } },
  "models": {
    "providers": {
      "iranrouter": {
        "baseUrl": "https://iranrouter.com/v1",
        "apiKey": "ir-...",
        "api": "openai-completions",
        "models": [{ "id": "anthropic/claude-sonnet-5", "name": "Claude Sonnet 5", "contextWindow": 1000000, "maxTokens": 8000 }]
      }
    }
  }
}

Watch your key. OpenClaw's memory goes to api.openai.com for embeddings by default. Unless you make one of the two settings below, your ir- key is sent to that service. Option one is to take embeddings from IranRouter too. Add this to the same file, with the id of an active embedding model from the models page:

JSON
{
  "memory": {
    "search": {
      "provider": "openai-compatible",
      "model": "openai/text-embedding-3-small",
      "remote": { "baseUrl": "https://iranrouter.com/v1", "apiKey": "ir-..." }
    }
  }
}

Option two: if there is no active embedding model, or you don't want memory search, switch it off:

JSON
{ "memory": { "search": { "enabled": false } } }

Take contextWindow and maxTokens from that model's page. After saving, restart the gateway and open the dashboard:

Shell
openclaw gateway restart
openclaw dashboard

Write a message in the dashboard's chat. When the answer arrives, find that request with its model name in Usage & logs.

Before you leave an agent on its own

An autonomous agent can send hundreds of requests in minutes. Two things before any long run:

  1. Give each agent its own key, so you can close one without stopping the rest.
  2. Put a daily cap on that key. A cap means that even if the code goes wrong, spending stops at your number.

A good agent can ask how much room it has before starting something heavy.

That's what GET /v1/key is for: it returns the limits, current use and what's left.

Shell
curl https://iranrouter.com/v1/key -H "Authorization: Bearer ir-..."

Give it a small job0 of 3 steps

  1. Run OpenClaw with its own key and a daily cap.
  2. Give it a small job, such as summarising a folder of text files.
  3. In the Sessions tab, see how many requests that job made and what it cost.

What you learned

  • OpenClaw connects through openclaw.json and full model ids.
  • Point memory embeddings at IranRouter or switch them off, or your key goes to another service.
  • Each agent needs its own key and daily cap.
  • GET /v1/key says how much room is left.
Presets and filesWhy change the model and settings in code each time, when you can change them once from the panel?Done, next lesson