Frequently asked questions
- How does aider use git?
- GPT-4 vs GPT-3.5
- Accessing other LLMs with OpenRouter
- Can I use aider with other LLMs, local LLMs, etc?
- Aider isn’t editing my files?
- Can I run aider in Google Colab?
- How can I run aider locally from source code?
- Can I script aider?
- What code languages does aider support?
- How to use pipx to avoid python package conflicts?
- How can I add ALL the files to the chat?
- Can I specify guidelines or conventions?
- Can I change the system prompts that aider uses?
How does aider use git?
Aider works best with code that is part of a git repo. Aider is tightly integrated with git, which makes it easy to:
- Use git to undo any GPT changes that you don’t like
- Go back in the git history to review the changes GPT made to your code
- Manage a series of GPT’s changes on a git branch
Aider specifically uses git in these ways:
- It asks to create a git repo if you launch it in a directory without one.
- Whenever GPT edits a file, aider commits those changes with a descriptive commit message. This makes it easy to undo or review GPT’s changes.
- Aider takes special care if GPT tries to edit files that already have uncommitted changes (dirty files). Aider will first commit any preexisting changes with a descriptive commit message. This keeps your edits separate from GPT’s edits, and makes sure you never lose your work if GPT makes an inappropriate change.
Aider also allows you to use in-chat commands to
/undo the last change made by GPT.
To do more complex management of your git history, you cat use raw
either by using
/git within the chat, or with standard git tools outside of aider.
While it is not recommended, you can disable aider’s use of git in a few ways:
--no-auto-commitswill stop aider from git committing each of GPT’s changes.
--no-dirty-commitswill stop aider from committing dirty files before applying GPT’s edits.
--no-gitwill completely stop aider from using git on your files. You should ensure you are keeping sensible backups of the files you are working with.
GPT-4 vs GPT-3.5
Aider supports all of OpenAI’s chat models.
You can choose a model with the
--model command line argument.
You will probably get the best results with one of the GPT-4 Turbo models,
which you can use by running
(this is a convenient shortcut for
They have large context windows, good coding skills and
they generally obey the instructions in the system prompt.
gpt-4-0613 model is a great choice if GPT-4 Turbo is having
trouble with your coding task, although it has a smaller context window
which can be a real limitation.
All the GPT-4 models are able to structure code edits as “diffs” and use a repository map to improve its ability to make changes in larger codebases.
limited to editing somewhat smaller codebases.
It is less able to follow instructions and
can’t reliably return code edits as “diffs”.
Aider disables the
when using GPT-3.5.
To use GPT-3.5, you can run
aider --35turbo as a shortcut for
For detailed quantitative comparisons, please see the aider blog which contains many benchmarking articles.
Accessing other LLMs with OpenRouter
OpenRouter provide an interface to many models which are not widely accessible, in particular gpt-4-32k and claude-2.
To access the openrouter models simply
- register for an account, purchase some credits and generate an api key
--openai-api-keyto your openrouter key
--modelto the model of your choice (
Some of the models weren’t very functional and each llm has its own quirks. The anthropic models work ok, but the llama-2 ones in particular will need more work to play friendly with aider.
Can I use aider with other LLMs, local LLMs, etc?
Aider provides experimental support for LLMs other than OpenAI’s GPT-3.5 and GPT-4. The support is currently only experimental for two reasons:
- GPT-3.5 is just barely capable of editing code to provide aider’s interactive “pair programming” style workflow. None of the other models seem to be as capable as GPT-3.5 yet.
- Just “hooking up” aider to a new model by connecting to its API is almost certainly not enough to get it working in a useful way. Getting aider working well with GPT-3.5 and GPT-4 was a significant undertaking, involving specific code editing prompts and backends for each model and extensive benchmarking. Officially supporting each new LLM will probably require a similar effort to tailor the prompts and editing backends.
Numerous users have done experiments with numerous models. None of these experiments have yet identified other models that look like they are capable of working well with aider.
Once we see signs that a particular model is capable of code editing, it would be reasonable for aider to attempt to officially support such a model. Until then, aider will simply maintain experimental support for using alternative models.
There are ongoing discussions about LLM integrations in the aider discord.
Here are some GitHub issues which may contain relevant information.
OpenAI API compatible LLMs
If you can make the model accessible via an OpenAI compatible API,
you can use
--openai-api-base to connect to a different API endpoint.
LocalAI and SimpleAI look like relevant tools to serve local models via a compatible API.
Aider can be configured to connect to the OpenAI models on Azure. Aider supports the configuration changes specified in the official openai python library docs. You should be able to run aider with the following arguments to connect to Azure:
$ aider \
--openai-api-type azure \
--openai-api-key your-key-goes-here \
--openai-api-base https://example-endpoint.openai.azure.com \
--openai-api-version 2023-05-15 \
--openai-api-deployment-id deployment-name \
You could also store those values in an
.aider.conf.yml file in your home directory:
See the official Azure documentation on using OpenAI models for more information on how to populate the above configuration values.
Aider isn’t editing my files?
Sometimes GPT will reply with some code changes that don’t get applied to your local files. In these cases, aider might say something like “Failed to apply edit to filename”.
This usually happens because GPT is not specifying the edits to make in the format that aider expects. GPT-3.5 is especially prone to disobeying the system prompt instructions in this manner, but it also happens with GPT-4.
Aider makes every effort to get GPT to conform, and works hard to deal with replies that are “almost” correctly formatted. If Aider detects an improperly formatted reply, it gives GPT feedback to try again. Also, before each release new versions of aider are benchmarked. This helps prevent regressions in the code editing performance of GPT that could have been inadvertantly introduced.
But sometimes GPT just won’t cooperate. In these cases, here are some things you might try:
/dropto remove files from the chat session which aren’t needed for the task at hand. This will reduce distractions and may help GPT produce properly formatted edits.
/clearto remove the conversation history, again to help GPT focus.
Can I run aider in Google Colab?
User imabutahersiddik has provided this Colab notebook.
How can I run aider locally from source code?
To run the project locally, follow these steps:
# Clone the repository:
git clone email@example.com:paul-gauthier/aider.git
# Navigate to the project directory:
# Install the dependencies listed in the `requirements.txt` file:
pip install -r requirements.txt
# Run the local version of Aider:
python -m aider.main
Can I script aider?
You can script aider via the command line or python.
Aider takes a
--message argument, where you can give it a natural language instruction.
It will do that one thing, apply the edits to the files and then exit.
So you could do:
aider --message "make a script that prints hello" hello.js
Or you can write simple shell scripts to apply the same instruction to many files:
for FILE in *.py ; do
aider --message "add descriptive docstrings to all the functions" $FILE
You can also script aider from python:
from aider.coders import Coder
# Make an openai client
client = openai.OpenAI(api_key=os.environ["OPENAI_API_KEY"])
# This is a list of files to add to the chat
fnames = ["foo.py"]
# Create a coder object
coder = Coder.create(client=client, fnames=fnames)
# This will execute one instruction on those files and then return
coder.run("make a script that prints hello world")
# Send another instruction
coder.run("make it say goodbye")
What code languages does aider support?
Aider supports pretty much all the popular coding languages. This is partly because GPT-4 is fluent in most mainstream languages, and familiar with popular libraries, packages and frameworks.
In fact, coding with aider is sometimes the most magical when you’re working in a language that you are less familiar with. GPT often knows the language better than you, and can generate all the boilerplate to get to the heart of your problem. GPT will often solve your problem in an elegant way using a library or package that you weren’t even aware of.
Aider uses tree-sitter to do code analysis and help GPT navigate larger code bases by producing a repository map.
Aider can currently produce repository maps for most mainstream languages, listed below. But aider should work quite well for other languages, even without repo map support.
- Emacs Lisp
How to use pipx to avoid python package conflicts?
If you are using aider to work on a python project, sometimes your project will require
specific versions of python packages which conflict with the versions that aider
If this happens, the
pip install command may return errors like these:
aider-chat 0.23.0 requires somepackage==X.Y.Z, but you have somepackage U.W.V which is incompatible.
You can avoid this problem by installing aider using
which will install it globally on your system
within its own python environment.
This way you can use aider to work on any python project,
even if that project has conflicting dependencies.
Install pipx then just do:
pipx install aider
How can I add ALL the files to the chat?
People regularly ask about how to add many or all of their repo’s files to the chat. This is probably not a good idea and will likely do more harm than good.
The best approach is think about which files need to be changed to accomplish the task you are working on. Just add those files to the chat.
Usually when people want to add “all the files” it’s because they think it will give GPT helpful context about the overall code base. Aider will automatically give GPT a bunch of additional context about how those specific files relate to the rest of your git repo. It does this by analyzing your entire codebase in light of the current chat to build a compact repository map.
Adding a bunch of files that are mostly irrelevant to the task at hand will often distract or confuse GPT. GPT will give worse coding results, and sometimese even fail to correctly edit files. Addings extra files will also increase the token costs on your OpenAI invoice.
Again, it’s usually best to just add the files to the chat that will need to be modified. If you still wish to add lots of files to the chat, you can:
- Use a wildcard when you launch aider:
- Use a wildcard with the in chat
- Give the
/addcommand a directory name and it will recurisvely add every file under that dir:
Can I specify guidelines or conventions?
Sometimes you want GPT to be aware of certain coding guidelines, like whether to provide type hints, which libraries or packages to prefer, etc.
Just put any extra instructions in a file
CONVENTIONS.md and then add it to the chat.
For more details, see this documentation on using a conventions file with aider.
Can I change the system prompts that aider uses?
Aider is set up to support different system prompts and edit formats
in a modular way. If you look in the
aider/coders subdirectory, you’ll
see there’s a base coder with base prompts, and then there are
a number of
different specific coder implementations.
If you’re thinking about experimenting with system prompts this document about benchmarking GPT-3.5 and GPT-4 on code editing might be useful background.
While it’s not well documented how to add new coder subsystems, you may be able to modify an existing implementation or use it as a template to add another.
To get started, try looking at and modifying these files.
The wholefile coder is currently used by GPT-3.5 by default. You can manually select it with
The editblock coder is currently used by GPT-4 by default. You can manually select it with
The universal diff coder is currently used by GPT-4 Turbo by default. You can manually select it with
When experimenting with coder backends, it helps to run aider with
--verbose --no-pretty so you can see
all the raw information being sent to/from GPT in the conversation.