Skip to content

Aider

Run Aider against Tokens with OPENAI_API_BASE and the openai/ model prefix, silence unknown-model warnings with a metadata file, and switch models per session.

Works withAiderTerminal
On this page

Aider is an open-source AI pair-programming CLI that edits files in your git repository and commits as it goes. It talks to Tokens through its OpenAI-compatible provider, sending chat completions to https://tokens.bd/v1.

The Tokens CLI doesn't configure Aider; it only takes two environment variables and one flag, so there's little to automate.

Install Aider#

bash
python -m pip install aider-install
aider-install

On macOS and Linux, curl -LsSf https://aider.chat/install.sh | sh does the same in one step.

Aider's development has slowed: the last release we saw was v0.86.0 from August 2025. It still works with OpenAI-compatible endpoints like Tokens.

Set OPENAI_API_BASE for Aider#

Create a key at /dashboard/keys (API keys covers spend caps). Keep it in TOKENS_API_KEY and hand it to Aider through the variables it reads:

export TOKENS_API_KEY="tok_live_your_key"
export OPENAI_API_BASE="https://tokens.bd/v1"
export OPENAI_API_KEY="$TOKENS_API_KEY"

The PowerShell lines last for the current window. To keep them, run setx for each (setx OPENAI_API_BASE https://tokens.bd/v1, and so on) and open a new terminal.

These variables are global

Other tools also read OPENAI_API_BASE and OPENAI_API_KEY. Setting them in your shell profile sends those tools to Tokens too. If that's not what you want, set them only in the terminal where you run Aider, or wrap Aider in a small script that exports them first.

Then start Aider in your project:

bash
cd /path/to/your/project
aider --model openai/deepseek/deepseek-v4.1-flash

The openai/ prefix tells Aider to use its OpenAI-compatible provider; Aider's docs say to always add it. Aider runs on LiteLLM, which strips that first openai/ and sends deepseek/deepseek-v4.1-flash to Tokens. That stripping is standard LiteLLM behavior rather than something Aider's page spells out, but it's why the full id still reaches us intact.

Generate the command#

Pick a model and this generator builds the exports and the aider command for you:

.aider.conf.yml
export OPENAI_API_BASE="https://tokens.bd/v1"
export OPENAI_API_KEY="tok_live_your_key"
aider --model openai/deepseek/deepseek-v4.1-flash

Run Aider terminal pair programmer against the Tokens gateway.

Add model metadata#

Aider doesn't know Tokens' model ids, so it prints a model warning at startup. The warning is harmless. To give Aider real limits and silence it, create .aider.model.metadata.json in your home folder, the repo root or the current directory (or pass --model-metadata-file <path>):

.aider.model.metadata.json
{
  "openai/deepseek/deepseek-v4.1-flash": {
    "max_input_tokens": 128000,
    "max_output_tokens": 8192,
    "input_cost_per_token": 0,
    "output_cost_per_token": 0,
    "litellm_provider": "openai",
    "mode": "chat"
  }
}

The token numbers are placeholders: copy the real context window and max output from the model's page in /models. Leave the costs at zero. Aider's cost display would only be an estimate anyway; your actual spend is in the dashboard and in node tokens.mjs usage.

Switch models#

Pass a different id after openai/:

bash
aider --model openai/<model id>

Copy the exact id from /models or GET /v1/models, and add a matching entry to the metadata file if you want the warning gone for that model too. Choosing a model covers which models suit editing work.

Verify it works#

Run the aider --model ... command above. Aider prints the model it's using on startup. Ask it something small ("What files are in this repo?") and check that it answers and that the request appears in Usage analytics on the dashboard.

To rule out Aider itself, test the endpoint directly:

bash
curl https://tokens.bd/v1/chat/completions \
  -H "Authorization: Bearer $TOKENS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "deepseek/deepseek-v4.1-flash", "messages": [{"role": "user", "content": "Reply with OK"}], "max_tokens": 10}'

Troubleshooting#

Requests never show up in your Tokens usage. The openai/ prefix is missing. Without it, Aider (through LiteLLM) may pick a different built-in provider from the first part of the id, and the request goes there instead of Tokens. The command needs openai/ plus the full Tokens id: openai/deepseek/deepseek-v4.1-flash.

404 model_not_found. The id after openai/ doesn't match a Tokens model. Copy it again from /models.

404 on every request. OPENAI_API_BASE must end in /v1. Without it the path doesn't exist on Tokens.

401 invalid_api_key or missing_api_key. OPENAI_API_KEY is empty or still holds an OpenAI key. Run echo $OPENAI_API_KEY (or $env:OPENAI_API_KEY in PowerShell); a Tokens key starts with tok_live_.

Context errors on large repos. Aider reports token limits but never enforces them. Keep the files you add to the chat small, or pick a model with a larger window.

"Model warnings" at startup. Expected for ids Aider doesn't know. Add the metadata file above.

For 402, 403 and 429 errors, see Troubleshooting.

Was this page helpful?

Still stuck? Open a support ticket

Need help configuring your agent?

Test your connection with the connection tester, or create an API key.