Skip to content

Integrating Aider ​

AI pair programming in your terminal — automatically writes code, runs tests, and creates Git commits. It connects to Calgine Tokens via the OpenAI-compatible API.

Aider is a terminal-based AI pair programming tool that edits your local codebase directly and automatically generates Git commits.

Prerequisites ​

  1. Sign up at the Calgine Tokens Console.
  2. Go to Workspace → API Tokens, click "Add Token", and copy the API Key after creation (starts with sk-).
SettingValue
OPENAI_API_BASEhttps://api.calgine.com.cn/v1
OPENAI_API_KEYThe API token you created in the console

Installation ​

bash
pip install aider-chat

Or use pipx (recommended, avoids dependency conflicts):

bash
pipx install aider-chat

Configuration & Launch ​

bash
echo 'export OPENAI_API_KEY="sk-your-token"' >> ~/.zshrc
echo 'export OPENAI_API_BASE="https://api.calgine.com.cn/v1"' >> ~/.zshrc
source ~/.zshrc
bash
echo 'export OPENAI_API_KEY="sk-your-token"' >> ~/.bashrc
echo 'export OPENAI_API_BASE="https://api.calgine.com.cn/v1"' >> ~/.bashrc
source ~/.bashrc
powershell
[Environment]::SetEnvironmentVariable("OPENAI_API_KEY", "sk-your-token", "User")
[Environment]::SetEnvironmentVariable("OPENAI_API_BASE", "https://api.calgine.com.cn/v1", "User")

After setting the environment variables, enter your project directory and launch:

bash
cd your-project
aider --model gpt-4o

Option 2: Command-Line Arguments (One-Off) ​

bash
aider \
  --openai-api-key sk-your-token \
  --openai-api-base https://api.calgine.com.cn/v1 \
  --model gpt-4o

Using Anthropic Models ​

bash
# Set environment variables
export ANTHROPIC_API_KEY="sk-your-token"
export ANTHROPIC_BASE_URL="https://api.calgine.com.cn/anthropic"

# Launch
aider --model claude-opus-4-5-20251101

Using a .aider.conf.yml Config File ​

Create .aider.conf.yml in your project root to avoid passing arguments every time:

yaml
openai-api-key: sk-your-token
openai-api-base: https://api.calgine.com.cn/v1
model: gpt-4o

Verify the Setup ​

After launching Aider, type a simple instruction (e.g., "add a hello world function"). If Aider edits files and creates a commit normally, the setup is complete.

Common Commands ​

CommandDescription
/add <file>Add a file to the current editing context
/drop <file>Remove a file from the context
/diffShow all code changes made in this session
/undoUndo the most recent AI-made Git commit
/commitCommit the current changes
/model <name>Switch the model
/exitExit Aider
ScenarioRecommended Model
General codinggpt-4o
Complex refactoringclaude-opus-4-5-20251101
Rapid iterationgpt-4o-mini

Note

Aider commits all changes to Git automatically by default. Start from a clean Git state so you can roll back easily with /undo.

Next Steps ​

  • Claude Code: Another terminal-based AI coding tool
  • Rate Limits: Learn about the platform's call frequency limits