> ## Documentation Index
> Fetch the complete documentation index at: https://inference-docs.cerebras.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Started with Aider

> Learn how to use Aider, an AI pair programming tool, with Cerebras Inference for ultra-fast code editing and generation in your terminal.

[Aider](https://aider.chat/?utm_source=3pi_aider\&utm_campaign=partner_doc) 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](https://cloud.cerebras.ai/?utm_source=3pi_aider\&utm_campaign=partner_doc)
* **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

<Steps>
  <Step title="Install Aider">
    Install Aider using pip. This will download and install the latest version of Aider and its dependencies.

    ```bash theme={null}
    pip install aider-chat
    ```

    Alternatively, you can use pipx for an isolated installation:

    ```bash theme={null}
    pipx install aider-chat
    ```

    <Note>
      Using `pipx` is recommended for isolated environments, as it installs Aider in its own virtual environment.
    </Note>
  </Step>

  <Step title="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.

    <CodeGroup>
      ```bash macOS/Linux theme={null}
      export CEREBRAS_API_KEY=your-cerebras-api-key-here
      ```

      ```bash Windows (PowerShell) theme={null}
      $env:CEREBRAS_API_KEY="your-cerebras-api-key-here"
      ```

      ```bash Windows (CMD) theme={null}
      set CEREBRAS_API_KEY=your-cerebras-api-key-here
      ```
    </CodeGroup>

    For a permanent setup, add this line to your shell configuration file (`~/.bashrc`, `~/.zshrc`, etc.).
  </Step>

  <Step title="Initialize your project directory">
    Aider works with Git repositories to track changes. Navigate to your project and ensure it's a Git repository.

    ```bash theme={null}
    cd /path/to/your/project
    ```

    If your project is not already a Git repository, initialize one:

    ```bash theme={null}
    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.
  </Step>

  <Step title="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:

    ```bash theme={null}
    cat > .aider.conf.yml <<EOF
    model: cerebras/gpt-oss-120b
    openai-api-key: env:CEREBRAS_API_KEY
    EOF
    ```

    With this configuration, you can simply run `aider` without additional flags.
  </Step>
</Steps>

## Using Aider with Cerebras

<Steps>
  <Step title="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:

    <CodeGroup>
      ```bash With config file theme={null}
      aider
      ```

      ```bash Without config file theme={null}
      aider \
        --model cerebras/gpt-oss-120b \
        --openai-api-key $CEREBRAS_API_KEY
      ```
    </CodeGroup>

    This command tells Aider to use the `gpt-oss-120b` model from Cerebras and connect to Cerebras's API endpoint.

    <Note>
      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.
    </Note>
  </Step>

  <Step title="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:

    ```text theme={null}
    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.
  </Step>

  <Step title="Refine the code">
    Now, let's ask Aider to improve the implementation. The model will analyze the existing code and apply your requested changes.

    ```text theme={null}
    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
  </Step>

  <Step title="Run the code">
    You can run shell commands directly within Aider to verify the changes.

    ```text theme={null}
    /run python fibonacci.py
    ```

    Aider will run the command and show the output:

    ```text theme={null}
    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.
  </Step>

  <Step title="Review and undo">
    You can inspect the changes Aider made or undo them if you're not satisfied.

    To see the last change:

    ```text theme={null}
    /diff
    ```

    To undo the last change:

    ```text theme={null}
    /undo
    ```

    Aider will revert the changes:

    ```text theme={null}
    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.
    ```
  </Step>
</Steps>

## Recommended Models

Cerebras offers several models that work well with Aider. Choose based on your needs for speed versus capability:

* **gpt-oss-120b**: Largest model for the most demanding tasks
* **zai-glm-4.7**: Advanced 357B parameter model with strong reasoning capabilities

<Note>
  For the best experience with Aider, we recommend using `cerebras/gpt-oss-120b` as it provides excellent code understanding and generation capabilities while maintaining fast inference speeds.
</Note>

## 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):

```bash theme={null}
aider --model cerebras/gpt-oss-120b --edit-format whole
```

To use diff-based editing for smaller changes:

```bash theme={null}
aider --model cerebras/gpt-oss-120b --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:

```bash theme={null}
aider --architect --model cerebras/gpt-oss-120b
```

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:

```bash theme={null}
aider --model cerebras/gpt-oss-120b --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:

```bash theme={null}
aider \
  --model cerebras/gpt-oss-120b \
  --editor-model cerebras/gpt-oss-120b
```

## 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:

```bash theme={null}
aider --model cerebras/gpt-oss-120b
```

Then, inside the Aider chat, run the following commands and prompts:

```text theme={null}
# 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

<AccordionGroup>
  <Accordion title="Aider can't connect to Cerebras API">
    Ensure your API key is correctly set and accessible:

    ```bash theme={null}
    echo $CEREBRAS_API_KEY
    ```

    If empty, set it again:

    ```bash theme={null}
    export CEREBRAS_API_KEY=your-key-here
    ```

    Verify the API base URL is correct: `https://api.cerebras.ai/v1`

    If you're still having issues, try running Aider with verbose logging:

    ```bash theme={null}
    aider --verbose --model gpt-oss-120b
    ```
  </Accordion>

  <Accordion title="Model isn't editing files properly">
    Some models may struggle with code editing, or the edit format may not be optimal. Try:

    1. Using a more capable model like `gpt-oss-120b`
    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](https://aider.chat/docs/leaderboards/?utm_source=3pi_aider\&utm_campaign=partner_doc) to see how different models perform.
  </Accordion>

  <Accordion title="Changes aren't being committed to Git">
    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:

    ```bash theme={null}
    git init
    git config user.name "Your Name"
    git config user.email "your.email@example.com"
    git add .
    git commit -m "Initial commit"
    ```

    Then restart Aider.
  </Accordion>

  <Accordion title="Rate limiting or quota errors">
    If you encounter rate limits or quota errors:

    1. Check your [Cerebras dashboard](https://cloud.cerebras.ai/?utm_source=3pi_aider\&utm_campaign=partner_doc) for current usage
    2. Consider upgrading your plan for higher limits
    3. Use a smaller model like `gpt-oss-120b` 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.
  </Accordion>

  <Accordion title="Aider is slow or unresponsive">
    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 `gpt-oss-120b` for faster responses

    Cerebras models are typically very fast, so slowness often indicates network issues or too much context.
  </Accordion>
</AccordionGroup>

## FAQ

<AccordionGroup>
  <Accordion title="Which Cerebras model should I use with Aider?">
    For the best experience, use `gpt-oss-120b`. It provides excellent code understanding and generation capabilities while maintaining fast inference speeds.

    For faster responses on simpler tasks, try `gpt-oss-120b`. For the most complex architectural decisions, consider `gpt-oss-120b`.

    Check [Aider's LLM leaderboards](https://aider.chat/docs/leaderboards/?utm_source=3pi_aider\&utm_campaign=partner_doc) to see how different models perform on code editing tasks.
  </Accordion>

  <Accordion title="Can I use Aider with multiple files?">
    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.
  </Accordion>

  <Accordion title="Does Aider work with non-Python projects?">
    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 `gpt-oss-120b` have strong multi-language capabilities.
  </Accordion>

  <Accordion title="How do I undo changes made by Aider?">
    Since Aider commits changes to Git, you can use standard Git commands:

    To view commit history:

    ```bash theme={null}
    git log
    ```

    To undo the last commit but keep the changes in your files:

    ```bash theme={null}
    git reset --soft HEAD~1
    ```

    To undo the last commit and discard the changes:

    ```bash theme={null}
    git reset --hard HEAD~1
    ```

    To revert a specific commit:

    ```bash theme={null}
    git revert <commit-hash>
    ```

    You can also use `/undo` within an Aider session to undo the last change before it's committed.
  </Accordion>

  <Accordion title="Can I use Aider in CI/CD pipelines?">
    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:

    ```python theme={null}
    # 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("gpt-oss-120b")

    # 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.
  </Accordion>

  <Accordion title="How much does it cost to use Aider with Cerebras?">
    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](https://cloud.cerebras.ai/?utm_source=3pi_aider\&utm_campaign=partner_doc) for current rates. Cerebras is typically very cost-effective due to fast inference speeds and competitive pricing.
  </Accordion>
</AccordionGroup>

## Next Steps

* Explore [Aider's documentation](https://aider.chat/docs/?utm_source=3pi_aider\&utm_campaign=partner_doc) for advanced features like voice coding and custom commands
* Try different [Cerebras models](/models) to find the best fit for your workflow
* Check out [Aider's LLM leaderboards](https://aider.chat/docs/leaderboards/?utm_source=3pi_aider\&utm_campaign=partner_doc) to see performance comparisons
* Read the [Cerebras documentation](/api-reference/chat-completions) to learn more about API capabilities
* Want to try the latest model? Check out the [GLM4.7 migration guide](https://inference-docs.cerebras.ai/resources/glm-47-migration?utm_source=3pi_aider\&utm_campaign=partner_doc)
