---
title: 3. Using a local model via Ollama
---

If you're happy using OpenAI, you can skip this section, but many people are interested in using models they run themselves. The easiest way to do this is via the great work of our friends at [Ollama](https://ollama.com/), who provide a simple to use client that will download, install and run a [growing range of models](https://ollama.com/library) for you.

### Install Ollama

They provide a one-click installer for Mac, Linux and Windows on their [home page](https://ollama.com/).

### Pick and run a model

Since we're going to be doing agentic work, we'll need a very capable model, but the largest models are hard to run on a laptop. We think `mixtral 8x7b` is a good balance between power and resources, but `llama3` is another great option. You can run it simply by running

```bash
ollama run mixtral:8x7b
```

The first time you run it will also automatically download and install the model for you.

### Switch the LLM in your code

There are two changes you need to make to the code we already wrote in `1_agent` to get Mixtral 8x7b to work. First, you need to switch to that model. Replace the call to `Settings.llm` with this:

```javascript
Settings.llm = ollama({
  model: "mixtral:8x7b",
});
```

### Run local agent

You can also create local agent by importing `agent` from `@llamaindex/workflow`.

```javascript
import { agent } from "@llamaindex/workflow";

const workflow = agent({
  tools: [getWeatherTool],
});

const resutl = workflow.run(
  "What's the weather like in San Francisco?",
);
```

### Next steps

Now you've got a local agent, you can [add Retrieval-Augmented Generation to your agent](4_agentic_rag).
