TL;DR: Aider supports OpenAI-compatible endpoints — set a base URL plus a key and you can use DeepSeek / Kimi / GLM / Qwen models via CodeGateway, pay as you go.
Prerequisites
Register at codegateway.dev — trial credit included after you bind a card (current amount shown on the signup/pricing page) — and create an API key (sk-cg- prefix).
Aider runs on Python; this guide uses the officially documented OpenAI-compatible path.
1. Install Aider
python -m pip install aider-install && aider-install2. Point Aider at CodeGateway
Env vars (put them in your shell profile):
export AIDER_OPENAI_API_BASE="https://api.codegateway.dev/v1"
export OPENAI_API_KEY="sk-cg-your-key"Start with --model (note the openai/ prefix):
aider --model openai/deepseek-v4-pro--openai-api-base is equivalent to the AIDER_OPENAI_API_BASE env var.
3. Optional: Anthropic-compatible path
For Claude models, all Aider requests go through litellm — pass the Anthropic endpoint via --set-env (the variable name comes from the litellm docs, not Aider's own docs):
aider --set-env ANTHROPIC_BASE_URL="https://api.codegateway.dev" \
--model anthropic/claude-sonnet-4-6On the Messages protocol, Claude and Gemini series models work (e.g. claude-sonnet-4-6, gemini-3.8-flash).
4. Verify
aider --message "Reply with only: hello" --model openai/deepseek-v4-proA reply means it works. --message runs a single-shot session, ideal for scripted checks.
Recommended models
OpenAI-compatible path (verified):
deepseek-v4-pro: first choice.kimi-k2.7-code: long coding tasks.glm-5.3: balanced.
Anthropic path: claude-sonnet-4-6, gemini-3.8-flash.
Note: GPT-series models are region-restricted upstream. Claude / Gemini are not available on the OpenAI-compatible path (and vice versa).
FAQ
Q: `AIDER_OPENAI_API_BASE` vs `OPENAI_API_BASE`? AIDER_OPENAI_API_BASE is Aider's own env var (equivalent to --openai-api-base); the underlying OPENAI_API_BASE also works. Set one; Aider's var takes precedence.
Q: Where does the Anthropic variable come from? Aider's docs don't list it — requests go through litellm, and ANTHROPIC_BASE_URL / ANTHROPIC_API_BASE are litellm-documented variable names. Use --set-env to pass them through.
Q: SSL errors behind a corporate proxy? --verify-ssl (or --no-verify-ssl) toggles certificate checks — only if you trust the path.
Q: Which model prefixes are supported? openai/ for the OpenAI-compatible path; anthropic/ for Anthropic. Model ids must match the model list.