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
| Field | Value |
|---|---|
| API Key | BetterToken API key |
| Base URL | https://bettertoken.ai/v1 |
| Model | A current Model ID from the model plaza |
Prerequisites
- The current version of the tool is installed
- A BetterToken API key: register and get one
- A Model ID from the model plaza
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:
python -m pip install aider-installaider-installAfter installation, confirm that Aider is available:
aider --helpManual setup
| Field | Value |
|---|---|
| API Key | BetterToken API key |
| Base URL | https://bettertoken.ai/v1 |
| Model | A current Model ID from the model plaza |
Configure BetterToken for the current terminal
macOS / Linux
export OPENAI_API_BASE="https://bettertoken.ai/v1"export OPENAI_API_KEY="YOUR_API_KEY"
cd /path/to/your/projectaider --model openai/YOUR_MODEL_IDWindows PowerShell
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:
aider --model openai/YOUR_MODEL_IDReplace 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/v1OPENAI_API_KEY=YOUR_API_KEYAIDER_MODEL=openai/YOUR_MODEL_IDAdd .env to .gitignore so the API Key is not committed. Then enter the project directory and run:
aiderTo use another file for one project, specify it explicitly:
aider --env-file ./aider-bettertoken.envOptional: use .aider.conf.yml
To persist only non-sensitive settings, create .aider.conf.yml in your home or project directory:
model: openai/YOUR_MODEL_IDopenai-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:
aider --model openai/YOUR_MODEL_IDDo 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
| 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 the model plaza and pass it to Aider as openai/model-id. |
Wrong request URL or 404 | Confirm OPENAI_API_BASE is https://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://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
Related guides
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.

