> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://pushai.vercel.app/api/mcp` to find what you need.
>
> **Have feedback?** Use `submit_feedback` on the same MCP server.

# Local models (Ollama) \[Your code never leaves your machine]

Local mode runs your commit generation through [Ollama](https://ollama.com) on
your own machine. There is no API key, no account, and no network call to an AI
provider — the diff stays where you wrote it.

:::tip
This is the fully offline path. Choose local mode with Ollama and an installed
model and PushAI can generate commit messages with your machine disconnected
from any AI service.
:::

## Install Ollama

If you do not have it yet:

:::code-group
```bash [macOS / Linux]
curl -fsSL https://ollama.com/install.sh | sh
```

```bash [Windows]
irm https://ollama.com/install.ps1 | iex
```
:::

Or download it from [ollama.com/download](https://ollama.com/download). `pai setup` will offer you
these same instructions if it detects that `ollama` is missing from your
`PATH`.

## Pull a model

```bash
ollama pull llama3.2
```

Anything you already have installed shows up in PushAI. Smaller models (around
1–8B) are plenty for writing two lines about a diff; run `ollama list` to see
what is on your machine.

## How PushAI uses Ollama

When you choose **local machine (Ollama)** in [`pai setup`](/introduction/setup-wizard):

1. **Detection** — PushAI runs `ollama -v` and reports the version:
   `ollama v0.5.7 detected`. If it is not installed you get the install
   instructions above instead.
2. **Server startup** — it pings `http://127.0.0.1:11434/api/tags`. If the
   server is not up, PushAI spawns `ollama serve` detached (so it outlives the
   CLI) and polls for up to about five seconds. If that fails, setup stops with
   `Ollama is not running and could not be started automatically. Start it
   manually with: ollama serve`.
3. **Model listing** — it reads your installed models with `ollama list`. With
   several installed you pick one interactively; with exactly one it is used
   automatically; with none you are offered `ollama pull <model>` instructions
   or the model library at [ollama.com/search](https://ollama.com/search).
4. **Selection** — the choice is saved as your active provider:
   `{"id": "local", "mode": "local", "model": "llama3.2"}`.

At commit time, [`pai commit`](/commands/commit) restarts the server if needed,
sends the system prompt plus the diff to the model at temperature `0.3`, and
reads back the two-line message.

## What local mode looks like in the terminal

```text
✔ ollama v0.5.7 detected
✔ you have 4 models installed
? which model would you like to use?
  llama3.2
  qwen2.5-coder:7b
  ...
```

Your commits then render as `local [llama3.2]` everywhere PushAI shows a
provider — in `pai peak`, `pai switch`, and the `provider` line of
`pai commit`.

## Things worth knowing

:::info
**First-request warm-up latency**

The first commit generation after a system boot or model switch loads the model weights into memory, which can take noticeably longer. Subsequent commits within the same session run against the loaded model and respond much faster.
:::

:::steps
#### Malformed or JSON responses are retried automatically

Local models — especially reasoning models or models processing large diffs — occasionally return raw JSON objects, code fences, or XML-style tags instead of plain commit text:

````text
╭─▶ proposed changes
│
├─▶ ```json
╰─▶ {
  "response": "I'm sorry, but I can't assist with
  that request."
}
````

PushAI automatically detects outputs wrapped in code fences, raw JSON objects, or `<commit>`, `<message>`, and `<response>` tags and requests a clean generation. While retrying, the terminal spinner updates to show progress:

```text
⠸ response looked like JSON — regenerating (2/4)..
```

PushAI retries up to **4 times**. If all four attempts return non-message output, the command exits with:

```text
The provider returned non-message output 4 times in a row.
Try a different model, or pass a message with `-m`.
```

To resolve this, switch to a standard instruct model (such as `llama3.2` or `qwen2.5-coder:7b`) or stage smaller, more focused batches of changes to reduce the context load.

#### No API keys or keychain secrets

Because local mode runs on your machine without authentication, PushAI stores only the mode and model name in `~/.config/pushai/config.json`. Nothing sensitive is written to disk or required in your system keychain.

#### Interactive regeneration works identically

Choosing *regenerate* during the commit review loop sends the same staged diff back to your local Ollama model to produce an alternative commit message.

#### `pai reset` leaves Ollama intact

Running `pai reset` only clears PushAI's local provider configuration. Your Ollama installation and downloaded models remain untouched on your machine.
:::

:::warning
**Avoid reasoning-heavy models**

Reasoning-focused models often spend their entire token budget on internal thought blocks and return an empty final output. When this happens, PushAI stops with:

`No commit message was generated. Try switching to a non-reasoning model.`

Stick to standard instruct or coding models such as `llama3.2` or `qwen2.5-coder:7b` for reliable results.
:::

## See also

* [Bring Your Own Key](/providers/byok) — when you want a bigger hosted model.
* [Cloud Hosted](/providers/cloud) — managed PushAI AI, coming soon.
