Skip to content

How-ToGPU

How to Use Aider With Ollama for Local AI Coding

How to install Aider, point it at a local Ollama server, use the recommended ollama_chat model prefix, and raise Ollama's default 2,000-token context window so your code is not silently discarded, from the official Aider documentation.

By , Editorial team

3 min read

How to Use Aider With Ollama for Local AI Coding

Aider is an open-source AI coding assistant that runs in the terminal and can edit your project files. It works with cloud models, but it can also talk to a model you are already running locally with Ollama. That is useful if you want coding help without sending the repository to a hosted API.

Forge PC has not tested Aider as a product. This guide follows the official Aider documentation for Ollama. If you have not installed Ollama yet, start with our guide to running models locally with Ollama or LM Studio. For an editor-based alternative, see how to use Continue with Ollama.

Install Aider

The official Ollama page starts with a two-line install:

python -m pip install aider-install
aider-install

That is the documented method. You need a working Python install on the PC first. After aider-install finishes, you should be able to run aider from a new terminal window.

Point Aider at Ollama

Aider needs to know where the Ollama server is. The usual local address is http://127.0.0.1:11434. Official setup, depending on your system, is:

export OLLAMA_API_BASE=http://127.0.0.1:11434

on macOS or Linux, or:

setx   OLLAMA_API_BASE http://127.0.0.1:11434

on Windows. The docs are clear that after setx you must restart the shell before the variable is available.

If your Ollama instance requires an API key, the same page says you can set OLLAMA_API_KEY with export or setx in the same way. Most local, default Ollama installs do not need a key.

Raise the context window before you start

This is the step that catches people out. Official Aider documentation warns that Ollama uses a 2,000-token context window by default, which is very small for coding work, and that Ollama silently discards anything that does not fit. Aider's own words are that this is "especially dangerous because many users don't even realize that most of their data is being discarded by Ollama."

The documented way to start the Ollama server with a larger window is:

OLLAMA_CONTEXT_LENGTH=8192 ollama serve

Pull a model first if you do not already have one:

ollama pull <model>

Replace <model> with a model tag you actually have, or plan to download, in Ollama. We are not recommending a specific coding model here; pick one that fits your GPU's VRAM, as discussed in our local AI RAM and NVIDIA vs AMD for local AI guides.

Aider also says that, by default, it will set Ollama's context window large enough for each request you send plus 8,000 tokens for the reply, so data is not silently dropped. You can instead pin a fixed window in an .aider.model.settings.yml file if you want a constant size. The docs give this as an example of the format, not as a model recommendation:

- name: ollama/qwen2.5-coder:32b-instruct-fp16
  extra_params:
    num_ctx: 65536

A 65,536-token window will only work if the model and your hardware can actually support it. Do not copy that number unless you know the model can take it.

Start Aider on your project

In a second terminal, change into the project directory and launch Aider with the ollama_chat/ prefix. The official docs recommend ollama_chat/ over ollama/:

cd /to/your/project
aider --model ollama_chat/<model>

Use the same model name you pulled in Ollama. Stay inside the repository you want Aider to edit, and review every proposed change. A local model can still overwrite a file incorrectly; Aider is not a substitute for version control.

If Aider warns that it is not familiar with the model, read the model warnings page linked from the official Ollama documentation. Those warnings are about Aider's built-in expectations for the model, not about Ollama failing to start.

Our verdict

Install Aider with aider-install, set OLLAMA_API_BASE to your local Ollama server, and launch it with --model ollama_chat/<model> rather than the older ollama/ prefix. The important practical step is the context window: Ollama's default 2,000 tokens is too small for coding, and overflowing context is discarded silently. Start the server with OLLAMA_CONTEXT_LENGTH=8192 or let Aider size the window per request, and do not assume a huge num_ctx value will fit in VRAM. We have not tested Aider ourselves; these steps follow the official Aider Ollama documentation.

The bottom line

Install Aider with `aider-install`, set `OLLAMA_API_BASE` to your local Ollama server, and launch it with `--model ollama_chat/<model>` rather than the older `ollama/` prefix. The important practical step is the context window: Ollama's default 2,000 tokens is too small for coding, and overflowing context is discarded silently. Start the server with `OLLAMA_CONTEXT_LENGTH=8192` or let Aider size the window per request, and do not assume a huge `num_ctx` value will fit in VRAM. We have not tested Aider ourselves; these steps follow the official Aider Ollama documentation.

Sources

  1. 01Aider documentation, Ollama

About the author

Forge PC Staff

Editorial team

The shared byline for articles researched, written and edited by the Forge PC editorial team. How we source, check and correct our work is set out in our editorial policy.

More from Forge PC Staff

Read next

Open WebUI vs AnythingLLM: Which Local Chat App Should You Use?

Versus

Open WebUI vs AnythingLLM: Which Local Chat App Should You Use?

Open WebUI vs AnythingLLM for local chat and document question-and-answer: a self-hosted web interface with team features, or a workspace-centred desktop app that can run without Docker, based on Open WebUI's official September 2026 comparison and each project's docs.

Forge PC Staff4 min