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
- Sign up at the Calgine Tokens Console.
- Go to Workspace → API Tokens, click "Add Token", and copy the API Key after creation (starts with
sk-).
| Setting | Value |
|---|---|
OPENAI_API_BASE | https://api.calgine.com.cn/v1 |
OPENAI_API_KEY | The API token you created in the console |
Installation
pip install aider-chatOr use pipx (recommended, avoids dependency conflicts):
pipx install aider-chatConfiguration & Launch
Option 1: Environment Variables (Recommended, Permanent)
echo 'export OPENAI_API_KEY="sk-your-token"' >> ~/.zshrc
echo 'export OPENAI_API_BASE="https://api.calgine.com.cn/v1"' >> ~/.zshrc
source ~/.zshrcecho 'export OPENAI_API_KEY="sk-your-token"' >> ~/.bashrc
echo 'export OPENAI_API_BASE="https://api.calgine.com.cn/v1"' >> ~/.bashrc
source ~/.bashrc[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:
cd your-project
aider --model gpt-4oOption 2: Command-Line Arguments (One-Off)
aider \
--openai-api-key sk-your-token \
--openai-api-base https://api.calgine.com.cn/v1 \
--model gpt-4oUsing Anthropic Models
# 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-20251101Using a .aider.conf.yml Config File
Create .aider.conf.yml in your project root to avoid passing arguments every time:
openai-api-key: sk-your-token
openai-api-base: https://api.calgine.com.cn/v1
model: gpt-4oVerify 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
| Command | Description |
|---|---|
/add <file> | Add a file to the current editing context |
/drop <file> | Remove a file from the context |
/diff | Show all code changes made in this session |
/undo | Undo the most recent AI-made Git commit |
/commit | Commit the current changes |
/model <name> | Switch the model |
/exit | Exit Aider |
Recommended Models
| Scenario | Recommended Model |
|---|---|
| General coding | gpt-4o |
| Complex refactoring | claude-opus-4-5-20251101 |
| Rapid iteration | gpt-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