> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/yetone/avante.nvim/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get started with Avante.nvim in under 5 minutes

This guide will take you from a fresh installation to your first AI-powered code interaction in less than 5 minutes.

## Before You Begin

Make sure you've completed the [Installation](/installation) steps and have Avante.nvim installed in your Neovim setup.

## Step 1: Set Up Your API Key

<Steps>
  <Step title="Choose Your AI Provider">
    Avante.nvim supports multiple AI providers. For this quickstart, we'll use Claude, but you can choose any supported provider:

    * **Claude** (Anthropic)
    * **OpenAI** (GPT-4, etc.)
    * **Azure OpenAI**
    * **Gemini** (Google)
    * **Copilot**
    * **Ollama** (local models)
    * And many more!
  </Step>

  <Step title="Get Your API Key">
    For **Claude**, get your API key from [Anthropic's website](https://console.anthropic.com/).

    For other providers, visit their respective platforms to obtain API keys.
  </Step>

  <Step title="Set the Environment Variable">
    Avante.nvim supports scoped API keys (recommended for isolation) by prefixing with `AVANTE_`:

    ```bash theme={null}
    # Recommended: Scoped keys (only for Avante)
    export AVANTE_ANTHROPIC_API_KEY=your-claude-api-key
    export AVANTE_OPENAI_API_KEY=your-openai-api-key
    export AVANTE_GEMINI_API_KEY=your-gemini-api-key
    ```

    Or use global API keys:

    ```bash theme={null}
    # Legacy: Global keys
    export ANTHROPIC_API_KEY=your-claude-api-key
    export OPENAI_API_KEY=your-openai-api-key
    ```

    <Note>
      For most consistency between Neovim sessions, it's recommended to set the environment variables in your shell configuration file (`.bashrc`, `.zshrc`, etc.).
    </Note>

    <Tip>
      If you don't set the API key in advance, Avante will prompt you at startup to input the API key for the provider you have selected.
    </Tip>
  </Step>
</Steps>

## Step 2: Configure Your Provider

In your Neovim configuration, set your preferred provider:

```lua theme={null}
require('avante').setup({
  provider = "claude", -- or "openai", "gemini", etc.
  providers = {
    claude = {
      endpoint = "https://api.anthropic.com",
      model = "claude-sonnet-4-20250514",
      timeout = 30000,
      extra_request_body = {
        temperature = 0.75,
        max_tokens = 20480,
      },
    },
  },
})
```

## Step 3: Open Neovim and Start Coding

<Steps>
  <Step title="Open a Code File">
    Open any code file in Neovim:

    ```bash theme={null}
    nvim your_file.py
    ```
  </Step>

  <Step title="Trigger Avante">
    There are several ways to interact with Avante:

    **Option 1: Use the Command**

    ```vim theme={null}
    :AvanteAsk
    ```

    **Option 2: Use the Default Keybinding**

    Press `<Leader>aa` to show the Avante sidebar.

    <Note>
      The default `<Leader>` key in Neovim is `\`, but many users remap it to `,` or `<Space>`.
    </Note>
  </Step>

  <Step title="Ask the AI a Question">
    Once the sidebar opens, you can ask questions about your code:

    * "Explain this function"
    * "Refactor this code to be more efficient"
    * "Add error handling to this function"
    * "Write unit tests for this code"

    Type your question in the input area and press `<CR>` (Enter) in normal mode or `<C-s>` in insert mode to submit.
  </Step>

  <Step title="Review and Apply Changes">
    The AI will respond with suggestions in the sidebar. You can:

    * **Apply all changes**: Press `A` in the sidebar
    * **Apply at cursor**: Press `a` in the sidebar
    * **Retry the request**: Press `r`
    * **Edit your request**: Press `e`
  </Step>
</Steps>

## Step 4: Explore Key Features

### Add Files to Context

You can add specific files to the AI's context:

* Press `@` in the sidebar to add a file
* Press `d` to remove a file
* Use `<Leader>ac` to add the current buffer
* Use `<Leader>aB` to add all open buffers

### Use Mentions and Commands

Type `@` in the input to access mentions:

* `@codebase` - Enable project context
* `@diagnostics` - Include diagnostics information
* `@file` - Open file selector
* `@buffers` - Add open buffers

Type `/` for slash commands:

* `/help` - Show help message
* `/clear` - Clear chat history
* `/new` - Start a new chat
* `/commit` - Generate commit message

### Visual Mode Selection

You can select code in visual mode and ask questions about it:

1. Enter visual mode (`v` or `V`)
2. Select the code you want to ask about
3. Press `<Leader>aa` to open Avante with the selected code

## Common Workflows

### Example 1: Refactoring Code

```python theme={null}
def calculate(a, b, op):
    if op == '+':
        return a + b
    elif op == '-':
        return a - b
    elif op == '*':
        return a * b
    elif op == '/':
        return a / b
```

1. Open the file in Neovim
2. Press `<Leader>aa`
3. Ask: "Refactor this function to use a dictionary for operations and add error handling"
4. Review the AI's suggestion
5. Press `A` to apply all changes

### Example 2: Writing Tests

1. Select a function in visual mode
2. Press `<Leader>aa`
3. Ask: "Write unit tests for this function covering edge cases"
4. Review the generated tests
5. Apply the changes

### Example 3: Understanding Code

1. Navigate to an unfamiliar function
2. Press `<Leader>aa`
3. Ask: "Explain what this function does and its time complexity"
4. Read the AI's explanation in the sidebar

## Tips for Success

<Tip>
  Be specific in your requests. Instead of "fix this", try "add error handling for network failures and validate input parameters".
</Tip>

<Tip>
  Use the `avante.md` file in your project root to provide project-specific context and coding standards to the AI.
</Tip>

<Warning>
  Always review AI-generated code before applying it. The AI is a powerful assistant, but you should verify that changes meet your requirements and coding standards.
</Warning>

## Keyboard Shortcuts Reference

Here are the most common keyboard shortcuts:

| Key Binding      | Description              |
| ---------------- | ------------------------ |
| `<Leader>aa`     | Show/toggle sidebar      |
| `<Leader>ar`     | Refresh sidebar          |
| `<Leader>af`     | Switch sidebar focus     |
| `A` (in sidebar) | Apply all changes        |
| `a` (in sidebar) | Apply change at cursor   |
| `r` (in sidebar) | Retry request            |
| `e` (in sidebar) | Edit request             |
| `q` (in sidebar) | Close sidebar            |
| `@` (in sidebar) | Add file to context      |
| `d` (in sidebar) | Remove file from context |

## Next Steps

Congratulations! You've completed your first AI-assisted coding session with Avante.nvim. Here's what to explore next:

* **Configuration**: Dive deeper into [configuration options](/configuration/overview) to customize Avante to your workflow
* **Commands**: Learn about all available [commands and keybindings](/api/commands)
* **Providers**: Explore different [AI providers](/providers/overview) and their capabilities
* **Advanced Features**: Discover [advanced features](/features/ai-assistance) like project instructions, RAG service, and more

## Troubleshooting

If you encounter issues:

1. Run `:checkhealth avante` to diagnose problems
2. Check that your API key is set correctly
3. Verify your Neovim version is 0.10.1 or later
4. Review the [GitHub issues](https://github.com/yetone/avante.nvim/issues) for known problems

For more help, join the [Discord community](https://discord.gg/QfnEFEdSjz) or check the [documentation](https://github.com/yetone/avante.nvim).
