# OpenAI compatible APIs

> Aider can connect to any LLM which is accessible via an OpenAI compatible API endpoint.

- 网址：https://funcoding.ai/agents/aider/llms/openai-compat/
- 来源：Aider 官方文档原文（英文），Apache-2.0 许可，同步于 2026-10-11
- 官方原文：https://aider.chat/docs/llms/openai-compat.html

---
Aider can connect to any LLM which is accessible via an OpenAI compatible API endpoint.

First, install aider:

```bash
python -m pip install aider-install
aider-install
```

Then configure your API key and endpoint:

```
# Mac/Linux:
export OPENAI_API_BASE=<endpoint>
export OPENAI_API_KEY=<key>

# Windows:
setx OPENAI_API_BASE <endpoint>
setx OPENAI_API_KEY <key>
# ... restart shell after setx commands
```

Start working with aider and your OpenAI compatible API on your codebase:

```bash
# Change directory into your codebase
cd /to/your/project

# Prefix the model name with openai/
aider --model openai/<model-name>
```

See the [model warnings](https://funcoding.ai/agents/aider/llms/warnings/)
section for information on warnings which will occur
when working with models that aider is not familiar with.
