mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 12:24:59 +00:00
docs: Improve GitHub Copilot connection docs tone and structure
This commit is contained in:
parent
6a3bb0f4ec
commit
cdd1546243
1 changed files with 60 additions and 37 deletions
|
@ -3,44 +3,56 @@ parent: Connecting to LLMs
|
||||||
nav_order: 510
|
nav_order: 510
|
||||||
---
|
---
|
||||||
|
|
||||||
# GitHub Copilot models
|
# GitHub Copilot compatible API
|
||||||
|
|
||||||
Aider can talk to the GitHub Copilot LLMs because Copilot exposes an **OpenAI-compatible** REST
|
Aider can connect to GitHub Copilot’s LLMs because Copilot exposes a standard **OpenAI-style**
|
||||||
API at `https://api.githubcopilot.com`.
|
endpoint at:
|
||||||
|
|
||||||
The only trick is getting an OAuth access token that has permission to call the Copilot
|
```
|
||||||
endpoint.
|
https://api.githubcopilot.com
|
||||||
The easiest, **official** way is to sign in to Copilot from any JetBrains IDE
|
```
|
||||||
(Goland, PyCharm, etc).
|
|
||||||
After you sign in, a file appears at:
|
First, install aider:
|
||||||
|
|
||||||
|
{% include install.md %}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Configure your environment
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# macOS/Linux
|
||||||
|
export OPENAI_API_BASE=https://api.githubcopilot.com
|
||||||
|
export OPENAI_API_KEY=<oauth_token>
|
||||||
|
|
||||||
|
# Windows (PowerShell)
|
||||||
|
setx OPENAI_API_BASE https://api.githubcopilot.com
|
||||||
|
setx OPENAI_API_KEY <oauth_token>
|
||||||
|
# …restart the shell after setx commands
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Where do I get the token?
|
||||||
|
The easiest path is to sign in to Copilot from any JetBrains IDE (PyCharm, GoLand, etc).
|
||||||
|
After you authenticate a file appears:
|
||||||
|
|
||||||
```
|
```
|
||||||
~/.config/github-copilot/apps.json
|
~/.config/github-copilot/apps.json
|
||||||
```
|
```
|
||||||
|
|
||||||
Inside you will find an `oauth_token` value – copy that string, **it is your API key**.
|
Copy the `oauth_token` value – that string is your `OPENAI_API_KEY`.
|
||||||
|
|
||||||
|
*Note:* tokens created by the Neovim **copilot.lua** plugin (old `hosts.json`) sometimes lack the
|
||||||
|
needed scopes. If you see “access to this endpoint is forbidden”, regenerate the token with a
|
||||||
|
JetBrains IDE or the VS Code Copilot extension.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Configure the environment
|
## Discover available models
|
||||||
|
|
||||||
```bash
|
|
||||||
# macOS/Linux
|
|
||||||
export OPENAI_API_BASE=https://api.githubcopilot.com
|
|
||||||
export OPENAI_API_KEY=<oauth_token from apps.json>
|
|
||||||
|
|
||||||
# Windows (PowerShell)
|
|
||||||
setx OPENAI_API_BASE https://api.githubcopilot.com
|
|
||||||
setx OPENAI_API_KEY <oauth_token>
|
|
||||||
# …restart the shell so the variables are picked up
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Pick a model
|
|
||||||
|
|
||||||
Copilot hosts many models (OpenAI, Anthropic, Google, etc).
|
Copilot hosts many models (OpenAI, Anthropic, Google, etc).
|
||||||
You can discover the list that your subscription allows with:
|
List the models your subscription allows with:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -s https://api.githubcopilot.com/models \
|
curl -s https://api.githubcopilot.com/models \
|
||||||
|
@ -49,8 +61,7 @@ curl -s https://api.githubcopilot.com/models \
|
||||||
-H "Copilot-Integration-Id: vscode-chat" | jq -r '.data[].id'
|
-H "Copilot-Integration-Id: vscode-chat" | jq -r '.data[].id'
|
||||||
```
|
```
|
||||||
|
|
||||||
The returned IDs are used exactly like OpenAI models, but **prefixed with `openai/`** when you
|
Each returned ID can be used with aider by **prefixing it with `openai/`**:
|
||||||
pass them to aider:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
aider --model openai/gpt-4o
|
aider --model openai/gpt-4o
|
||||||
|
@ -58,7 +69,21 @@ aider --model openai/gpt-4o
|
||||||
aider --model openai/claude-3.7-sonnet-thought
|
aider --model openai/claude-3.7-sonnet-thought
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also store this in `~/.aider.conf.yml`:
|
---
|
||||||
|
|
||||||
|
## Quick start
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# change into your project
|
||||||
|
cd /to/your/project
|
||||||
|
|
||||||
|
# talk to Copilot
|
||||||
|
aider --model openai/gpt-4o
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Optional config file (`~/.aider.conf.yml`)
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
openai-api-base: https://api.githubcopilot.com
|
openai-api-base: https://api.githubcopilot.com
|
||||||
|
@ -70,13 +95,11 @@ show-model-warnings: false
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Notes & FAQ
|
## FAQ
|
||||||
|
|
||||||
* Copilot billing is handled entirely by GitHub. Calls made through aider count against your
|
* Calls made through aider are billed through your Copilot subscription
|
||||||
Copilot subscription, even though aider will still print estimated costs.
|
(aider will still print *estimated* costs).
|
||||||
* Tokens created by **Neovim copilot.lua** or older `hosts.json` files sometimes lack the
|
* The Copilot docs explicitly allow third-party “agents” that hit this API – aider is playing by
|
||||||
required scopes. If you get `access to this endpoint is forbidden`, regenerate the token via a
|
the rules.
|
||||||
JetBrains IDE or VS Code Copilot extension.
|
* Aider talks directly to the REST endpoint—no web-UI scraping or browser automation.
|
||||||
* The Copilot terms of service allow third-party “agents” that access the LLM endpoint. Aider
|
|
||||||
merely follows the documented API and **does not scrape the web UI**.
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue