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

# Aider setup: installation, API key, Base URL, and custom models

> Install Aider, configure the BetterToken Base URL and API key, choose a compatible provider model, and troubleshoot common errors.

To connect Aider to BetterToken, prepare an API key, enter the Base URL shown below, and choose a current Model ID from the model plaza.

## Key settings

| Field    | Value                                                                                  |
| -------- | -------------------------------------------------------------------------------------- |
| API Key  | BetterToken API key                                                                    |
| Base URL | `https://www.bettertoken.ai/v1`                                                        |
| Model    | A current Model ID from the <a href={"https://bettertoken.ai/pricing"}>model plaza</a> |

## Prerequisites

* The current version of the tool is installed
* A BetterToken API key: <a href={"https://bettertoken.ai/register"}>register and get one</a>
* A Model ID from the <a href={"https://bettertoken.ai/pricing"}>model plaza</a>

### Additional requirements

* Install Python

## Install

### Install Aider

Run the following commands in a terminal:

```bash theme={null}
python -m pip install aider-install
aider-install
```

After installation, confirm that Aider is available:

```bash theme={null}
aider --help
```

## Manual setup

| Field    | Value                                                                                  |
| -------- | -------------------------------------------------------------------------------------- |
| API Key  | BetterToken API key                                                                    |
| Base URL | `https://www.bettertoken.ai/v1`                                                        |
| Model    | A current Model ID from the <a href={"https://bettertoken.ai/pricing"}>model plaza</a> |

### Configure BetterToken for the current terminal

<Tabs>
  <Tab title="macOS / Linux">
    ```bash theme={null}
    export OPENAI_API_BASE="https://www.bettertoken.ai/v1"
    export OPENAI_API_KEY="YOUR_API_KEY"

    cd /path/to/your/project
    aider --model openai/YOUR_MODEL_ID
    ```
  </Tab>

  <Tab title="Windows PowerShell">
    ```powershell theme={null}
    setx OPENAI_API_BASE "https://www.bettertoken.ai/v1"
    setx OPENAI_API_KEY "YOUR_API_KEY"
    ```

    After `setx`, close and reopen PowerShell. Then change into your project directory and run:

    ```powershell theme={null}
    aider --model openai/YOUR_MODEL_ID
    ```
  </Tab>
</Tabs>

Replace `YOUR_API_KEY` with your BetterToken API Key. `YOUR_MODEL_ID` is only an example. Replace it with a current **model ID from a supported provider** from the model plaza, and keep the `openai/` prefix.

### Save the configuration with .env

To avoid setting variables every time you open a terminal, create a `.env` file at the Git root of your project:

```dotenv theme={null}
OPENAI_API_BASE=https://www.bettertoken.ai/v1
OPENAI_API_KEY=YOUR_API_KEY
AIDER_MODEL=openai/YOUR_MODEL_ID
```

Add `.env` to `.gitignore` so the API Key is not committed. Then enter the project directory and run:

```bash theme={null}
aider
```

To use another file for one project, specify it explicitly:

```bash theme={null}
aider --env-file ./aider-bettertoken.env
```

### Optional: use .aider.conf.yml

To persist only non-sensitive settings, create `.aider.conf.yml` in your home or project directory:

```yaml theme={null}
model: openai/YOUR_MODEL_ID
openai-api-base: "https://www.bettertoken.ai/v1"
```

Keep the API Key in the `OPENAI_API_KEY` environment variable instead of a shared YAML file.

### Change the model

Replace the model in the launch command with a current **model ID from a supported provider**:

```bash theme={null}
aider --model openai/YOUR_MODEL_ID
```

Do not remove the `openai/` prefix. the Model ID must be compatible with the configured endpoint.

## Verify the connection

Send a short test prompt. If the tool returns a response without an authentication or Model ID error, the connection works. Fully restart the tool after changing its configuration.

## Switch models

Open the model selector or change the `Model` field in the configuration. Use the exact Model ID from the <a href={"https://bettertoken.ai/pricing"}>model plaza</a>, then restart the current session.

## Common errors

| Symptom                                     | What to do                                                                                                                                     |
| ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `401`, `Unauthorized`, or `Invalid API key` | Check `OPENAI_API_KEY`, confirm it is a BetterToken API Key, and remove any extra spaces.                                                      |
| `model not found` or model unavailable      | Copy a current **model ID from a supported provider** from the model plaza and pass it to Aider as `openai/model-id`.                          |
| Wrong request URL or `404`                  | Confirm `OPENAI_API_BASE` is `https://www.bettertoken.ai/v1`. Do not append `/chat/completions`.                                               |
| Windows does not read the new variables     | `setx` only affects newly opened terminals. Close the current PowerShell window and open a new one.                                            |
| Aider reports an unknown model              | Check the model ID and API provider first. Aider may show a warning for a new model, but you must still use a current ID from the model plaza. |

### Setup FAQ

**Which Base URL should Aider use?**

Use `https://www.bettertoken.ai/v1`. This is BetterToken's OpenAI-compatible Base URL.

**Why does the model name need the `openai/` prefix?**

Aider uses this prefix to identify an OpenAI-compatible model. Omitting it can make Aider select the wrong provider.

**Can I put the API Key in `.aider.conf.yml`?**

We do not recommend it. Use environment variables or a `.env` file ignored by Git to reduce the risk of exposing an API Key in project files.

## Advanced setup

### Supported providers

| Provider | Status        |
| -------- | ------------- |
| Claude   | Not supported |
| GPT      | Manual setup  |
| Kimi     | Manual setup  |
| GLM      | Manual setup  |

<Note>Statuses apply to the BetterToken setup documented on this page.</Note>

<Accordion title="What the setup methods mean">
  * **Manual setup**: enter the API Key, Base URL, and Model.
  * **Not supported**: no verified direct setup is currently available.
</Accordion>

### Related guides

* [Continue CLI custom model setup](/en/ai-tools/continue-cli)
* [Codex CLI custom provider setup](/en/ai-tools/codex)
* [Cursor custom API, Base URL, and API Key setup](/en/ai-tools/cursor)
* [Configure an OpenAI-compatible API in Cline](/en/ai-tools/cline)

## Technical details

<Accordion title="Protocol, endpoint, and internal provider fields">
  This setup uses `https://www.bettertoken.ai/v1`. The tool appends the OpenAI-compatible endpoint path. Do not add `/chat/completions` or `/responses` unless a specific field explicitly requires it.
</Accordion>
