Skip to main content
Aider is an AI pair programming tool that runs in your terminal. It allows you to edit code in your local Git repository using natural language commands. By connecting Aider to Cerebras Inference, you can leverage ultra-fast inference speeds for an enhanced coding experience.

Prerequisites

Before you begin, ensure you have:
  • Cerebras API Key - Get a free API key here
  • Python 3.10 to 3.13 - Aider requires Python to run
  • Git - Aider works with Git repositories to track changes
  • A code editor - While Aider runs in the terminal, you’ll want an editor to view your files

Installation and Setup

1

Install Aider

Install Aider using pip. This will download and install the latest version of Aider and its dependencies.
pip install aider-chat
Alternatively, you can use pipx for an isolated installation:
pipx install aider-chat
Using pipx is recommended for isolated environments, as it installs Aider in its own virtual environment.
2

Set up your Cerebras API key

Aider needs your Cerebras API key to authenticate requests. Set it as an environment variable so Aider can access it.
export CEREBRAS_API_KEY=your-cerebras-api-key-here
For a permanent setup, add this line to your shell configuration file (~/.bashrc, ~/.zshrc, etc.).
3

Initialize your project directory

Aider works with Git repositories to track changes. Navigate to your project and ensure it’s a Git repository.
cd /path/to/your/project
If your project is not already a Git repository, initialize one:
git init
git add .
git commit -m "Initial commit"
Aider uses Git to track all changes it makes, allowing you to easily review and revert modifications.
4

Create an Aider configuration file

Create an .aider.conf.yml file in your project root for easier usage. This eliminates the need to specify connection details every time you launch Aider.You can create this file via a terminal command:
cat > .aider.conf.yml <<EOF
model: cerebras/llama-3.3-70b
openai-api-key: env:CEREBRAS_API_KEY
EOF
With this configuration, you can simply run aider without additional flags.

Using Aider with Cerebras

1

Start Aider with a Cerebras model

Launch Aider and specify a Cerebras model using the OpenAI-compatible API. If you created a configuration file, simply run aider. Otherwise, use the full command:
aider
This command tells Aider to use the llama-3.3-70b model from Cerebras and connect to Cerebras’s API endpoint.
The cerebras/ prefix tells Aider to use LiteLLM routing to Cerebras, which automatically configures the correct API endpoint. The --openai-api-key flag is used because Aider expects this parameter name for OpenAI-compatible providers.
2

Create a new file from scratch

Since we are starting with an empty project, let’s ask Aider to create a file. Aider can generate code and create files based on your instructions.Paste this prompt into Aider:
Create a python script named fibonacci.py that calculates the fibonacci sequence using a recursive approach.
Aider will create fibonacci.py with the implementation. You don’t need to manually create the file first.
3

Refine the code

Now, let’s ask Aider to improve the implementation. The model will analyze the existing code and apply your requested changes.
Convert the fibonacci function to use iteration instead of recursion for better performance. Also add a main block to run it.
Aider will:
  1. Analyze the recursive implementation
  2. Rewrite it to use iteration
  3. Add the main execution block
  4. Commit the changes to Git
4

Run the code

You can run shell commands directly within Aider to verify the changes.
/run python fibonacci.py
Aider will run the command and show the output:
Running python fibonacci.py
The 10th Fibonacci number is: 34
You can choose to add this output to the chat so Aider can see the result and fix any errors if they occur.
5

Review and undo

You can inspect the changes Aider made or undo them if you’re not satisfied.To see the last change:
/diff
To undo the last change:
/undo
Aider will revert the changes:
Removed: 83b2890 refactor: use iteration in fibonacci
Now at:  8f1f75c feat: add fibonacci script
You can use /undo to undo and discard each aider commit.
Cerebras offers several models that work well with Aider. Choose based on your needs for speed versus capability:
  • llama-3.3-70b: Best for complex reasoning, long-form content, and tasks requiring deep understanding
  • qwen-3-32b: Balanced performance for general-purpose applications
  • llama3.1-8b: Fastest option for simple tasks and high-throughput scenarios
  • gpt-oss-120b: Largest model for the most demanding tasks
  • zai-glm-4.6: Advanced 357B parameter model with strong reasoning capabilities
For the best experience with Aider, we recommend using cerebras/llama-3.3-70b as it provides excellent code understanding and generation capabilities while maintaining fast inference speeds.

Advanced Usage

Using Different Edit Formats

Aider supports multiple edit formats. For Cerebras models, the default “whole” format works well, but you can experiment with others: To use whole file editing (recommended for Cerebras):
aider --model cerebras/llama-3.3-70b --edit-format whole
To use diff-based editing for smaller changes:
aider --model cerebras/llama-3.3-70b --edit-format diff

Architect Mode

For high-level design discussions before coding, use architect mode. This is useful for planning changes, discussing architecture, or exploring different approaches:
aider --architect --model cerebras/llama-3.3-70b
In architect mode, Aider won’t make direct code changes but will help you think through design decisions.

Streaming Responses

Enable streaming to see responses as they’re generated, providing immediate feedback:
aider --model cerebras/llama-3.3-70b --stream

Working with Multiple Models

You can use different models for different tasks. For example, use a larger model for complex edits and a smaller one for simple changes:
aider \
  --model cerebras/llama-3.3-70b \
  --editor-model cerebras/llama3.1-8b

Example Session

Here’s a complete example of using Aider with Cerebras to add a new feature to a Python project. First, start Aider from your terminal:
aider --model cerebras/llama-3.3-70b
Then, inside the Aider chat, run the following commands and prompts:
# Add relevant files
/add calculator.py
/add test_calculator.py

# Request a new feature
Add a new function to calculate the factorial of a number, with proper error handling for negative inputs

# Aider generates and applies the code
# Review the changes
/diff

# Request tests
Now add comprehensive unit tests for the factorial function, including edge cases

# Review the test file changes
/diff test_calculator.py

# If satisfied, changes are already committed
# View the commit
/git log -1

# Continue with more requests or exit
/exit

Troubleshooting

Ensure your API key is correctly set and accessible:
echo $CEREBRAS_API_KEY
If empty, set it again:
export CEREBRAS_API_KEY=your-key-here
Verify the API base URL is correct: https://api.cerebras.ai/v1If you’re still having issues, try running Aider with verbose logging:
aider --verbose --model llama-3.3-70b
Some models may struggle with code editing, or the edit format may not be optimal. Try:
  1. Using a more capable model like llama-3.3-70b
  2. Switching edit formats: --edit-format whole
  3. Being more specific in your requests with examples
  4. Breaking complex changes into smaller, incremental steps
  5. Adding more context files with /add
You can also check Aider’s LLM leaderboards to see how different models perform.
Aider requires a Git repository to function properly. Ensure:
  1. You’re in a Git repository: git status
  2. You have an initial commit: git log
  3. Your Git configuration is set up: git config user.name and git config user.email
If needed, initialize Git:
git init
git config user.name "Your Name"
git config user.email "[email protected]"
git add .
git commit -m "Initial commit"
Then restart Aider.
If you encounter rate limits or quota errors:
  1. Check your Cerebras dashboard for current usage
  2. Consider upgrading your plan for higher limits
  3. Use a smaller model like llama3.1-8b for simple tasks
  4. Add delays between requests if using Aider programmatically
  5. Break large changes into smaller sessions
Cerebras offers generous rate limits, but very intensive usage may require a paid plan.
If Aider feels slow:
  1. Ensure you’re using a Cerebras model (they’re optimized for speed)
  2. Reduce the number of files in context with /drop filename
  3. Use streaming mode: --stream
  4. Check your internet connection
  5. Try a smaller model like llama3.1-8b for faster responses
Cerebras models are typically very fast, so slowness often indicates network issues or too much context.

FAQ

For the best experience, use llama-3.3-70b. It provides excellent code understanding and generation capabilities while maintaining fast inference speeds.For faster responses on simpler tasks, try llama3.1-8b. For the most complex architectural decisions, consider gpt-oss-120b.Check Aider’s LLM leaderboards to see how different models perform on code editing tasks.
Yes! Use the /add command to include multiple files in the conversation:
/add src/main.py
/add src/utils.py
/add tests/test_main.py
Aider will maintain context across all added files. You can also add entire directories:
/add src/
Use /drop filename to remove files from context if needed.
Absolutely! Aider works with any programming language including JavaScript, TypeScript, Java, C++, Go, Rust, and more. It uses Git for version control and can edit any text-based files.The model’s ability to work with different languages depends on its training, but Cerebras models like llama-3.3-70b have strong multi-language capabilities.
Since Aider commits changes to Git, you can use standard Git commands:To view commit history:
git log
To undo the last commit but keep the changes in your files:
git reset --soft HEAD~1
To undo the last commit and discard the changes:
git reset --hard HEAD~1
To revert a specific commit:
git revert <commit-hash>
You can also use /undo within an Aider session to undo the last change before it’s committed.
Yes! Aider can be used programmatically in CI/CD pipelines for automated code improvements, refactoring, or documentation generation.Use the programmatic API with the yes=True flag to auto-approve changes:
# pip install aider-chat openai
import os
from aider.coders import Coder
from aider.models import Model
from aider.io import InputOutput

# Set environment variables for Cerebras
os.environ["OPENAI_API_KEY"] = os.getenv("CEREBRAS_API_KEY", "")
os.environ["OPENAI_API_BASE"] = "https://api.cerebras.ai/v1"

# Create model instance
model = Model("llama-3.3-70b")

# Create IO instance with auto-approve
io = InputOutput(yes=True)

# Create coder and run
coder = Coder.create(main_model=model, io=io, fnames=["src/main.py"])
coder.run("Add type hints to all functions")
Always test on a separate branch and review changes before merging.
Cerebras offers a free tier with generous limits. Costs depend on:
  • The model you choose (larger models cost more per token)
  • The number of tokens processed (input + output)
  • Your usage volume
Check the Cerebras pricing page for current rates. Cerebras is typically very cost-effective due to fast inference speeds and competitive pricing.

Next Steps