# Ollama configuration

> The basic, explicit, and custom base URL config shapes for the Ollama provider

- 网址：https://funcoding.ai/agents/openclaw/providers/ollama/configuration/
- 来源：OpenClaw 官方文档原文（英文），MIT 许可，同步于 2026-10-11
- 官方原文：https://docs.openclaw.ai/zh-CN/providers/ollama/configuration

---
## Configuration

**Basic (implicit discovery)**

```bash
export OLLAMA_API_KEY="ollama-local"
```

<div class="callout callout-tip">

If `OLLAMA_API_KEY` is set, you can omit `apiKey` in the provider entry; OpenClaw fills it in for availability checks.

</div>

**Explicit (manual models)**

Use explicit config for hosted cloud setup, a non-default host/port, forced
context windows, or per-model settings. Hosted `https://ollama.com` uses only
the listed models; a self-hosted endpoint also lists its other installed models:

```json5
{
  models: {
    providers: {
      ollama: {
        baseUrl: "https://ollama.com",
        apiKey: "OLLAMA_API_KEY",
        api: "ollama",
        models: [
          {
            id: "kimi-k2.5:cloud",
            name: "kimi-k2.5:cloud",
            reasoning: false,
            input: ["text", "image"],
            cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
            contextWindow: 128000,
            maxTokens: 8192
          }
        ]
      }
    }
  }
}
```

**Custom base URL**

The listed model keeps these settings; other models installed on that host are
still discovered:

```json5
{
  models: {
    providers: {
      ollama: {
        apiKey: "ollama-local",
        baseUrl: "http://ollama-host:11434", // No /v1 - native Ollama API URL
        api: "ollama", // Explicit: guarantees native tool-calling behavior
        timeoutSeconds: 300, // Optional: longer connect/stream budget for cold local models
        models: [
          {
            id: "qwen3:32b",
            name: "qwen3:32b",
            params: {
              keep_alive: "15m", // Optional: keep the model loaded between turns
            },
          },
        ],
      },
    },
  },
}
```

<div class="callout callout-warning">

Do not add `/v1`. That path selects OpenAI-compatible mode, where tool calling is not reliable.

</div>
