Aider Integration with CodeGateway: OpenAI-Compatible Endpoint Setup

(Unofficial)

This guide is independently community-maintained. It is not affiliated with, endorsed by, or sponsored by the vendor of the third-party tool it covers. All third-party trademarks are the property of their respective owners.

Set AIDER_OPENAI_API_BASE plus a key to use DeepSeek/Kimi/GLM models via CodeGateway, pay as you go.

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

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

2. Point Aider at CodeGateway

Env vars (put them in your shell profile):

bash
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):

bash
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):

bash
aider --set-env ANTHROPIC_BASE_URL="https://api.codegateway.dev" \
--model anthropic/claude-sonnet-4-6

On the Messages protocol, Claude and Gemini series models work (e.g. claude-sonnet-4-6, gemini-3.8-flash).

4. Verify

bash
aider --message "Reply with only: hello" --model openai/deepseek-v4-pro

A reply means it works. --message runs a single-shot session, ideal for scripted checks.

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.

References

Turn this doc into a real API call

Lacking an official key or facing overseas card payment issues? Create an sk-cg- key after signing up, point your base URL at CodeGateway, and keep your existing SDK or CLI unchanged. Pay per token; binding a card adds free credit.

Sign up free
Author:CodeGateway Team