# Run templates on Ollama

Ollama runs a model on your own computer. Point AgentRun at it and you pay nothing for the model, and nothing you send leaves your machine for a model provider. Paid tools a template calls still cost what they cost.

## Set it up

1. Install Ollama. On macOS or Windows, download it from ollama.com/download. On Linux:

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

2. Pull a model that can call tools. Templates search, fetch pages and write files, so the model has to call tools. qwen3:8b can. Check any other model with ollama show <tag>: tools must be listed under Capabilities.

   ```sh
   ollama pull qwen3:8b
   ollama show qwen3:8b
   ```

3. Give it room for a template's prompt. Ollama loads a model with 4,096 tokens of context. A template's first request is about 12,000, and Ollama drops the start, the question included, so the agent answers that it was never asked anything. Make a copy of the model with 32,768 tokens. It needs about 10 GB of memory. On Windows, put the two lines of the Modelfile in a file with any editor, then run ollama create.

   ```sh
   printf 'FROM qwen3:8b\nPARAMETER num_ctx 32768\n' > Modelfile
   ollama create qwen3-8b-32k -f Modelfile
   ```

4. Point AgentRun at it. If AgentRun runs as a service, install the service again with the model. It restarts and keeps the setting:

   ```sh
   ~/.agentrun/bin/agentrun service install --env AGENT_MODEL_BASE_URL=http://localhost:11434/v1 --env AGENT_MODEL_GATEWAY_IDS=bare --env AGENT_MODEL=qwen3-8b-32k --env AGENT_MODEL_PRICE=0,0,0 --env AGENT_MODEL_API_KEY=none
   ```

5. Or, if AgentRun runs in the background, stop it and start it with the same five settings. A background start keeps only what that line sets.

   ```sh
   ~/.agentrun/bin/agentrun stop
   curl -fsSL https://agentrun.ai/install | AGENT_MODEL_BASE_URL=http://localhost:11434/v1 AGENT_MODEL_GATEWAY_IDS=bare AGENT_MODEL=qwen3-8b-32k AGENT_MODEL_PRICE=0,0,0 AGENT_MODEL_API_KEY=none sh
   ```

6. Install a template. Pick one on this site and press Install. Every run then goes to your model, whatever model the template names, and the model costs nothing. A template that calls a paid service (monid, Parallel) still pays that service, as its page says.

## Before you start

- AGENT_MODEL_API_KEY=none is a key Ollama ignores. Without a key set, AgentRun refuses each run.
- AGENT_MODEL_PRICE=0,0,0 tells AgentRun a run costs $0, so a template's spend cap still works.
- A template's Tested line is measured on its own model, not yours. A small local model passes fewer cases, and on a computer without a GPU a run takes 10 to 15 minutes.
- The model is local, the web is not. Searches and page fetches still go out to the web. Search needs no key: it goes through Exa's keyless tier, or through Parallel when you set PARALLEL_API_KEY.

Templates that already prefer a free hosted model: https://marketplace.agentrun.ai/free.md
