How to Cut OpenClaw API Costs with Ollama and Local Models

Pinned

The Cost Problem

If you're self-hosting OpenClaw with cloud APIs like OpenAI or Gemini, you've probably noticed the bills adding up fast. We've seen users reporting $20+ per week on basic search and browsing tasks — and that's with moderate usage.

The reason is token volume. OpenClaw's tool-use architecture means a single web search can consume millions of tokens. The agent reasons about which tools to call, processes search results, summarizes content, and formats a response. Each step burns tokens. Multiply that by dozens of queries per day and you're looking at serious monthly spend.

The good news: you have options. OpenClaw supports custom model providers, which means you can run local models for free, use cheaper cloud alternatives, or set up a hybrid approach that gives you the best of both worlds.

Option 1: Run Local Models with Ollama

Ollama is an open-source tool that lets you run large language models locally on your own hardware. It exposes an OpenAI-compatible API, which means OpenClaw can use it as a drop-in replacement for cloud models.

Installing Ollama

Install Ollama on the same machine as OpenClaw (or a separate machine — more on that later):

curl -fsSL https://ollama.com/install.sh | sh

Then pull a model:

ollama pull llama3.1:8b

Configuring OpenClaw to Use Ollama

In your openclaw.json config, add Ollama as a custom provider under models.providers:

{
  "models": {
    "providers": [
      {
        "name": "ollama",
        "baseUrl": "http://localhost:11434/v1",
        "api": "openai",
        "models": [
          { "id": "llama3.1:8b", "name": "Llama 3.1 8B" },
          { "id": "qwen2.5:14b", "name": "Qwen 2.5 14B" },
          { "id": "deepseek-r1:32b", "name": "DeepSeek R1 32B" }
        ]
      }
    ]
  }
}

The key settings:

  • baseUrl — points to Ollama's OpenAI-compatible endpoint (port 11434 by default)
  • api — set to "openai" since Ollama speaks the OpenAI API format
  • models — list the models you've pulled with ollama pull

Setting a Local Model as Default

To make OpenClaw use your local model by default instead of a cloud API, configure agents.defaults:

{
  "agents": {
    "defaults": {
      "model": "ollama/llama3.1:8b"
    }
  }
}

Now every new conversation starts with your local model — zero API cost.

Hardware Requirements for Local Models

Local models run on your CPU or GPU. The limiting factor is almost always memory — the model needs to fit entirely in RAM (or VRAM for GPU inference).

RAM / VRAMModel SizeQualityExamples
8 GB7B parametersBasic — handles simple tasks, struggles with complex reasoningLlama 3.1 8B, Mistral 7B
16 GB7–13B parametersGood — solid for routine tasks like search summaries and formattingLlama 3.1 8B (fast), Qwen 2.5 14B
32 GB+32B+ parametersStrong — approaches cloud model quality for most tasksDeepSeek R1 32B, Qwen 2.5 32B
48 GB+ VRAM (GPU)70B+ parametersExcellent — comparable to mid-tier cloud modelsLlama 3.1 70B, Mixtral 8x22B

GPU Recommendations

Running models on a GPU is 5–10x faster than CPU inference. If you're serious about local models:

  • RTX 3090 (24 GB VRAM) — runs 13B models at full speed, 32B models with quantization
  • RTX 4090 (24 GB VRAM) — same capacity, faster inference
  • Dual GPUs or 48 GB+ VRAM — needed for 70B+ models without heavy quantization

CPU-only inference works for 7–8B models but expect slower response times — around 5–15 tokens per second depending on your hardware.

Running Ollama on a Separate Machine

Your VPS probably doesn't have a GPU. But your desktop at home might. You can run Ollama on a home machine with a GPU and connect your VPS to it securely using Tailscale.

Setup

  1. Install Tailscale on both your VPS and your home machine
  2. Install Ollama on your home machine (the one with the GPU)
  3. Start Ollama with network access enabled:

​

OLLAMA_HOST=0.0.0.0 ollama serve

4. Update OpenClaw config on your VPS to point to the Tailscale IP:

{
  "models": {
    "providers": [
      {
        "name": "ollama",
        "baseUrl": "http://100.x.x.x:11434/v1",
        "api": "openai",
        "models": [
          { "id": "deepseek-r1:32b", "name": "DeepSeek R1 32B" }
        ]
      }
    ]
  }
}

Replace 100.x.x.x with your home machine's Tailscale IP. The connection is encrypted and doesn't require opening any ports on your home network.

Option 2: Use Cheaper Cloud Models via OpenRouter

Not everyone has GPU hardware at home. OpenRouter aggregates dozens of AI models and lets you pay per token — often at a fraction of the cost of direct API access.

Models like Gemini Flash, Llama 3.1, and Mistral are available at significantly lower rates than GPT or Claude, and work well for routine OpenClaw tasks.

OpenRouter Config

{
  "models": {
    "providers": [
      {
        "name": "openrouter",
        "baseUrl": "https://openrouter.ai/api/v1",
        "api": "openai",
        "apiKey": "sk-or-your-key-here",
        "models": [
          { "id": "google/gemini-2.0-flash-001", "name": "Gemini 2.0 Flash" },
          { "id": "meta-llama/llama-3.1-70b-instruct", "name": "Llama 3.1 70B" },
          { "id": "mistralai/mistral-large-latest", "name": "Mistral Large" }
        ]
      }
    ]
  }
}

OpenRouter pricing varies by model, but expect to pay 50–90% less than equivalent OpenAI or Anthropic models for routine tasks.

Option 3: The Hybrid Approach

The smartest strategy combines local and cloud models. Use cheap or free models for everyday tasks, and reserve expensive cloud models for when you actually need them.

How It Works

OpenClaw lets you assign different models to different agents. The idea:

  • Routine tasks (web search, summarization, formatting) → Ollama local model or cheap OpenRouter model
  • Complex reasoning (code generation, multi-step analysis, creative writing) → GPT, Claude, or Gemini Pro

Configure per-agent model selection in your openclaw.json:

{
  "agents": {
    "defaults": {
      "model": "ollama/llama3.1:8b"
    },
    "overrides": {
      "coder": { "model": "anthropic/claude-sonnet-4-5-20250929" },
      "researcher": { "model": "openrouter/google/gemini-2.0-flash-001" }
    }
  }
}

This way, your default agent uses a free local model, but specialized agents like the coder can use a more capable cloud model when the task demands it.

Cost Comparison

Here's what typical monthly costs look like for moderate usage (~50 queries/day) across different setups:

SetupAI Model CostInfrastructureTotal Monthly
Pure cloud (GPT / Gemini Pro)€60–120€5–10 VPS€65–130
OpenRouter (Gemini Flash / Llama)€10–30€5–10 VPS€15–40
Pure local (Ollama 8B–32B)€0€5–10 VPS + electricity€5–15
Hybrid (local default + cloud for complex)€10–25€5–10 VPS€15–35

The difference is dramatic. A hybrid setup can cut your monthly AI spend by 70–85% compared to using cloud APIs exclusively.

The Trade-offs

Local models aren't free of cost — they trade money for other things:

  • Slower responses on CPU-only hardware
  • Lower quality on complex reasoning tasks (especially 7–8B models)
  • More setup work and occasional troubleshooting
  • Power consumption if running a GPU 24/7

For many users, the hybrid approach hits the sweet spot: fast and cheap for routine work, high quality when it matters.

Getting Started

  1. Start simple — install Ollama, pull llama3.1:8b, and try it as your default model
  2. Evaluate quality — run your typical tasks and see if the output is good enough
  3. Scale up if needed — try larger models (14B, 32B) or add OpenRouter as a fallback
  4. Go hybrid — configure per-agent models once you know which tasks need cloud quality

The OpenClaw community on Discord is a great place to share configs and get recommendations for which models work best for specific tasks.

Want the convenience of managed hosting without the server management? ClawNest handles infrastructure, updates, and backups so you can focus on configuring your AI assistants.

Posted Feb 15, 2026, 8:39 PM UTC

10
Loading comments…