This is a hello-world for aider
which is a nice tool to generate code with AI using command line
Aider is AI pair programming in your terminal
Install Link to heading
The installation uses uv
which seems like a new python package manager. Cool! will circle back later.
python -m pip install aider-install
aider-install
Now, we have aider in PATH
which will point $HOME/.local/bin/aider
Hello world with OpenAI Link to heading
The first example shows how to use aider to generate a file on the command line.
export OPENAI_API_KEY=<KEY>
aider --list-models openai/
aider --model gpt-4o-mini main.py
Aider v0.74.2
Model: gpt-4o-mini with whole edit format
Git repo: .git with 0 files
Repo-map: using 4096 tokens, auto refresh
Added main.py to the chat.
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
main.py
> generate flask application to serve home page
To create a Flask application that serves a home page, I will implement the necessary code in the main.py file. Here’s the complete content for the
file:
main.py
@@ -0,0 +1,10 @@
+from flask import Flask
+
+app = Flask(__name__)
+
+@app.route('/')
+def home():
+ return "Welcome to the Home Page!"
+
+if __name__ == '__main__':
+ app.run(debug=True)
Tokens: 734 sent, 80 received. Cost: $0.00016 message, $0.00016 session.
Committing main.py before applying edits.
Commit 0fa4961 feat: Add main.py file to the project
Applied edit to main.py
Commit f8857f7 feat: Create Flask application to serve home page
You can use /undo to undo and discard each aider commit.
Hello world with Ollama Link to heading
The second example is using Ollama (if you don’t mind setting your computer on fire)
export OLLAMA_API_BASE=http://127.0.0.1:11434
aider --model ollama_chat/llama3.2:latest