OpenClawSkills
GitHub
Providers • TutorialHeader.readTime

Ollama

Use Ollama (a local LLM runtime) in OpenClaw.

Ollama is a local LLM runtime that allows you to run open-source models more conveniently on your own machine. OpenClaw integrates with Ollama's OpenAI-compatible API; when you enable it via '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'OLLAMA_API_KEY'</code>' (or an auth profile) and do '<strong>'not'</strong>' explicitly configure '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'models.providers.ollama'</code>', OpenClaw can '<strong>'automatically discover models that support tools'</strong>'.

Tutorial.step

Quick Start

1. Install Ollama: https://ollama.ai

2. Pull a model:

Bash
ollama pull llama3.3

ollama pull qwen2.5-coder:32b

ollama pull deepseek-r1:32b

3. Enable Ollama for OpenClaw (any value works; Ollama doesn't need a real key):

Bash
export OLLAMA_API_KEY="ollama-local"


openclaw config set models.providers.ollama.apiKey "ollama-local"

4. Use Ollama models:

Json5
{
  agents: {
    defaults: {
      model: { primary: "ollama/llama3.3" },
    },
  },
}
Tutorial.step

Model Discovery (Implicit Provider)

When you set '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'OLLAMA_API_KEY'</code>' (or an auth profile) and '<strong>'do not'</strong>' define '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'models.providers.ollama'</code>', OpenClaw automatically discovers models from your local Ollama instance at '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'http://127.0.0.1:11434'</code>':

- - Query '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'/api/tags'</code>' and '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'/api/show'</code>'

- - Only keep models that report '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'tools'</code>' capability

- - Mark models as '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'reasoning'</code>' when they report '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'thinking'</code>'

- - Read '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'contextWindow'</code>' from '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'model_info[&quot;&lt;arch&gt;.context_length&quot;]'</code>' when possible

- - Set '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'maxTokens'</code>' to 10x the context window

- - Set all costs to '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'0'</code>'

This avoids manual model entry maintenance while keeping the catalog consistent with Ollama's capabilities.

View available models:

Bash
ollama list
openclaw models list

When adding new models, just pull with Ollama:

Bash
ollama pull mistral

New models will be automatically discovered and available for use.

If you explicitly configure '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'models.providers.ollama'</code>', auto-discovery is skipped and you need to manually define models (see below).

Tutorial.step

Configuration

#

Tutorial.step

Basic Configuration (Implicit Discovery)

The simplest way to enable is to set an environment variable:

Bash
export OLLAMA_API_KEY="ollama-local"

#

Tutorial.step

Explicit Configuration (Manual Models)

Useful when:

- - Ollama is running on a different host/port

- - You want to force specify context window or model list

- - You want to include models that don't declare tool support

Json5
{
  models: {
    providers: {
      ollama: {
        // OpenAI-compatible API baseUrl needs to include /v1
        baseUrl: "http://ollama-host:11434/v1",
        apiKey: "ollama-local",
        api: "openai-completions",
        models: [
          {
            id: "llama3.3",
            name: "Llama 3.3",
            reasoning: false,
            input: ["text"],
            cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
            contextWindow: 8192,
            maxTokens: 8192 * 10
          }
        ]
      }
    }
  }
}

If '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'OLLAMA_API_KEY'</code>' is set, you can omit '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'apiKey'</code>' in the provider entry, and OpenClaw will auto-fill it during availability checks.

#

Tutorial.step

Custom Base URL (Explicit Configuration)

When Ollama is running on a different host or port (explicit configuration disables auto-discovery, so you also need to manually define models):

Json5
{
  models: {
    providers: {
      ollama: {
        apiKey: "ollama-local",
        baseUrl: "http://ollama-host:11434/v1",
      },
    },
  },
}

#

Tutorial.step

Model Selection

After configuration, all your Ollama models are available:

Json5
{
  agents: {
    defaults: {
      model: {
        primary: "ollama/llama3.3",
        fallback: ["ollama/qwen2.5-coder:32b"],
      },
    },
  },
}
Tutorial.step

Advanced

#

Tutorial.step

Reasoning Models

When Ollama reports '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'thinking'</code>' in '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'/api/show'</code>', OpenClaw marks the model as having reasoning capabilities:

Bash
ollama pull deepseek-r1:32b

#

Tutorial.step

Model Costs

Ollama runs locally and is free, so all model costs are set to $0.

#

Tutorial.step

Context Window

For auto-discovered models, OpenClaw uses the context window reported by Ollama when possible; otherwise defaults to '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'8192'</code>'. You can override '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'contextWindow'</code>' and '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'maxTokens'</code>' in explicit provider configuration.

Tutorial.step

Troubleshooting

#

Tutorial.step

Ollama Not Detected

Confirm Ollama is running and you set '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'OLLAMA_API_KEY'</code>' (or an auth profile), and '<strong>'do not'</strong>' explicitly define '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'models.providers.ollama'</code>':

Bash
ollama serve

Also confirm API is accessible:

Bash
curl http://localhost:11434/api/tags

#

Tutorial.step

No Available Models

OpenClaw only auto-discovers models that report supporting tools. If your model doesn't appear in the list:

- - Pull a model that supports tools, or

- - Manually define the model in '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'models.providers.ollama'</code>'

Add new models:

Bash
ollama list  # View installed models
ollama pull llama3.3  # Pull a model

#

Tutorial.step

Connection Refused

Check if Ollama is running on the correct port:

Bash
ps aux | grep ollama


ollama serve
Tutorial.step

See Also

- '<a href="/concepts/model-providers" className="text-emerald-400 hover:text-emerald-300 transition-colors">'Model Providers'</a>' - Provider overview

- '<a href="/concepts/models" className="text-emerald-400 hover:text-emerald-300 transition-colors">'Model Selection'</a>' - How to choose models

- '<a href="/gateway/configuration" className="text-emerald-400 hover:text-emerald-300 transition-colors">'Configuration'</a>' - Complete configuration reference