---
title: Ollama
description: ollama() — local-model provider via Ollama's OpenAI-compatible API. Run llama3, mistral, qwen, deepseek locally; same agent code as production providers.
---

> Ollama runs local models on your machine. agentfootprint's `ollama()` factory wraps Ollama's OpenAI-compatible endpoint as an `LLMProvider` — your agent code is identical between local-Ollama dev and cloud-Anthropic production.

## Install

Ollama itself: see [ollama.com/download](https://ollama.com/download). Pull a model:

```bash
ollama pull llama3.1
```

agentfootprint side: `ollama()` uses the `openai` SDK under the hood (via OpenAI-compatible endpoint), so install the OpenAI peer dep:

```bash
npm install openai
```

## Use

```ts
import { Agent } from 'agentfootprint';
import { ollama } from 'agentfootprint/llm-providers';

const provider = ollama({
  defaultModel: 'llama3.1',         // used when the request model is the 'ollama' shorthand
  host: 'http://localhost:11434',   // default — talks to http://localhost:11434/v1
});

const agent = Agent.create({
  provider,
  model: 'llama3.1',
}).build();
```

`ollama()` is a thin convenience over `openai()` — it lives on the `agentfootprint/llm-providers` subpath (vendor-SDK-backed providers are kept off the main barrel for tree-shaking). Options: `host` (defaults to `http://localhost:11434`), `baseURL` (overrides `host`), `apiKey` (Ollama ignores it; defaults to `'ollama'`), `defaultModel` (defaults to `llama3.2`), and `defaultMaxTokens`.

## When to use Ollama

- **Local development** — no API key, no cost, no network.
- **Privacy-sensitive workloads** — model + data never leave the machine.
- **Cost-sensitive batch jobs** — local inference for high-volume background processing.
- **Edge / offline deployments** — bundle the model with your app.

## Limitations

- Local models are smaller and less capable than frontier models. Tool-calling reliability varies by model — llama3.1 + qwen2.5 + deepseek work; smaller models may struggle.
- No streaming for some local models (depends on Ollama config).
- Multi-modal not exposed.

## Switching to Anthropic / OpenAI for production

Same agent code; swap the provider one line:

```ts
import { anthropic, ollama } from 'agentfootprint/llm-providers';

const provider = process.env.NODE_ENV === 'production'
  ? anthropic({ apiKey: process.env.ANTHROPIC_API_KEY! })
  : ollama({ defaultModel: 'llama3.1' });
```

## Next steps

- [OpenAI](/agentfootprint/integrations/openai/) — `baseURL` pattern works with any OpenAI-compatible endpoint
- [Mocks-first development](/agentfootprint/getting-started/quick-start/) — `mock()` for $0 deterministic tests
