---
# System prepended metadata

title: Aider Setup

---

## Setup `pyenv`

https://github.com/pyenv/pyenv#installation

* Install: `curl -fsSL https://pyenv.run | bash`
* Then, run these commands in terminal:

```bash
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init - bash)"' >> ~/.bashrc
```

* Install these deps: `sudo apt install make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm xz-utils tk-dev libffi-dev liblzma-dev git`

* Then, do this:

```bash=
pyenv install --list #See the versions available for installation  

pyenv install 3.11.4 #Installs python 3.11.4
pyenv versions #See available versions and the active version is marked with asterisk

pyenv local 3.11.4 #Activate the version for the CURRENT SHELL
pyenv global 3.11.4 #Activate the version for ALL THE SHELLS
```

## Setup Ollama

* Install Ollama on Linux: `curl -fsSL https://ollama.com/install.sh | sh`
* Add these lines to your `~/.bashrc` or `~/.zshrc` file: 
    * `export OLLAMA_HOST=<OUR-OLLAMA-SERVER>`
    * `export OLLAMA_API_BASE=<OUR-OLLAMA-SERVER>`
    * To reload the shell: `exec bash` (or `exec zsh`)
* To chat with Ollama: `ollama run $(ollama list | awk 'NR>1 {print $1}' | fzf) --verbose`

## Setup `lazygit`

```bash=
LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": *"v\K[^"]*')
curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/download/v${LAZYGIT_VERSION}/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz"
tar xf lazygit.tar.gz lazygit
sudo install lazygit -D -t /usr/local/bin/
```


## Install Aider

* Then, install Aider as per the instructions here: https://aider.chat/docs/install.html
* Install `fzf` (fuzzy finder): `sudo apt install fzf`
* Run aider with Ollama: `aider --model ollama/$(ollama list | awk 'NR>1 {print $1}' | fzf) --edit-format diff`

# Using Commercial LLM Models

Commercial models work much better with aider: https://aider.chat/docs/leaderboards/. And surprisingly, we have a few free options in commercial models.


## FREE! Google Gemini API

Google Gemini API is actually FREE!! There are 2 catches though: (1) The Free API will use your data for training their models, (2) It is rate limited to 100 requests per day.

https://aider.chat/docs/llms/gemini.html

* Go to: https://aistudio.google.com/
* Create yoru free api key and copy the API key
* Then, in your bashrc, add this: `export GEMINI_API_KEY=<key>`
* Then, run aider with gemini: `aider --model gemini`

## FREE 5$ credits! With Perplexity Pro

Perplexity is giving 5$ free API credits per month with Pro. **You can't directly use Perplexity API with `aider`. However, you can use Perplexity using OpenRouter** (https://openrouter.ai/). Here are the steps to set it up:

* Create an API key in your [Perplexity account](https://www.perplexity.ai/account/api/keys)
* Login on [OpenRouter](https://openrouter.ai/) using your Google account
* Go to: https://openrouter.ai/settings/integrations and enable Perplexity and add your Perplexity API key
* Go to: https://openrouter.ai/settings/keys and create an OpenRouter key and copy it
* Add to your bashrc: `export OPENROUTER_API_KEY=<key>`
* Now, run aider with: `aider --model openrouter/perplexity/sonar`

### ASIDE: Benefits of OpenRouter

Setting up OpenRouter is worth it. OpenRouter provides a single end-point for ALL models that exist out there. You can access OpenAI, Google Gemini, Grok, DeepSeek and all commercial and open-source models using a single API key of OpenRouter. 

