@@ -3,44 +3,56 @@ parent: Connecting to LLMs
3
3
nav_order : 510
4
4
---
5
5
6
- # GitHub Copilot models
6
+ # GitHub Copilot compatible API
7
7
8
- Aider can talk to the GitHub Copilot LLMs because Copilot exposes an ** OpenAI-compatible** REST
9
- API at ` https://api.githubcopilot.com ` .
10
-
11
- The only trick is getting an OAuth access token that has permission to call the Copilot
12
- endpoint.
13
- The easiest, ** official** way is to sign in to Copilot from any JetBrains IDE
14
- (Goland, PyCharm, etc).
15
- After you sign in, a file appears at:
8
+ Aider can connect to GitHub Copilot’s LLMs because Copilot exposes a standard ** OpenAI-style**
9
+ endpoint at:
16
10
17
11
```
18
- ~/.config/github-copilot/apps.json
12
+ https://api.githubcopilot.com
19
13
```
20
14
21
- Inside you will find an ` oauth_token ` value – copy that string, ** it is your API key** .
15
+ First, install aider:
16
+
17
+ {% include install.md %}
22
18
23
19
---
24
20
25
- ## Configure the environment
21
+ ## Configure your environment
26
22
27
23
``` bash
28
24
# macOS/Linux
29
25
export OPENAI_API_BASE=https://api.githubcopilot.com
30
- export OPENAI_API_KEY=< oauth_token from apps.json >
26
+ export OPENAI_API_KEY=< oauth_token>
31
27
32
28
# Windows (PowerShell)
33
29
setx OPENAI_API_BASE https://api.githubcopilot.com
34
30
setx OPENAI_API_KEY < oauth_token>
35
- # …restart the shell so the variables are picked up
31
+ # …restart the shell after setx commands
36
32
```
37
33
38
34
---
39
35
40
- ## Pick a model
36
+ ### Where do I get the token?
37
+ The easiest path is to sign in to Copilot from any JetBrains IDE (PyCharm, GoLand, etc).
38
+ After you authenticate a file appears:
39
+
40
+ ```
41
+ ~/.config/github-copilot/apps.json
42
+ ```
43
+
44
+ Copy the ` oauth_token ` value – that string is your ` OPENAI_API_KEY ` .
45
+
46
+ * Note:* tokens created by the Neovim ** copilot.lua** plugin (old ` hosts.json ` ) sometimes lack the
47
+ needed scopes. If you see “access to this endpoint is forbidden”, regenerate the token with a
48
+ JetBrains IDE or the VS Code Copilot extension.
49
+
50
+ ---
51
+
52
+ ## Discover available models
41
53
42
54
Copilot hosts many models (OpenAI, Anthropic, Google, etc).
43
- You can discover the list that your subscription allows with:
55
+ List the models your subscription allows with:
44
56
45
57
``` bash
46
58
curl -s https://api.githubcopilot.com/models \
@@ -49,16 +61,29 @@ curl -s https://api.githubcopilot.com/models \
49
61
-H " Copilot-Integration-Id: vscode-chat" | jq -r ' .data[].id'
50
62
```
51
63
52
- The returned IDs are used exactly like OpenAI models, but ** prefixed with ` openai/ ` ** when you
53
- pass them to aider:
64
+ Each returned ID can be used with aider by ** prefixing it with ` openai/ ` ** :
54
65
55
66
``` bash
56
67
aider --model openai/gpt-4o
57
68
# or
58
69
aider --model openai/claude-3.7-sonnet-thought
59
70
```
60
71
61
- You can also store this in ` ~/.aider.conf.yml ` :
72
+ ---
73
+
74
+ ## Quick start
75
+
76
+ ``` bash
77
+ # change into your project
78
+ cd /to/your/project
79
+
80
+ # talk to Copilot
81
+ aider --model openai/gpt-4o
82
+ ```
83
+
84
+ ---
85
+
86
+ ## Optional config file (` ~/.aider.conf.yml ` )
62
87
63
88
``` yaml
64
89
openai-api-base : https://api.githubcopilot.com
@@ -70,13 +95,11 @@ show-model-warnings: false
70
95
71
96
---
72
97
73
- ## Notes & FAQ
98
+ ## FAQ
74
99
75
- * Copilot billing is handled entirely by GitHub. Calls made through aider count against your
76
- Copilot subscription, even though aider will still print estimated costs.
77
- * Tokens created by **Neovim copilot.lua** or older ` hosts.json` files sometimes lack the
78
- required scopes. If you get `access to this endpoint is forbidden`, regenerate the token via a
79
- JetBrains IDE or VS Code Copilot extension.
80
- * The Copilot terms of service allow third-party “agents” that access the LLM endpoint. Aider
81
- merely follows the documented API and **does not scrape the web UI**.
100
+ * Calls made through aider are billed through your Copilot subscription
101
+ (aider will still print *estimated* costs).
102
+ * The Copilot docs explicitly allow third-party “agents” that hit this API – aider is playing by
103
+ the rules.
104
+ * Aider talks directly to the REST endpoint—no web-UI scraping or browser automation.
82
105
0 commit comments