From cdd15462439bbb6ec49dd4b69e34a7424747635c Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Sat, 10 May 2025 17:12:55 -0700 Subject: [PATCH] docs: Improve GitHub Copilot connection docs tone and structure --- aider/website/docs/llms/github.md | 97 +++++++++++++++++++------------ 1 file changed, 60 insertions(+), 37 deletions(-) diff --git a/aider/website/docs/llms/github.md b/aider/website/docs/llms/github.md index 07149c04f..3d4381a44 100644 --- a/aider/website/docs/llms/github.md +++ b/aider/website/docs/llms/github.md @@ -3,44 +3,56 @@ parent: Connecting to LLMs 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 -API at `https://api.githubcopilot.com`. +Aider can connect to GitHub Copilot’s LLMs because Copilot exposes a standard **OpenAI-style** +endpoint at: -The only trick is getting an OAuth access token that has permission to call the Copilot -endpoint. -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: +``` +https://api.githubcopilot.com +``` + +First, install aider: + +{% include install.md %} + +--- + +## Configure your environment + +```bash +# macOS/Linux +export OPENAI_API_BASE=https://api.githubcopilot.com +export OPENAI_API_KEY= + +# Windows (PowerShell) +setx OPENAI_API_BASE https://api.githubcopilot.com +setx OPENAI_API_KEY +# …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 ``` -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 - -```bash -# macOS/Linux -export OPENAI_API_BASE=https://api.githubcopilot.com -export OPENAI_API_KEY= - -# Windows (PowerShell) -setx OPENAI_API_BASE https://api.githubcopilot.com -setx OPENAI_API_KEY -# …restart the shell so the variables are picked up -``` - ---- - -## Pick a model +## Discover available models 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 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' ``` -The returned IDs are used exactly like OpenAI models, but **prefixed with `openai/`** when you -pass them to aider: +Each returned ID can be used with aider by **prefixing it with `openai/`**: ```bash aider --model openai/gpt-4o @@ -58,7 +69,21 @@ aider --model openai/gpt-4o 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 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 - Copilot subscription, even though aider will still print estimated costs. -* Tokens created by **Neovim copilot.lua** or older `hosts.json` files sometimes lack the - required scopes. If you get `access to this endpoint is forbidden`, regenerate the token via a - JetBrains IDE or VS Code Copilot extension. -* 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**. +* Calls made through aider are billed through your Copilot subscription + (aider will still print *estimated* costs). +* The Copilot docs explicitly allow third-party “agents” that hit this API – aider is playing by + the rules. +* Aider talks directly to the REST endpoint—no web-UI scraping or browser automation.