Back to blog

Tools & integrationsGuide

How to connect Aider to CheapTokens

Point Aider at the CheapTokens OpenAI-compatible API with two environment variables and the openai/ model prefix, then check that it answers.

By CheapTokens TeamPublished 2 min read

Aider in a terminal connected to the CheapTokens API
On this page
  1. Before you start
  2. Step 1. Set the API address and key
  3. Step 2. Start Aider with a model
  4. Step 3. Check that it works
  5. Common errors

Aider is an AI pair programmer that works in your terminal and commits its edits to git. It talks to any OpenAI-compatible API, so connecting it to CheapTokens takes two environment variables and a model name. The steps follow Aider's documentation for OpenAI-compatible APIs as of October 2026; they have not been run on a live Aider installation yet.

Before you start#

  • Aider is installed (aider --version prints a version).
  • You have a CheapTokens API key and a positive balance. If not, start with Your first API request.

Step 1. Set the API address and key#

bash
export OPENAI_API_BASE="https://api.cheaptokens.dev/v1"
export OPENAI_API_KEY="your-cheaptokens-key"

The address must end with /v1. Put both lines in your shell profile or in a .env file in the project if you don't want to repeat them.

Step 2. Start Aider with a model#

bash
aider --model openai/deepseek-ai/DeepSeek-V4-Flash-0731

The openai/ prefix tells Aider to use the OpenAI-compatible protocol; it is removed before the request, and the API receives the full model ID. Other models:

  • openai/zai-org/GLM-5.3-Flash — reasons before answering, good for harder changes.
  • openai/MiniMaxAI/MiniMax-M2.7 — for long agent sessions; 200K context.

How they differ and what they cost: GLM vs DeepSeek vs MiniMax.

Aider may warn that it does not know the model's context window and prices. It then uses safe defaults, and the requests still work; the limits of each model are listed in Connecting Cline.

Step 3. Check that it works#

Ask something small in the chat, for example /ask what does this repository do?. An answer means the setup is done. Architect mode, the repo map and git commits run on your machine, so they work the same way.

Common errors#

  • 401 — the key has a typo or was rotated; export it again.
  • 404 — OPENAI_API_BASE does not end with /v1.
  • 400 Model "…" not found — the model ID after openai/ has a typo.
  • 402 — the balance is used up.

All codes: Connection errors and fixes. Aider resends the conversation on every turn, so most of the bill is input tokens — see What an AI agent costs.

Recommending CheapTokens to other developers? The referral program credits you a percentage of their top-ups.