copilot-gateway 0.10.0 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -2
- package/README.md +138 -227
- package/dist/{config-CcK4TXHc.js → config-DvrCfcfb.mjs} +12 -13
- package/dist/config-DvrCfcfb.mjs.map +1 -0
- package/dist/{main.js → main.mjs} +9 -11
- package/dist/main.mjs.map +1 -0
- package/dist/{server-CKh3Pzh6.js → server-ZxmAET3c.mjs} +252 -266
- package/dist/server-ZxmAET3c.mjs.map +1 -0
- package/package.json +18 -17
- package/dist/config-CcK4TXHc.js.map +0 -1
- package/dist/main.js.map +0 -1
- package/dist/server-CKh3Pzh6.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
4
|
-
Copyright (c) 2026-Now Pengfei Ni
|
|
3
|
+
Copyright (c) 2026 Pengfei Ni
|
|
5
4
|
|
|
6
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -4,18 +4,10 @@
|
|
|
4
4
|
> This is a reverse-engineered proxy of GitHub Copilot API. It is not supported by GitHub, and may break unexpectedly. Use at your own risk.
|
|
5
5
|
|
|
6
6
|
> [!WARNING]
|
|
7
|
-
> **GitHub Security Notice:**
|
|
8
|
-
> Excessive automated or scripted use of Copilot (including rapid or bulk requests, such as via automated tools) may trigger GitHub's abuse-detection systems.
|
|
9
|
-
> You may receive a warning from GitHub Security, and further anomalous activity could result in temporary suspension of your Copilot access.
|
|
10
|
-
>
|
|
11
|
-
> GitHub prohibits use of their servers for excessive automated bulk activity or any activity that places undue burden on their infrastructure.
|
|
12
|
-
>
|
|
13
|
-
> Please review:
|
|
14
|
-
>
|
|
7
|
+
> **GitHub Security Notice:**
|
|
8
|
+
> Use this proxy responsibly to avoid account restrictions. Excessive automated or scripted use of Copilot (including rapid or bulk requests, such as via automated tools) may trigger GitHub's abuse-detection systems. You may receive a warning from GitHub Security, and further anomalous activity could result in temporary suspension of your Copilot access. Please review:
|
|
15
9
|
> - [GitHub Acceptable Use Policies](https://docs.github.com/site-policy/acceptable-use-policies/github-acceptable-use-policies#4-spam-and-inauthentic-activity-on-github)
|
|
16
10
|
> - [GitHub Copilot Terms](https://docs.github.com/site-policy/github-terms/github-terms-for-additional-products-and-features#github-copilot)
|
|
17
|
-
>
|
|
18
|
-
> Use this proxy responsibly to avoid account restrictions.
|
|
19
11
|
|
|
20
12
|
---
|
|
21
13
|
|
|
@@ -27,77 +19,81 @@
|
|
|
27
19
|
|
|
28
20
|
A reverse-engineered proxy for the GitHub Copilot API that exposes it as an OpenAI and Anthropic compatible service. This allows you to use GitHub Copilot with any tool that supports the OpenAI Chat Completions API or the Anthropic Messages API, including to power [Claude Code](https://docs.anthropic.com/en/docs/claude-code/overview).
|
|
29
21
|
|
|
30
|
-
|
|
22
|
+
- OpenAI (`/v1/chat/completions`, `/v1/responses`, `/v1/models`, `/v1/embeddings`) and Anthropic (`/v1/messages`) compatible endpoints
|
|
23
|
+
- One-command Claude Code setup via `--claude-code`
|
|
24
|
+
- Web-based usage dashboard for monitoring quotas
|
|
25
|
+
- Rate limiting (`--rate-limit`, `--wait`) and manual request approval (`--manual`)
|
|
26
|
+
- Interactive or token-based auth, with individual / business / enterprise account support
|
|
27
|
+
- GitHub Enterprise Server & Cloud compatible
|
|
31
28
|
|
|
32
|
-
|
|
33
|
-
- **Claude Code Integration**: Easily configure and launch [Claude Code](https://docs.anthropic.com/en/docs/claude-code/overview) to use Copilot as its backend with a simple command-line flag (`--claude-code`).
|
|
34
|
-
- **Usage Dashboard**: A web-based dashboard to monitor your Copilot API usage, view quotas, and see detailed statistics.
|
|
35
|
-
- **Rate Limit Control**: Manage API usage with rate-limiting options (`--rate-limit`) and a waiting mechanism (`--wait`) to prevent errors from rapid requests on generation endpoints.
|
|
36
|
-
- **Manual Request Approval**: Manually approve or deny each generation request for fine-grained control over usage (`--manual`).
|
|
37
|
-
- **Token Visibility**: Option to display GitHub and Copilot tokens during authentication and refresh for debugging (`--show-token`).
|
|
38
|
-
- **Flexible Authentication**: Authenticate interactively or provide a GitHub token directly, suitable for CI/CD environments.
|
|
39
|
-
- **Support for Different Account Types**: Works with individual, business, and enterprise GitHub Copilot plans.
|
|
40
|
-
- **GitHub Enterprise Support**: Compatible with GitHub Enterprise Server and GitHub Enterprise Cloud installations.
|
|
29
|
+
## Quick Start
|
|
41
30
|
|
|
42
|
-
|
|
31
|
+
**Prerequisites:** A GitHub account with Copilot subscription.
|
|
43
32
|
|
|
44
|
-
|
|
45
|
-
- GitHub account with Copilot subscription (individual, business, or enterprise)
|
|
46
|
-
|
|
47
|
-
## Installation
|
|
48
|
-
|
|
49
|
-
To install dependencies, run:
|
|
33
|
+
**1. Start the server** (will prompt for GitHub auth on first run):
|
|
50
34
|
|
|
51
35
|
```sh
|
|
52
|
-
|
|
36
|
+
npx copilot-gateway@latest start
|
|
53
37
|
```
|
|
54
38
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
Build image
|
|
39
|
+
**2. Use with Claude Code** — run with `--claude-code` to get a ready-to-paste launch command:
|
|
58
40
|
|
|
59
41
|
```sh
|
|
60
|
-
|
|
42
|
+
npx copilot-gateway@latest start --claude-code
|
|
61
43
|
```
|
|
62
44
|
|
|
63
|
-
|
|
45
|
+
Or manually configure Claude Code by creating `.claude/settings.json` in your project:
|
|
64
46
|
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"env": {
|
|
50
|
+
"ANTHROPIC_BASE_URL": "http://localhost:4141",
|
|
51
|
+
"ANTHROPIC_AUTH_TOKEN": "sk-dummy",
|
|
52
|
+
"ANTHROPIC_MODEL": "claude-opus-4.6",
|
|
53
|
+
"ANTHROPIC_SMALL_FAST_MODEL": "claude-sonnet-4.5",
|
|
54
|
+
"ENABLE_TOOL_SEARCH": "true",
|
|
55
|
+
"CLAUDE_CODE_ATTRIBUTION_HEADER": "0",
|
|
56
|
+
"DISABLE_NON_ESSENTIAL_MODEL_CALLS": "1",
|
|
57
|
+
"CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1",
|
|
58
|
+
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
68
62
|
|
|
69
|
-
|
|
70
|
-
# This ensures your authentication survives container restarts
|
|
63
|
+
More options: [Claude Code settings](https://docs.anthropic.com/en/docs/claude-code/settings#environment-variables) · [IDE integration](https://docs.anthropic.com/en/docs/claude-code/ide-integrations)
|
|
71
64
|
|
|
72
|
-
|
|
73
|
-
```
|
|
65
|
+
## Docker
|
|
74
66
|
|
|
75
|
-
|
|
76
|
-
> The GitHub token and related data will be stored in `copilot-data` on your host. This is mapped to `/root/.local/share/copilot-gateway` inside the container, ensuring persistence across restarts.
|
|
77
|
-
> If you don't provide `GH_TOKEN`, make sure the mapped directory already contains a valid token from a previous auth flow.
|
|
67
|
+
Pre-built images are published to `ghcr.io/feiskyer/copilot-gateway` on every release.
|
|
78
68
|
|
|
79
|
-
|
|
69
|
+
<details>
|
|
70
|
+
<summary>View Docker usage details</summary>
|
|
80
71
|
|
|
81
|
-
|
|
72
|
+
```sh
|
|
73
|
+
docker run -p 4141:4141 ghcr.io/feiskyer/copilot-gateway:latest
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Pass a GitHub token via environment variable:
|
|
82
77
|
|
|
83
78
|
```sh
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
docker run -p 4141:4141 -e GH_TOKEN=your_github_token_here ghcr.io/feiskyer/copilot-gateway:latest
|
|
80
|
+
```
|
|
86
81
|
|
|
87
|
-
|
|
88
|
-
docker run -p 4141:4141 -e GH_TOKEN=your_github_token_here copilot-gateway
|
|
82
|
+
Persist auth across restarts with a bind mount:
|
|
89
83
|
|
|
90
|
-
|
|
91
|
-
|
|
84
|
+
```sh
|
|
85
|
+
mkdir -p ./copilot-data
|
|
86
|
+
docker run -p 4141:4141 \
|
|
87
|
+
-v $(pwd)/copilot-data:/root/.local/share/copilot-gateway \
|
|
88
|
+
ghcr.io/feiskyer/copilot-gateway:latest
|
|
92
89
|
```
|
|
93
90
|
|
|
94
|
-
|
|
91
|
+
Docker Compose:
|
|
95
92
|
|
|
96
93
|
```yaml
|
|
97
|
-
version: "3.8"
|
|
98
94
|
services:
|
|
99
95
|
copilot-gateway:
|
|
100
|
-
|
|
96
|
+
image: ghcr.io/feiskyer/copilot-gateway:latest
|
|
101
97
|
ports:
|
|
102
98
|
- "4141:4141"
|
|
103
99
|
environment:
|
|
@@ -105,47 +101,26 @@ services:
|
|
|
105
101
|
restart: unless-stopped
|
|
106
102
|
```
|
|
107
103
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
- Multi-stage build for optimized image size
|
|
111
|
-
- Health check for container monitoring
|
|
112
|
-
- Pinned base image version for reproducible builds
|
|
113
|
-
|
|
114
|
-
## Using with npx
|
|
115
|
-
|
|
116
|
-
You can run the project directly using npx:
|
|
117
|
-
|
|
118
|
-
```sh
|
|
119
|
-
npx copilot-gateway@latest start
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
With options:
|
|
123
|
-
|
|
124
|
-
```sh
|
|
125
|
-
npx copilot-gateway@latest start --port 8080
|
|
126
|
-
```
|
|
104
|
+
To build from source instead, use `docker build -t copilot-gateway .`
|
|
127
105
|
|
|
128
|
-
|
|
106
|
+
</details>
|
|
129
107
|
|
|
130
|
-
|
|
131
|
-
npx copilot-gateway@latest auth
|
|
132
|
-
```
|
|
108
|
+
## CLI Options
|
|
133
109
|
|
|
134
|
-
|
|
110
|
+
Subcommands: `start`, `auth`, `check-usage`, `debug`. Run `npx copilot-gateway@latest <command> --help` for details.
|
|
135
111
|
|
|
136
|
-
|
|
112
|
+
<details>
|
|
113
|
+
<summary>View all commands and flags</summary>
|
|
137
114
|
|
|
138
|
-
|
|
139
|
-
- `auth`: Run GitHub authentication flow without starting the server. This is typically used if you need to generate a token for use with the `--github-token` option, especially in non-interactive environments.
|
|
140
|
-
- `check-usage`: Show your current GitHub Copilot usage and quota information directly in the terminal (no server required).
|
|
141
|
-
- `debug`: Display diagnostic information including version, runtime details, file paths, and authentication status. Useful for troubleshooting and support.
|
|
115
|
+
### Commands
|
|
142
116
|
|
|
143
|
-
|
|
117
|
+
- `start`: Start the server (handles auth if needed).
|
|
118
|
+
- `auth`: Run GitHub auth flow without starting the server.
|
|
119
|
+
- `check-usage`: Show Copilot usage/quota in the terminal (no server required).
|
|
120
|
+
- `debug`: Display diagnostic info for troubleshooting.
|
|
144
121
|
|
|
145
122
|
### Start Command Options
|
|
146
123
|
|
|
147
|
-
The following command line options are available for the `start` command:
|
|
148
|
-
|
|
149
124
|
| Option | Description | Default | Alias |
|
|
150
125
|
| -------------- | ----------------------------------------------------------------------------- | ---------- | ----- |
|
|
151
126
|
| --port | Port to listen on | 4141 | -p |
|
|
@@ -158,7 +133,7 @@ The following command line options are available for the `start` command:
|
|
|
158
133
|
| --claude-code | Generate a command to launch Claude Code with Copilot Gateway config | false | -c |
|
|
159
134
|
| --show-token | Show GitHub and Copilot tokens on fetch and refresh | false | none |
|
|
160
135
|
| --proxy-env | Initialize proxy from environment variables (Node.js runtime only) | false | none |
|
|
161
|
-
| --enterprise-url | GitHub Enterprise host to use (eg. https://ghe.example.com) | none | none |
|
|
136
|
+
| --enterprise-url | GitHub Enterprise host to use (eg. <https://ghe.example.com>) | none | none |
|
|
162
137
|
| --api-key | API keys for authentication. Can be specified multiple times | none | none |
|
|
163
138
|
|
|
164
139
|
### Auth Command Options
|
|
@@ -167,7 +142,7 @@ The following command line options are available for the `start` command:
|
|
|
167
142
|
| ------------ | ------------------------- | ------- | ----- |
|
|
168
143
|
| --verbose | Enable verbose logging | false | -v |
|
|
169
144
|
| --show-token | Show GitHub token on auth | false | none |
|
|
170
|
-
| --enterprise-url | GitHub Enterprise host (eg. https://ghe.example.com) | none | none |
|
|
145
|
+
| --enterprise-url | GitHub Enterprise host (eg. <https://ghe.example.com>) | none | none |
|
|
171
146
|
|
|
172
147
|
### Debug Command Options
|
|
173
148
|
|
|
@@ -175,11 +150,18 @@ The following command line options are available for the `start` command:
|
|
|
175
150
|
| ------ | ------------------------- | ------- | ----- |
|
|
176
151
|
| --json | Output debug info as JSON | false | none |
|
|
177
152
|
|
|
178
|
-
|
|
153
|
+
</details>
|
|
154
|
+
|
|
155
|
+
## Configuration
|
|
156
|
+
|
|
157
|
+
Stored at `~/.local/share/copilot-gateway/config.json`. Edit to customize prompts, models, and reasoning efforts.
|
|
158
|
+
|
|
159
|
+
<details>
|
|
160
|
+
<summary>View config format and options</summary>
|
|
179
161
|
|
|
180
|
-
- **Location:** `~/.local/share/copilot-gateway/config.json` (Linux/macOS) or `%USERPROFILE%\.local\share\copilot-gateway\config.json` (Windows).
|
|
181
162
|
- **Related files in the same directory:** `github_token`, `enterprise_url`, and `logs/`.
|
|
182
163
|
- **Default shape:**
|
|
164
|
+
|
|
183
165
|
```json
|
|
184
166
|
{
|
|
185
167
|
"extraPrompts": {
|
|
@@ -192,19 +174,23 @@ The following command line options are available for the `start` command:
|
|
|
192
174
|
}
|
|
193
175
|
}
|
|
194
176
|
```
|
|
195
|
-
|
|
177
|
+
|
|
178
|
+
- **extraPrompts:** Map of `model -> prompt` appended to the first system prompt when translating Anthropic-style requests to Copilot. Missing default entries are auto-added without overwriting your custom prompts.
|
|
196
179
|
- **smallModel:** Fallback model used for tool-less warmup messages (e.g., Claude Code probe requests) to avoid spending premium requests; defaults to `gpt-5-mini`.
|
|
197
|
-
- **modelReasoningEfforts:** Per-model `reasoning.effort` sent to the Copilot Responses API. Allowed values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. If a model isn
|
|
180
|
+
- **modelReasoningEfforts:** Per-model `reasoning.effort` sent to the Copilot Responses API. Allowed values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. If a model isn't listed, `high` is used by default.
|
|
181
|
+
|
|
182
|
+
Restart the server after changes so the cached config is refreshed.
|
|
198
183
|
|
|
199
|
-
|
|
184
|
+
</details>
|
|
200
185
|
|
|
201
|
-
##
|
|
186
|
+
## Endpoints
|
|
202
187
|
|
|
203
|
-
|
|
188
|
+
OpenAI and Anthropic compatible API endpoints, plus usage monitoring.
|
|
204
189
|
|
|
205
|
-
|
|
190
|
+
<details>
|
|
191
|
+
<summary>View all endpoints</summary>
|
|
206
192
|
|
|
207
|
-
|
|
193
|
+
### OpenAI Compatible
|
|
208
194
|
|
|
209
195
|
| Endpoint | Method | Description |
|
|
210
196
|
| --------------------------- | ------ | ---------------------------------------------------------------- |
|
|
@@ -213,77 +199,64 @@ These endpoints mimic the OpenAI API structure.
|
|
|
213
199
|
| `GET /v1/models` | `GET` | Lists the currently available models. |
|
|
214
200
|
| `POST /v1/embeddings` | `POST` | Creates an embedding vector representing the input text. |
|
|
215
201
|
|
|
216
|
-
|
|
202
|
+
Aliases without `/v1` prefix: `/responses`, `/chat/completions`, `/models`, `/embeddings`.
|
|
217
203
|
|
|
218
|
-
|
|
219
|
-
- `POST /chat/completions`
|
|
220
|
-
- `GET /models`
|
|
221
|
-
- `POST /embeddings`
|
|
222
|
-
|
|
223
|
-
### Anthropic Compatible Endpoints
|
|
224
|
-
|
|
225
|
-
These endpoints are designed to be compatible with the Anthropic Messages API.
|
|
204
|
+
### Anthropic Compatible
|
|
226
205
|
|
|
227
206
|
| Endpoint | Method | Description |
|
|
228
207
|
| -------------------------------- | ------ | ------------------------------------------------------------ |
|
|
229
208
|
| `POST /v1/messages` | `POST` | Creates a model response for a given conversation. |
|
|
230
209
|
| `POST /v1/messages/count_tokens` | `POST` | Calculates the number of tokens for a given set of messages. |
|
|
231
|
-
| `POST /api/event_logging/batch` | `POST` | Anthropic telemetry log (
|
|
232
|
-
|
|
233
|
-
### Usage Monitoring Endpoints
|
|
210
|
+
| `POST /api/event_logging/batch` | `POST` | Anthropic telemetry log (returns 200). |
|
|
234
211
|
|
|
235
|
-
|
|
212
|
+
### Monitoring
|
|
236
213
|
|
|
237
214
|
| Endpoint | Method | Description |
|
|
238
215
|
| ------------ | ------ | ------------------------------------------------------------ |
|
|
239
216
|
| `GET /usage` | `GET` | Get detailed Copilot usage statistics and quota information. |
|
|
240
217
|
| `GET /token` | `GET` | Get the current Copilot token being used by the API. |
|
|
241
218
|
|
|
242
|
-
|
|
219
|
+
</details>
|
|
243
220
|
|
|
244
|
-
|
|
221
|
+
## Authentication
|
|
245
222
|
|
|
246
|
-
|
|
223
|
+
Restrict access with API keys via `--api-key`. Supports both `Authorization: Bearer` and `x-api-key` headers.
|
|
247
224
|
|
|
248
|
-
|
|
225
|
+
<details>
|
|
226
|
+
<summary>View authentication details</summary>
|
|
249
227
|
|
|
250
|
-
- **OpenAI format**:
|
|
251
|
-
|
|
252
|
-
curl -H "Authorization: Bearer your_api_key_here" http://localhost:4141/v1/models
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
- **Anthropic format**: Include the API key in the `x-api-key` header:
|
|
256
|
-
```bash
|
|
257
|
-
curl -H "x-api-key: your_api_key_here" http://localhost:4141/v1/messages
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
### Configuration
|
|
261
|
-
|
|
262
|
-
Use the `--api-key` flag to enable API key authentication. You can specify multiple keys for different clients:
|
|
228
|
+
- **OpenAI format**: `Authorization: Bearer your_api_key_here`
|
|
229
|
+
- **Anthropic format**: `x-api-key: your_api_key_here`
|
|
263
230
|
|
|
264
231
|
```bash
|
|
265
232
|
# Single API key
|
|
266
233
|
npx copilot-gateway@latest start --api-key your_secret_key
|
|
267
234
|
|
|
268
|
-
# Multiple API keys
|
|
235
|
+
# Multiple API keys
|
|
269
236
|
npx copilot-gateway@latest start --api-key key1 --api-key key2 --api-key key3
|
|
270
237
|
```
|
|
271
238
|
|
|
272
239
|
When API keys are configured:
|
|
273
|
-
|
|
240
|
+
|
|
241
|
+
- All API endpoints require authentication
|
|
274
242
|
- Requests without valid API keys will receive a 401 Unauthorized response
|
|
275
243
|
- The root endpoint `/` remains accessible without authentication
|
|
276
244
|
|
|
277
|
-
|
|
245
|
+
</details>
|
|
246
|
+
|
|
247
|
+
## Examples
|
|
248
|
+
|
|
249
|
+
Common usage patterns for different account types, rate limiting, and enterprise setups.
|
|
278
250
|
|
|
279
|
-
|
|
251
|
+
<details>
|
|
252
|
+
<summary>View example commands</summary>
|
|
280
253
|
|
|
281
254
|
```sh
|
|
282
255
|
# Basic usage with start command
|
|
283
256
|
npx copilot-gateway@latest start
|
|
284
257
|
|
|
285
258
|
# Run on custom port with verbose logging
|
|
286
|
-
npx copilot-gateway@latest start --port
|
|
259
|
+
npx copilot-gateway@latest start --port 4141 --verbose
|
|
287
260
|
|
|
288
261
|
# Use with a business plan GitHub account
|
|
289
262
|
npx copilot-gateway@latest start --account-type business
|
|
@@ -312,133 +285,71 @@ npx copilot-gateway@latest start --api-key key1 --api-key key2 --api-key key3
|
|
|
312
285
|
# Run only the auth flow
|
|
313
286
|
npx copilot-gateway@latest auth
|
|
314
287
|
|
|
315
|
-
# Run auth flow with verbose logging
|
|
316
|
-
npx copilot-gateway@latest auth --verbose
|
|
317
|
-
|
|
318
288
|
# Show your Copilot usage/quota in the terminal (no server needed)
|
|
319
289
|
npx copilot-gateway@latest check-usage
|
|
320
290
|
|
|
321
291
|
# Display debug information for troubleshooting
|
|
322
292
|
npx copilot-gateway@latest debug
|
|
323
293
|
|
|
324
|
-
# Display debug information in JSON format
|
|
325
|
-
npx copilot-gateway@latest debug --json
|
|
326
|
-
|
|
327
|
-
# Initialize proxy from environment variables (HTTP_PROXY, HTTPS_PROXY, etc.)
|
|
328
|
-
# Note: this option is currently relevant for Node.js runtime paths; Bun generally uses its own proxy behavior.
|
|
329
|
-
npx copilot-gateway@latest start --proxy-env
|
|
330
|
-
|
|
331
294
|
# Use GitHub Enterprise / GitHub Enterprise Server
|
|
332
295
|
npx copilot-gateway@latest start --account-type enterprise --enterprise-url https://ghe.example.com
|
|
333
296
|
|
|
334
|
-
# Authenticate with GitHub Enterprise interactively (will prompt for enterprise host)
|
|
335
|
-
npx copilot-gateway@latest auth
|
|
336
|
-
|
|
337
297
|
# Authenticate with GitHub Enterprise using CLI flag (for scripting)
|
|
338
298
|
npx copilot-gateway@latest auth --enterprise-url ghe.example.com
|
|
339
299
|
```
|
|
340
300
|
|
|
341
|
-
|
|
301
|
+
</details>
|
|
342
302
|
|
|
343
|
-
|
|
303
|
+
## Usage Dashboard
|
|
344
304
|
|
|
345
|
-
|
|
346
|
-
```sh
|
|
347
|
-
npx copilot-gateway@latest start
|
|
348
|
-
```
|
|
349
|
-
2. The server will output a URL to the usage viewer. Copy and paste this URL into your browser. It will look something like this:
|
|
350
|
-
`https://feiskyer.github.io/copilot-gateway?endpoint=http://localhost:4141/usage`
|
|
351
|
-
- If you use the `start.bat` script on Windows, this page will open automatically.
|
|
305
|
+
A web-based dashboard for monitoring your Copilot API usage and quotas.
|
|
352
306
|
|
|
353
|
-
|
|
307
|
+
<details>
|
|
308
|
+
<summary>View dashboard setup</summary>
|
|
354
309
|
|
|
355
|
-
|
|
356
|
-
-
|
|
357
|
-
- **Usage Quotas**: View a summary of your usage quotas for different services like Chat and Completions, displayed with progress bars for a quick overview.
|
|
358
|
-
- **Detailed Information**: See the full JSON response from the API for a detailed breakdown of all available usage statistics.
|
|
359
|
-
- **URL-based Configuration**: You can also specify the API endpoint directly in the URL using a query parameter. This is useful for bookmarks or sharing links. For example:
|
|
360
|
-
`https://feiskyer.github.io/copilot-gateway?endpoint=http://your-api-server/usage`
|
|
310
|
+
After starting the server, a URL to the dashboard will be displayed in your console:
|
|
311
|
+
`https://feiskyer.github.io/copilot-gateway?endpoint=http://localhost:4141/usage`
|
|
361
312
|
|
|
362
|
-
|
|
313
|
+
The dashboard shows usage quotas with progress bars, detailed JSON statistics, and supports custom API endpoint URLs via query parameter.
|
|
363
314
|
|
|
364
|
-
|
|
315
|
+
</details>
|
|
365
316
|
|
|
366
|
-
|
|
317
|
+
## Development
|
|
367
318
|
|
|
368
|
-
|
|
319
|
+
Build and run from source using Bun.
|
|
369
320
|
|
|
370
|
-
|
|
321
|
+
<details>
|
|
322
|
+
<summary>View development commands</summary>
|
|
371
323
|
|
|
372
324
|
```sh
|
|
373
|
-
|
|
325
|
+
bun install # Install dependencies
|
|
326
|
+
bun run dev # Development mode with watch
|
|
327
|
+
bun run start # Production mode
|
|
328
|
+
bun run lint # ESLint
|
|
329
|
+
bun run typecheck # TypeScript strict checking
|
|
330
|
+
bun test # Run all tests
|
|
374
331
|
```
|
|
375
332
|
|
|
376
|
-
|
|
333
|
+
</details>
|
|
377
334
|
|
|
378
|
-
|
|
335
|
+
## Tips
|
|
379
336
|
|
|
380
|
-
|
|
337
|
+
Best practices for rate limiting, account types, and enterprise configuration.
|
|
381
338
|
|
|
382
|
-
|
|
339
|
+
<details>
|
|
340
|
+
<summary>View tips</summary>
|
|
383
341
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
"env": {
|
|
389
|
-
"ANTHROPIC_BASE_URL": "http://localhost:4141",
|
|
390
|
-
"ANTHROPIC_AUTH_TOKEN": "dummy",
|
|
391
|
-
"ANTHROPIC_MODEL": "gpt-4.1",
|
|
392
|
-
"ANTHROPIC_DEFAULT_SONNET_MODEL": "gpt-4.1",
|
|
393
|
-
"ANTHROPIC_SMALL_FAST_MODEL": "gpt-4.1",
|
|
394
|
-
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "gpt-4.1",
|
|
395
|
-
"DISABLE_NON_ESSENTIAL_MODEL_CALLS": "1",
|
|
396
|
-
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
|
|
397
|
-
},
|
|
398
|
-
"permissions": {
|
|
399
|
-
"deny": [
|
|
400
|
-
"WebSearch"
|
|
401
|
-
]
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
You can find more options here: [Claude Code settings](https://docs.anthropic.com/en/docs/claude-code/settings#environment-variables)
|
|
407
|
-
|
|
408
|
-
You can also read more about IDE integration here: [Add Claude Code to your IDE](https://docs.anthropic.com/en/docs/claude-code/ide-integrations)
|
|
409
|
-
|
|
410
|
-
## Running from Source
|
|
411
|
-
|
|
412
|
-
The project can be run from source in several ways:
|
|
413
|
-
|
|
414
|
-
### Development Mode
|
|
415
|
-
|
|
416
|
-
```sh
|
|
417
|
-
bun run dev
|
|
418
|
-
```
|
|
419
|
-
|
|
420
|
-
### Production Mode
|
|
421
|
-
|
|
422
|
-
```sh
|
|
423
|
-
bun run start
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
## Usage Tips
|
|
427
|
-
|
|
428
|
-
- To avoid hitting GitHub Copilot's rate limits, you can use the following flags:
|
|
429
|
-
- `--manual`: Enables manual approval for each request, giving you full control over when requests are sent.
|
|
430
|
-
- `--rate-limit <seconds>`: Enforces a minimum time interval between requests. For example, `copilot-gateway start --rate-limit 30` will ensure there's at least a 30-second gap between requests.
|
|
431
|
-
- `--wait`: Use this with `--rate-limit`. It makes the server wait for the cooldown period to end instead of rejecting the request with an error. This is useful for clients that don't automatically retry on rate limit errors.
|
|
432
|
-
- If you have a GitHub business or enterprise plan account with Copilot, use the `--account-type` flag (e.g., `--account-type business`). See the [official documentation](https://docs.github.com/en/enterprise-cloud@latest/copilot/managing-copilot/managing-github-copilot-in-your-organization/managing-access-to-github-copilot-in-your-organization/managing-github-copilot-access-to-your-organizations-network#configuring-copilot-subscription-based-network-routing-for-your-enterprise-or-organization) for more details.
|
|
433
|
-
- For GitHub Enterprise Server/Cloud users: Use `--enterprise-url` to specify your enterprise host (e.g., `--enterprise-url https://ghe.example.com`). The interactive auth command (`copilot-gateway auth`) will prompt you for your enterprise host if you don't provide it via the CLI flag.
|
|
342
|
+
- Use `--rate-limit <seconds>` with `--wait` to throttle requests instead of getting errors.
|
|
343
|
+
- Use `--manual` for full control over when each request is sent.
|
|
344
|
+
- For business/enterprise Copilot plans, set `--account-type business` or `--account-type enterprise`. See the [official documentation](https://docs.github.com/en/enterprise-cloud@latest/copilot/managing-copilot/managing-github-copilot-in-your-organization/managing-access-to-github-copilot-in-your-organization/managing-github-copilot-access-to-your-organizations-network#configuring-copilot-subscription-based-network-routing-for-your-enterprise-or-organization) for more details.
|
|
345
|
+
- For GitHub Enterprise Server/Cloud: use `--enterprise-url` to specify your enterprise host.
|
|
434
346
|
|
|
347
|
+
</details>
|
|
435
348
|
|
|
349
|
+
## Credits
|
|
436
350
|
|
|
351
|
+
Fork of [`ericc-ch/copilot-api`](https://github.com/ericc-ch/copilot-api). Thanks to [@ericc-ch](https://github.com/ericc-ch) and all contributors.
|
|
437
352
|
|
|
438
|
-
##
|
|
353
|
+
## License
|
|
439
354
|
|
|
440
|
-
|
|
441
|
-
This project is maintained as a fork/rebrand of the original
|
|
442
|
-
[`ericc-ch/copilot-api`](https://github.com/ericc-ch/copilot-api).
|
|
443
|
-
Huge thanks to [@ericc-ch](https://github.com/ericc-ch) and all contributors for the original implementation.
|
|
444
|
-
</detail>
|
|
355
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
@@ -67,16 +67,16 @@ const COPILOT_VERSION = "0.35.0";
|
|
|
67
67
|
const EDITOR_PLUGIN_VERSION = `copilot-chat/${COPILOT_VERSION}`;
|
|
68
68
|
const USER_AGENT = `GitHubCopilotChat/${COPILOT_VERSION}`;
|
|
69
69
|
const API_VERSION = "2025-10-01";
|
|
70
|
-
const copilotBaseUrl = (state
|
|
71
|
-
if (state
|
|
72
|
-
return state
|
|
70
|
+
const copilotBaseUrl = (state) => {
|
|
71
|
+
if (state.enterpriseUrl) return `https://copilot-api.${state.enterpriseUrl}`;
|
|
72
|
+
return state.accountType === "individual" ? "https://api.githubcopilot.com" : `https://api.${state.accountType}.githubcopilot.com`;
|
|
73
73
|
};
|
|
74
|
-
const copilotHeaders = (state
|
|
74
|
+
const copilotHeaders = (state, vision = false) => {
|
|
75
75
|
const headers = {
|
|
76
|
-
Authorization: `Bearer ${state
|
|
76
|
+
Authorization: `Bearer ${state.copilotToken}`,
|
|
77
77
|
"content-type": standardHeaders()["content-type"],
|
|
78
78
|
"copilot-integration-id": "vscode-chat",
|
|
79
|
-
"editor-version": `vscode/${state
|
|
79
|
+
"editor-version": `vscode/${state.vsCodeVersion}`,
|
|
80
80
|
"editor-plugin-version": EDITOR_PLUGIN_VERSION,
|
|
81
81
|
"user-agent": USER_AGENT,
|
|
82
82
|
"openai-intent": "conversation-panel",
|
|
@@ -88,10 +88,10 @@ const copilotHeaders = (state$1, vision = false) => {
|
|
|
88
88
|
return headers;
|
|
89
89
|
};
|
|
90
90
|
const GITHUB_API_BASE_URL = () => githubApiBaseUrl(state.enterpriseUrl);
|
|
91
|
-
const githubHeaders = (state
|
|
91
|
+
const githubHeaders = (state) => ({
|
|
92
92
|
...standardHeaders(),
|
|
93
|
-
authorization: `token ${state
|
|
94
|
-
"editor-version": `vscode/${state
|
|
93
|
+
authorization: `token ${state.githubToken}`,
|
|
94
|
+
"editor-version": `vscode/${state.vsCodeVersion}`,
|
|
95
95
|
"editor-plugin-version": EDITOR_PLUGIN_VERSION,
|
|
96
96
|
"user-agent": USER_AGENT,
|
|
97
97
|
"x-github-api-version": API_VERSION,
|
|
@@ -252,8 +252,7 @@ function mergeDefaultExtraPrompts(config) {
|
|
|
252
252
|
};
|
|
253
253
|
}
|
|
254
254
|
function mergeConfigWithDefaults() {
|
|
255
|
-
const
|
|
256
|
-
const { mergedConfig, changed } = mergeDefaultExtraPrompts(config);
|
|
255
|
+
const { mergedConfig, changed } = mergeDefaultExtraPrompts(readConfigFromDisk());
|
|
257
256
|
if (changed) try {
|
|
258
257
|
fs$1.writeFileSync(PATHS.CONFIG_PATH, `${JSON.stringify(mergedConfig, null, 2)}\n`, "utf8");
|
|
259
258
|
} catch (writeError) {
|
|
@@ -277,5 +276,5 @@ function getReasoningEffortForModel(model) {
|
|
|
277
276
|
}
|
|
278
277
|
|
|
279
278
|
//#endregion
|
|
280
|
-
export {
|
|
281
|
-
//# sourceMappingURL=config-
|
|
279
|
+
export { ensurePaths as C, PATHS as S, copilotBaseUrl as _, getCopilotUsage as a, standardHeaders as b, constantTimeEqual as c, HTTPError as d, forwardError as f, GITHUB_CLIENT_ID as g, GITHUB_BASE_URL as h, mergeConfigWithDefaults as i, isNullish as l, GITHUB_APP_SCOPES as m, getReasoningEffortForModel as n, cacheModels as o, GITHUB_API_BASE_URL as p, getSmallModel as r, cacheVSCodeVersion as s, getExtraPromptForModel as t, sleep as u, copilotHeaders as v, state as x, githubHeaders as y };
|
|
280
|
+
//# sourceMappingURL=config-DvrCfcfb.mjs.map
|