Skip to content
Sign Up Free
Coding Agent setup

Aider setup: API key, Base URL, and models

Install Aider, configure the BetterToken Base URL and API key, choose an available model, and troubleshoot common errors. Includes setup guidance.

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

FieldValue
API KeyBetterToken API key
Base URLhttps://bettertoken.ai/v1
ModelA current Model ID from the model plaza

Prerequisites

Sign up and get a BetterToken API Key

Already have an account? Sign in, top up, then create a key in the console.

Additional requirements

  • Install Python

Install

Install Aider

Run the following commands in a terminal:

Terminal window
python -m pip install aider-install
aider-install

After installation, confirm that Aider is available:

Terminal window
aider --help

Manual setup

FieldValue
API KeyBetterToken API key
Base URLhttps://bettertoken.ai/v1
ModelA current Model ID from the model plaza

Configure BetterToken for the current terminal

macOS / Linux

Terminal window
export OPENAI_API_BASE="https://bettertoken.ai/v1"
export OPENAI_API_KEY="YOUR_API_KEY"
cd /path/to/your/project
aider --model openai/YOUR_MODEL_ID

Windows PowerShell

Terminal window
setx OPENAI_API_BASE "https://bettertoken.ai/v1"
setx OPENAI_API_KEY "YOUR_API_KEY"

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

Terminal window
aider --model openai/YOUR_MODEL_ID

Replace YOUR_API_KEY with your BetterToken API Key. YOUR_MODEL_ID is only an example. Replace it with a current model ID 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:

OPENAI_API_BASE=https://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:

Terminal window
aider

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

Terminal window
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:

model: openai/YOUR_MODEL_ID
openai-api-base: "https://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:

Terminal window
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 model plaza, then restart the current session.

Common errors

SymptomWhat to do
401, Unauthorized, or Invalid API keyCheck OPENAI_API_KEY, confirm it is a BetterToken API Key, and remove any extra spaces.
model not found or model unavailableCopy a current model ID from the model plaza and pass it to Aider as openai/model-id.
Wrong request URL or 404Confirm OPENAI_API_BASE is https://bettertoken.ai/v1. Do not append /chat/completions.
Windows does not read the new variablessetx only affects newly opened terminals. Close the current PowerShell window and open a new one.
Aider reports an unknown modelCheck 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://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

Technical details

Protocol, endpoint, and internal provider fields

This setup uses https://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.