# Local models with Ollama

> Run the model on your machine or on your own server with Ollama, so that your data does not leave your infrastructure.

Source: https://opendb.tools/en/docs/ollama

[Ollama](https://ollama.com) runs language models on your own hardware. Paired with OpenDB, it gives you an agent whose **requests never leave your infrastructure**.

## Install Ollama and a model

Install Ollama by following the instructions on its site, then download a model:

```bash
ollama pull qwen3:4b
```

Check that it answers:

```bash
ollama list
```

## Connect Ollama to OpenDB

1. Open **Settings → Models**.
2. Click **Connect** next to **Ollama**.
3. Keep the default address, `http://localhost:11434`, if Ollama runs on the same machine. No key is required.
4. Enable the models you downloaded.

From a terminal, check the enabled models:

```bash
opendb ai:models ollama
```

## Choose a model

OpenDB's agent works by calling **tools**. Choose a model that supports them.

| Your hardware | Starting point |
|---|---|
| A laptop without a dedicated graphics card | A small model, around 4 billion parameters |
| A workstation with a graphics card | A medium model, 8 to 14 billion parameters |
| A dedicated server | A large model, depending on the memory available |

A larger model follows instructions better, writes more accurate SQL and makes fewer mistakes when choosing tools. A small model is fine for exploring a schema and asking simple questions.

## Ollama on another server

You can host Ollama on a server of your network and connect OpenDB to it: give its address instead of `http://localhost:11434`.

The agent's requests then travel over your network. Protect this access: Ollama does not authenticate its clients by default.

## Other local servers

Any server that exposes an **OpenAI-compatible** API is connected as a custom provider. See [AI providers](/en/docs/ai-providers).

## Tips with a small model

- **Stay in read-only mode** as long as you do not need to write.
- **Ask one question at a time.** Multi-part requests lose a small model more easily.
- **Lower the number of rows read per query** in **Settings → AI agent**: a small model has less room for data.
- **Hide the tables you do not need** to lighten the schema the agent has to understand. See [Project settings](/en/docs/project-settings).
- **Write the project memory in the imperative**, with precise instructions. See [Memory](/en/docs/memory).

## What stays local

With Ollama on your machine:

- your questions and the rows read by the agent do not leave your computer;
- OpenDB sends nothing to a third party;
- usage tracking stays stored locally.

You then do not need to [clone the database](/en/docs/cloning-anonymization) to protect your data. Cloning remains useful for working on a copy rather than on production.

## Troubleshooting

| Symptom | What to check |
|---|---|
| No model appears | Is Ollama running? Has a model been downloaded? |
| OpenDB cannot reach Ollama | Are the address and port correct? Is a firewall blocking the connection? |
| The agent does not use its tools | Does the model support tool calls? Try a larger model. |
| Answers are very slow | The model is too large for your hardware |
