copilot-api-plus 1.0.8 → 1.0.10

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/README.md CHANGED
@@ -1,549 +1,349 @@
1
1
  # Copilot API Plus
2
2
 
3
-
4
-
5
3
  > **Fork of [ericc-ch/copilot-api](https://github.com/ericc-ch/copilot-api)** with bug fixes and improvements.
6
4
 
7
- > [!WARNING]
8
- > 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.
9
-
10
- > [!WARNING]
11
- > **GitHub Security Notice:**
12
- > Excessive automated or scripted use of Copilot (including rapid or bulk requests, such as via automated tools) may trigger GitHub's abuse-detection systems.
13
- > You may receive a warning from GitHub Security, and further anomalous activity could result in temporary suspension of your Copilot access.
14
- >
15
- > GitHub prohibits use of their servers for excessive automated bulk activity or any activity that places undue burden on their infrastructure.
16
- >
17
- > Please review:
18
- >
19
- > - [GitHub Acceptable Use Policies](https://docs.github.com/site-policy/acceptable-use-policies/github-acceptable-use-policies#4-spam-and-inauthentic-activity-on-github)
20
- > - [GitHub Copilot Terms](https://docs.github.com/site-policy/github-terms/github-terms-for-additional-products-and-features#github-copilot)
21
- >
22
- > Use this proxy responsibly to avoid account restrictions.
5
+ GitHub Copilot、OpenCode Zen、Google Antigravity 等 AI 服务转换为 **OpenAI** 和 **Anthropic** 兼容 API,支持与 [Claude Code](https://docs.anthropic.com/en/docs/claude-code/overview)、[opencode](https://github.com/sst/opencode) 等工具无缝集成。
23
6
 
24
7
  ---
25
8
 
26
- ## What's Different from Original?
27
-
28
- This fork includes the following bug fixes and improvements:
29
-
30
- - ✅ **Auto Re-authentication**: Automatically detects invalid/expired GitHub tokens and re-authenticates
31
- - **Logout Command**: New `logout` command to clear stored tokens and switch accounts
32
- - **Better Error Handling**: Token refresh failures no longer crash the server
33
- - **OAuth Timeout**: Device code polling now has proper timeout handling
34
- - ✅ **Token Validation**: Validates provided GitHub tokens before use
35
- - **API Key Auth**: API key authentication middleware is now properly enabled
9
+ ## 📋 目录
10
+
11
+ - [功能特点](#-功能特点)
12
+ - [快速开始](#-快速开始)
13
+ - [详细使用指南](#-详细使用指南)
14
+ - [GitHub Copilot 模式](#1-github-copilot-模式默认)
15
+ - [OpenCode Zen 模式](#2-opencode-zen-模式)
16
+ - [Google Antigravity 模式](#3-google-antigravity-模式)
17
+ - [代理配置](#-代理配置)
18
+ - [Claude Code 集成](#-claude-code-集成)
19
+ - [opencode 集成](#-opencode-集成)
20
+ - [API 端点](#-api-端点)
21
+ - [命令行参考](#-命令行参考)
22
+ - [Docker 部署](#-docker-部署)
23
+ - [常见问题](#-常见问题)
36
24
 
37
25
  ---
38
26
 
39
- ## Project Overview
27
+ ## 功能特点
40
28
 
41
- 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
+ | 功能 | 说明 |
30
+ |------|------|
31
+ | 🔌 **多后端支持** | GitHub Copilot、OpenCode Zen、Google Antigravity 三种后端可选 |
32
+ | 🤖 **双协议兼容** | 同时支持 OpenAI Chat Completions API 和 Anthropic Messages API |
33
+ | 💻 **Claude Code 集成** | 一键生成 Claude Code 启动命令 (`--claude-code`) |
34
+ | 📊 **使用量监控** | Web 仪表盘实时查看 API 使用情况 |
35
+ | 🔄 **自动认证** | Token 过期自动刷新,无需手动干预 |
36
+ | ⚡ **速率限制** | 内置请求频率控制,避免触发限制 |
37
+ | 🌐 **代理支持** | 支持 HTTP/HTTPS 代理,配置持久化 |
38
+ | 🐳 **Docker 支持** | 提供完整的 Docker 部署方案 |
42
39
 
43
- ## Features
44
-
45
- - **OpenAI & Anthropic Compatibility**: Exposes GitHub Copilot as an OpenAI-compatible (`/v1/chat/completions`, `/v1/models`, `/v1/embeddings`) and Anthropic-compatible (`/v1/messages`) API.
46
- - **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`).
47
- - **Usage Dashboard**: A web-based dashboard to monitor your Copilot API usage, view quotas, and see detailed statistics.
48
- - **Rate Limit Control**: Manage API usage with rate-limiting options (`--rate-limit`) and a waiting mechanism (`--wait`) to prevent errors from rapid requests.
49
- - **Manual Request Approval**: Manually approve or deny each API request for fine-grained control over usage (`--manual`).
50
- - **Token Visibility**: Option to display GitHub and Copilot tokens during authentication and refresh for debugging (`--show-token`).
51
- - **Flexible Authentication**: Authenticate interactively or provide a GitHub token directly, suitable for CI/CD environments.
52
- - **Support for Different Account Types**: Works with individual, business, and enterprise GitHub Copilot plans.
53
-
54
- ## Prerequisites
40
+ ---
55
41
 
56
- - Bun (>= 1.2.x)
57
- - GitHub account with Copilot subscription (individual, business, or enterprise)
42
+ ## 🚀 快速开始
58
43
 
59
- ## Installation
44
+ ### 安装
60
45
 
61
- To install dependencies, run:
46
+ ```bash
47
+ # 全局安装
48
+ npm install -g copilot-api-plus
62
49
 
63
- ```sh
64
- bun install
50
+ # 或使用 npx 直接运行(推荐)
51
+ npx copilot-api-plus@latest start
65
52
  ```
66
53
 
67
- ## Using with Docker
68
-
69
- Build image
54
+ ### 基本用法
70
55
 
71
- ```sh
72
- docker build -t copilot-api-plus .
73
- ```
74
-
75
- Run the container
56
+ ```bash
57
+ # 启动服务器(默认使用 GitHub Copilot)
58
+ npx copilot-api-plus@latest start
76
59
 
77
- ```sh
78
- # Create a directory on your host to persist the GitHub token and related data
79
- mkdir -p ./copilot-data
60
+ # 使用 OpenCode Zen
61
+ npx copilot-api-plus@latest start --zen
80
62
 
81
- # Run the container with a bind mount to persist the token
82
- # This ensures your authentication survives container restarts
63
+ # 使用 Google Antigravity
64
+ npx copilot-api-plus@latest start --antigravity
83
65
 
84
- docker run -p 4141:4141 -v $(pwd)/copilot-data:/root/.local/share/copilot-api-plus copilot-api-plus
66
+ # Claude Code 配合
67
+ npx copilot-api-plus@latest start --claude-code
85
68
  ```
86
69
 
87
- > **Note:**
88
- > The GitHub token and related data will be stored in `copilot-data` on your host. This is mapped to `/root/.local/share/copilot-api-plus` inside the container, ensuring persistence across restarts.
89
-
90
- ### Docker with Environment Variables
91
-
92
- You can pass the GitHub token directly to the container using environment variables:
70
+ 服务器启动后,默认监听 `http://localhost:4141`。
93
71
 
94
- ```sh
95
- # Build with GitHub token
96
- docker build --build-arg GH_TOKEN=your_github_token_here -t copilot-api-plus .
97
-
98
- # Run with GitHub token
99
- docker run -p 4141:4141 -e GH_TOKEN=your_github_token_here copilot-api-plus
100
-
101
- # Run with additional options
102
- docker run -p 4141:4141 -e GH_TOKEN=your_token copilot-api-plus start --verbose --port 4141
103
- ```
72
+ ---
104
73
 
105
- ### Docker Compose Example
74
+ ## 📖 详细使用指南
106
75
 
107
- ```yaml
108
- version: "3.8"
109
- services:
110
- copilot-api-plus:
111
- build: .
112
- ports:
113
- - "4141:4141"
114
- environment:
115
- - GH_TOKEN=your_github_token_here
116
- restart: unless-stopped
117
- ```
118
-
119
- The Docker image includes:
76
+ ### 1. GitHub Copilot 模式(默认)
120
77
 
121
- - Multi-stage build for optimized image size
122
- - Non-root user for enhanced security
123
- - Health check for container monitoring
124
- - Pinned base image version for reproducible builds
78
+ 使用你的 GitHub Copilot 订阅访问 AI 模型。
125
79
 
126
- ## Using with npx
80
+ #### 前置要求
81
+ - GitHub 账户
82
+ - 有效的 Copilot 订阅(Individual / Business / Enterprise)
127
83
 
128
- You can run the project directly using npx:
84
+ #### 启动步骤
129
85
 
130
- ```sh
86
+ ```bash
131
87
  npx copilot-api-plus@latest start
132
88
  ```
133
89
 
134
- With options:
135
-
136
- ```sh
137
- npx copilot-api-plus@latest start --port 8080
138
- ```
139
-
140
- For authentication only:
141
-
142
- ```sh
143
- npx copilot-api-plus@latest auth
144
- ```
145
-
146
- ## Command Structure
147
-
148
- Copilot API Plus uses a subcommand structure with these main commands:
149
-
150
- - `start`: Start the Copilot API server. This command will also handle authentication if needed.
151
- - `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.
152
- - `check-usage`: Show your current GitHub Copilot usage and quota information directly in the terminal (no server required).
153
- - `debug`: Display diagnostic information including version, runtime details, file paths, and authentication status. Useful for troubleshooting and support.
154
- - `logout`: Clear stored GitHub token and logout. Use this to switch accounts or re-authenticate.
155
-
156
- ## Command Line Options
157
-
158
- ### Start Command Options
159
-
160
- The following command line options are available for the `start` command:
161
-
162
- | Option | Description | Default | Alias |
163
- | -------------- | ----------------------------------------------------------------------------- | ---------- | ----- |
164
- | --port | Port to listen on | 4141 | -p |
165
- | --verbose | Enable verbose logging | false | -v |
166
- | --account-type | Account type to use (individual, business, enterprise) | individual | -a |
167
- | --manual | Enable manual request approval | false | none |
168
- | --rate-limit | Rate limit in seconds between requests | none | -r |
169
- | --wait | Wait instead of error when rate limit is hit | false | -w |
170
- | --github-token | Provide GitHub token directly (must be generated using the `auth` subcommand) | none | -g |
171
- | --claude-code | Generate a command to launch Claude Code with Copilot API config | false | -c |
172
- | --show-token | Show GitHub and Copilot tokens on fetch and refresh | false | none |
173
- | --proxy-env | Initialize proxy from environment variables | false | none |
174
- | --zen | Enable OpenCode Zen mode (proxy to Zen instead of GitHub Copilot) | false | -z |
175
- | --zen-api-key | OpenCode Zen API key (get from https://opencode.ai/zen) | none | none |
176
-
177
- ### Auth Command Options
178
-
179
- | Option | Description | Default | Alias |
180
- | ------------ | ------------------------- | ------- | ----- |
181
- | --verbose | Enable verbose logging | false | -v |
182
- | --show-token | Show GitHub token on auth | false | none |
90
+ **首次运行**会引导你完成 GitHub OAuth 认证:
183
91
 
184
- ### Debug Command Options
92
+ 1. 终端显示设备码,例如:`XXXX-XXXX`
93
+ 2. 打开浏览器访问:https://github.com/login/device
94
+ 3. 输入设备码,点击授权
95
+ 4. 返回终端,等待认证完成
185
96
 
186
- | Option | Description | Default | Alias |
187
- | ------ | ------------------------- | ------- | ----- |
188
- | --json | Output debug info as JSON | false | none |
97
+ 认证成功后,Token 会保存到本地,下次启动无需重新认证。
189
98
 
190
- ## Proxy Configuration
99
+ #### 企业/商业账户
191
100
 
192
- If you are behind a corporate firewall or need to route traffic through a proxy server, you can configure the proxy using environment variables.
193
-
194
- ### Using the `--proxy-env` Flag
195
-
196
- Start the server with the `--proxy-env` flag to automatically read proxy settings from environment variables:
197
-
198
- ```sh
199
- # Set proxy environment variables first
200
- export HTTP_PROXY=http://your-proxy-server:8080
201
- export HTTPS_PROXY=http://your-proxy-server:8080
101
+ ```bash
102
+ # Business 计划
103
+ npx copilot-api-plus@latest start --account-type business
202
104
 
203
- # Start with proxy support
204
- npx copilot-api-plus@latest start --proxy-env
105
+ # Enterprise 计划
106
+ npx copilot-api-plus@latest start --account-type enterprise
205
107
  ```
206
108
 
207
- On Windows (PowerShell):
109
+ #### 可用模型
208
110
 
209
- ```powershell
210
- $env:HTTP_PROXY = "http://your-proxy-server:8080"
211
- $env:HTTPS_PROXY = "http://your-proxy-server:8080"
212
- npx copilot-api-plus@latest start --proxy-env
213
- ```
214
-
215
- On Windows (CMD):
111
+ | 模型 | ID | 上下文长度 |
112
+ |------|-----|-----------|
113
+ | Claude Sonnet 4 | `claude-sonnet-4` | 200K |
114
+ | Claude Sonnet 4.5 | `claude-sonnet-4.5` | 200K |
115
+ | GPT-4.1 | `gpt-4.1` | 1M |
116
+ | o4-mini | `o4-mini` | 200K |
117
+ | Gemini 2.5 Pro | `gemini-2.5-pro` | 1M |
216
118
 
217
- ```cmd
218
- set HTTP_PROXY=http://your-proxy-server:8080
219
- set HTTPS_PROXY=http://your-proxy-server:8080
220
- npx copilot-api-plus@latest start --proxy-env
221
- ```
119
+ ---
222
120
 
223
- ### Supported Proxy Environment Variables
121
+ ### 2. OpenCode Zen 模式
224
122
 
225
- | Variable | Description |
226
- | ------------- | ----------------------------------------- |
227
- | `HTTP_PROXY` | Proxy URL for HTTP connections |
228
- | `HTTPS_PROXY` | Proxy URL for HTTPS connections |
229
- | `http_proxy` | Alternative (lowercase) for HTTP proxy |
230
- | `https_proxy` | Alternative (lowercase) for HTTPS proxy |
231
- | `NO_PROXY` | Comma-separated list of hosts to bypass |
232
- | `no_proxy` | Alternative (lowercase) for no-proxy list |
123
+ 使用 [OpenCode Zen](https://opencode.ai/zen) 的多模型 API 服务。
233
124
 
234
- ### Proxy Authentication
125
+ #### 前置要求
126
+ 1. 访问 https://opencode.ai/zen
127
+ 2. 注册账号并创建 API Key
235
128
 
236
- If your proxy requires authentication, include the credentials in the URL:
129
+ #### 启动步骤
237
130
 
238
- ```sh
239
- export HTTPS_PROXY=http://username:password@your-proxy-server:8080
131
+ **方式一:交互式设置**
132
+ ```bash
133
+ npx copilot-api-plus@latest start --zen
240
134
  ```
135
+ 首次运行会提示输入 API Key,保存后下次自动使用。
241
136
 
242
- ### Docker with Proxy
243
-
244
- When running in Docker, pass the proxy environment variables:
245
-
246
- ```sh
247
- docker run -p 4141:4141 \
248
- -e HTTP_PROXY=http://your-proxy:8080 \
249
- -e HTTPS_PROXY=http://your-proxy:8080 \
250
- copilot-api-plus start --proxy-env
137
+ **方式二:直接指定 API Key**
138
+ ```bash
139
+ npx copilot-api-plus@latest start --zen --zen-api-key YOUR_API_KEY
251
140
  ```
252
141
 
253
- ## API Endpoints
142
+ #### 可用模型
254
143
 
255
- The server exposes several endpoints to interact with the Copilot API. It provides OpenAI-compatible endpoints and now also includes support for Anthropic-compatible endpoints, allowing for greater flexibility with different tools and services.
144
+ | 模型 | ID | 说明 |
145
+ |------|-----|------|
146
+ | Claude Sonnet 4.5 | `claude-sonnet-4-5` | Anthropic Claude (200K) |
147
+ | Claude Opus 4.5 | `claude-opus-4-5` | Anthropic Claude (200K) |
148
+ | GPT-5 Codex | `gpt-5-codex` | OpenAI Responses API |
149
+ | Gemini 3 Pro | `gemini-3-pro` | Google Gemini |
150
+ | Qwen3 Coder 480B | `qwen3-coder` | Alibaba Qwen |
151
+ | Kimi K2 | `kimi-k2` | Moonshot |
152
+ | Grok Code Fast 1 | `grok-code` | xAI |
256
153
 
257
- ### OpenAI Compatible Endpoints
154
+ 更多模型请访问 [opencode.ai/zen](https://opencode.ai/zen)
258
155
 
259
- These endpoints mimic the OpenAI API structure.
156
+ #### 管理 API Key
260
157
 
261
- | Endpoint | Method | Description |
262
- | --------------------------- | ------ | --------------------------------------------------------- |
263
- | `POST /v1/chat/completions` | `POST` | Creates a model response for the given chat conversation. |
264
- | `GET /v1/models` | `GET` | Lists the currently available models. |
265
- | `POST /v1/embeddings` | `POST` | Creates an embedding vector representing the input text. |
158
+ ```bash
159
+ # 查看/更换 API Key(清除后重新启动会提示输入)
160
+ npx copilot-api-plus@latest logout --zen
161
+ ```
266
162
 
267
- ### Anthropic Compatible Endpoints
163
+ ---
268
164
 
269
- These endpoints are designed to be compatible with the Anthropic Messages API.
165
+ ### 3. Google Antigravity 模式
270
166
 
271
- | Endpoint | Method | Description |
272
- | -------------------------------- | ------ | ------------------------------------------------------------ |
273
- | `POST /v1/messages` | `POST` | Creates a model response for a given conversation. |
274
- | `POST /v1/messages/count_tokens` | `POST` | Calculates the number of tokens for a given set of messages. |
167
+ 使用 Google Antigravity API 服务,支持 Gemini 和 Claude 模型。
275
168
 
276
- ### Usage Monitoring Endpoints
169
+ #### 前置要求
170
+ - Google 账户
277
171
 
278
- New endpoints for monitoring your Copilot usage and quotas.
172
+ #### 启动步骤
279
173
 
280
- | Endpoint | Method | Description |
281
- | ------------ | ------ | ------------------------------------------------------------ |
282
- | `GET /usage` | `GET` | Get detailed Copilot usage statistics and quota information. |
283
- | `GET /token` | `GET` | Get the current Copilot token being used by the API. |
174
+ ```bash
175
+ npx copilot-api-plus@latest start --antigravity
176
+ ```
284
177
 
285
- ## Example Usage
178
+ **首次运行**会引导你完成 Google OAuth 认证:
286
179
 
287
- Using with npx:
180
+ 1. 终端显示 Google 授权 URL
181
+ 2. 在浏览器中打开该 URL
182
+ 3. 使用 Google 账号登录并授权
183
+ 4. 授权成功后,浏览器会跳转到一个 `localhost:8046/callback?code=...` 的页面
184
+ 5. **复制浏览器地址栏中的完整 URL**
185
+ 6. 粘贴到终端,按回车完成认证
288
186
 
289
- ```sh
290
- # Basic usage with start command
291
- npx copilot-api-plus@latest start
187
+ #### 可用模型
292
188
 
293
- # Run on custom port with verbose logging
294
- npx copilot-api-plus@latest start --port 8080 --verbose
189
+ | 模型 | ID | 说明 |
190
+ |------|-----|------|
191
+ | Gemini 2.5 Pro | `gemini-2.5-pro-exp-03-25` | Google Gemini |
192
+ | Gemini 2.5 Pro Preview | `gemini-2.5-pro-preview-05-06` | Google Gemini |
193
+ | Gemini 2.0 Flash | `gemini-2.0-flash-exp` | 快速响应 |
194
+ | Gemini 2.0 Flash Thinking | `gemini-2.0-flash-thinking-exp` | 支持思考链 |
195
+ | Claude Opus 4.5 | `claude-opus-4-5` | Anthropic Claude |
196
+ | Claude Sonnet 4.5 | `claude-sonnet-4-5` | Anthropic Claude |
295
197
 
296
- # Use with a business plan GitHub account
297
- npx copilot-api-plus@latest start --account-type business
198
+ #### 特性
199
+ - 自动 Token 刷新
200
+ - ✅ 多账户支持,自动轮换
201
+ - ✅ 配额用尽自动切换账户
202
+ - ✅ 支持 Thinking 模型(思考链输出)
298
203
 
299
- # Use with an enterprise plan GitHub account
300
- npx copilot-api-plus@latest start --account-type enterprise
204
+ #### 多账户管理
301
205
 
302
- # Enable manual approval for each request
303
- npx copilot-api-plus@latest start --manual
206
+ 可以添加多个 Google 账户,系统会在配额用尽时自动切换:
304
207
 
305
- # Set rate limit to 30 seconds between requests
306
- npx copilot-api-plus@latest start --rate-limit 30
208
+ ```bash
209
+ # 添加新账户:重新运行启动命令,选择添加账户
210
+ npx copilot-api-plus@latest start --antigravity
307
211
 
308
- # Wait instead of error when rate limit is hit
309
- npx copilot-api-plus@latest start --rate-limit 30 --wait
212
+ # 清除所有账户
213
+ npx copilot-api-plus@latest logout --antigravity
214
+ ```
310
215
 
311
- # Provide GitHub token directly
312
- npx copilot-api-plus@latest start --github-token ghp_YOUR_TOKEN_HERE
216
+ ---
313
217
 
314
- # Run only the auth flow
315
- npx copilot-api-plus@latest auth
218
+ ## 🌐 代理配置
316
219
 
317
- # Run auth flow with verbose logging
318
- npx copilot-api-plus@latest auth --verbose
220
+ 如果你需要通过代理访问网络,有两种配置方式:
319
221
 
320
- # Show your Copilot usage/quota in the terminal (no server needed)
321
- npx copilot-api-plus@latest check-usage
222
+ ### 方式一:持久化配置(推荐)
322
223
 
323
- # Display debug information for troubleshooting
324
- npx copilot-api-plus@latest debug
224
+ 配置一次,永久生效,下次启动自动使用。
325
225
 
326
- # Display debug information in JSON format
327
- npx copilot-api-plus@latest debug --json
226
+ ```bash
227
+ # 交互式配置
228
+ npx copilot-api-plus@latest proxy --set
328
229
 
329
- # Logout and clear stored tokens (to switch accounts)
330
- npx copilot-api-plus@latest logout
230
+ # 或直接设置
231
+ npx copilot-api-plus@latest proxy --http-proxy http://127.0.0.1:7890
331
232
 
332
- # Initialize proxy from environment variables (HTTP_PROXY, HTTPS_PROXY, etc.)
333
- npx copilot-api-plus@latest start --proxy-env
233
+ # 同时设置 HTTP HTTPS 代理
234
+ npx copilot-api-plus@latest proxy --http-proxy http://127.0.0.1:7890 --https-proxy http://127.0.0.1:7890
334
235
  ```
335
236
 
336
- ## Using the Usage Viewer
337
-
338
- After starting the server, a URL to the Copilot Usage Dashboard will be displayed in your console. This dashboard is a web interface for monitoring your API usage.
339
-
340
- 1. Start the server. For example, using npx:
341
- ```sh
342
- npx copilot-api-plus@latest start
343
- ```
344
- 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:
345
- `https://imbuxiangnan-cyber.github.io/copilot-api-plus?endpoint=http://localhost:4141/usage`
346
- - If you use the `start.bat` script on Windows, this page will open automatically.
347
-
348
- The dashboard provides a user-friendly interface to view your Copilot usage data:
349
-
350
- - **API Endpoint URL**: The dashboard is pre-configured to fetch data from your local server endpoint via the URL query parameter. You can change this URL to point to any other compatible API endpoint.
351
- - **Fetch Data**: Click the "Fetch" button to load or refresh the usage data. The dashboard will automatically fetch data on load.
352
- - **Usage Quotas**: View a summary of your usage quotas for different services like Chat and Completions, displayed with progress bars for a quick overview.
353
- - **Detailed Information**: See the full JSON response from the API for a detailed breakdown of all available usage statistics.
354
- - **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:
355
- `https://imbuxiangnan-cyber.github.io/copilot-api-plus?endpoint=http://your-api-server/usage`
356
-
357
- ## Using with OpenCode Zen
358
-
237
+ #### 代理管理命令
359
238
 
360
- ### OpenCode Zen 使用指南
239
+ ```bash
240
+ # 查看当前代理配置
241
+ npx copilot-api-plus@latest proxy
361
242
 
362
- OpenCode Zen 是由 opencode.ai 提供的多模型 API 服务,支持 Claude、GPT-5、Gemini、Qwen 等主流大模型,适合代码生成、AI 助手等场景。Copilot API Plus 支持将 Zen 转换为 OpenAI/Anthropic 兼容 API,方便与 Claude Code、opencode 等工具无缝集成。
243
+ # 启用代理
244
+ npx copilot-api-plus@latest proxy --enable
363
245
 
364
- #### 1. 获取 Zen API Key
365
- 1. 访问 [https://opencode.ai/zen](https://opencode.ai/zen)
366
- 2. 注册并登录,进入“API Keys”页面,创建你的 API Key
246
+ # 禁用代理(保留设置)
247
+ npx copilot-api-plus@latest proxy --disable
367
248
 
368
- #### 2. 启动 Zen 模式
369
- 首次运行会自动提示输入 API Key,并保存到本地。也可直接指定:
370
- ```sh
371
- npx copilot-api-plus@latest start --zen --zen-api-key <你的APIKey>
372
- ```
373
- 或交互式:
374
- ```sh
375
- npx copilot-api-plus@latest start --zen
376
- ```
377
-
378
- #### 3. 与 Claude Code 配合
379
- Zen 支持多种 Claude 模型,推荐用法:
380
- ```sh
381
- npx copilot-api-plus@latest start --zen --claude-code
382
- ```
383
- 会自动生成 Claude Code 启动命令,支持模型选择。
384
-
385
- #### 4. 支持的模型(部分示例)
386
- | 名称 | ID | 说明 |
387
- |---------------------|----------------------|---------------------------|
388
- | Claude Sonnet 4.5 | claude-sonnet-4-5 | Anthropic Claude 200K |
389
- | Claude Opus 4.5 | claude-opus-4-5 | Anthropic Claude 200K |
390
- | GPT-5 Codex | gpt-5-codex | OpenAI Responses API |
391
- | Gemini 3 Pro | gemini-3-pro | Google Gemini |
392
- | Qwen3 Coder 480B | qwen3-coder | Alibaba Qwen |
393
- | Kimi K2 | kimi-k2 | Moonshot |
394
- | Grok Code Fast 1 | grok-code | xAI |
395
- 更多模型请见 [Zen 官网](https://opencode.ai/zen)。
396
-
397
- #### 5. API 路径
398
- Zen 模式下,所有 OpenAI/Anthropic 兼容路径均可用:
399
- - `POST /v1/chat/completions` (OpenAI 格式)
400
- - `POST /v1/messages` (Anthropic 格式)
401
- - `GET /v1/models` (模型列表)
402
- Zen 专属路径(始终可用):
403
- - `POST /zen/v1/chat/completions`
404
- - `POST /zen/v1/messages`
405
- - `GET /zen/v1/models`
406
-
407
- #### 6. 常见问题
408
- - **API Key 存储位置**:`~/.local/share/copilot-api-plus/zen-auth.json`
409
- - **切换/清除 API Key**:
410
- - 只清除 Zen:`npx copilot-api-plus@latest logout --zen`
411
- - 全部清除:`npx copilot-api-plus@latest logout --all`
412
- - **模型选择**:启动时会自动显示可用模型列表
413
- - **与 opencode 配合**:在 `opencode.json` 里设置 `baseURL` 为 `http://127.0.0.1:4141/v1`,或用环境变量 `OPENAI_BASE_URL`
414
-
415
- #### 7. 使用技巧
416
- - 推荐用 `--claude-code` 生成 Claude Code 启动命令
417
- - 支持所有 Zen 公开模型,按需选择
418
- - 支持 Docker 部署,API Key 持久化
419
-
420
- 如需详细配置示例、opencode 配置、更多高级用法,请继续阅读下方文档。
421
-
422
- ### Why Use Zen Mode?
423
-
424
- - **Access to many models**: Claude Sonnet 4.5, Claude Opus 4.5, GPT-5 Codex, Gemini 3 Pro, Qwen3 Coder, and more
425
- - **Transparent pricing**: Pay per request with zero markups
426
- - **Tested & verified**: All models are tested by the OpenCode team for coding tasks
427
- - **Single API key**: One key for all Zen models
428
-
429
- ### Getting Started with Zen
430
-
431
- 1. **Get your API key**: Go to [opencode.ai/zen](https://opencode.ai/zen), sign up, and create an API key.
432
-
433
- 2. **Start the server in Zen mode**:
434
- ```sh
435
- npx copilot-api-plus@latest start --zen
436
- ```
437
-
438
- You will be prompted to enter your Zen API key on first run. The key will be saved for future use.
439
-
440
- 3. **Or provide the API key directly**:
441
- ```sh
442
- npx copilot-api-plus@latest start --zen --zen-api-key your_api_key_here
443
- ```
444
-
445
- ### Using Zen with Claude Code
446
-
447
- Start the server with both `--zen` and `--claude-code` flags:
448
-
449
- ```sh
450
- npx copilot-api-plus@latest start --zen --claude-code
249
+ # 清除代理配置
250
+ npx copilot-api-plus@latest proxy --clear
451
251
  ```
452
252
 
453
- This will:
454
- 1. Connect to OpenCode Zen instead of GitHub Copilot
455
- 2. Show you available Zen models to choose from
456
- 3. Generate a command to launch Claude Code with the selected model
253
+ #### 示例:配置 Clash 代理
457
254
 
458
- ### Available Zen Models
255
+ ```bash
256
+ # Clash 默认端口 7890
257
+ npx copilot-api-plus@latest proxy --http-proxy http://127.0.0.1:7890
459
258
 
460
- When using Zen mode, you can access models like:
461
-
462
- | Model | ID | Description |
463
- | ------------------ | ----------------- | ------------------------------ |
464
- | Claude Sonnet 4.5 | claude-sonnet-4-5 | Anthropic Claude (200K context)|
465
- | Claude Opus 4.5 | claude-opus-4-5 | Anthropic Claude (200K context)|
466
- | GPT 5 Codex | gpt-5-codex | OpenAI (Responses API) |
467
- | Gemini 3 Pro | gemini-3-pro | Google Gemini |
468
- | Qwen3 Coder 480B | qwen3-coder | Alibaba Qwen |
469
- | Kimi K2 | kimi-k2 | Moonshot |
470
- | Grok Code Fast 1 | grok-code | xAI |
259
+ # 验证配置
260
+ npx copilot-api-plus@latest proxy
261
+ # 输出:
262
+ # Current proxy configuration:
263
+ # Status: Enabled
264
+ # HTTP_PROXY: http://127.0.0.1:7890
265
+ # HTTPS_PROXY: http://127.0.0.1:7890
266
+ ```
471
267
 
472
- For the full list, visit [opencode.ai/zen](https://opencode.ai/zen).
268
+ ### 方式二:环境变量(临时)
473
269
 
474
- ### Zen API Endpoints
270
+ 仅当次启动生效:
475
271
 
476
- The server exposes the same endpoints in Zen mode:
272
+ ```bash
273
+ # Linux/macOS
274
+ export HTTP_PROXY=http://127.0.0.1:7890
275
+ export HTTPS_PROXY=http://127.0.0.1:7890
276
+ npx copilot-api-plus@latest start --proxy-env
477
277
 
478
- | Endpoint | Description |
479
- | --------------------------- | ------------------------------------ |
480
- | `POST /v1/chat/completions` | OpenAI-compatible chat completions |
481
- | `POST /v1/messages` | Anthropic-compatible messages |
482
- | `GET /v1/models` | List available Zen models |
278
+ # Windows PowerShell
279
+ $env:HTTP_PROXY = "http://127.0.0.1:7890"
280
+ $env:HTTPS_PROXY = "http://127.0.0.1:7890"
281
+ npx copilot-api-plus@latest start --proxy-env
483
282
 
484
- You can also access dedicated Zen routes (always available):
283
+ # Windows CMD
284
+ set HTTP_PROXY=http://127.0.0.1:7890
285
+ set HTTPS_PROXY=http://127.0.0.1:7890
286
+ npx copilot-api-plus@latest start --proxy-env
287
+ ```
485
288
 
486
- | Endpoint | Description |
487
- | -------------------------------- | ------------------------ |
488
- | `POST /zen/v1/chat/completions` | Zen chat completions |
489
- | `POST /zen/v1/messages` | Zen messages |
490
- | `GET /zen/v1/models` | Zen models |
289
+ ### 代理配置优先级
491
290
 
492
- ## Using with Claude Code
291
+ 1. `--proxy-env` 参数(从环境变量读取)
292
+ 2. 持久化配置(`proxy --set` 设置的)
293
+ 3. 无代理
493
294
 
494
- This proxy can be used to power [Claude Code](https://docs.anthropic.com/en/claude-code), an experimental conversational AI assistant for developers from Anthropic.
295
+ ---
495
296
 
496
- There are two ways to configure Claude Code to use this proxy:
297
+ ## 💻 Claude Code 集成
497
298
 
498
- ### Interactive Setup with `--claude-code` flag
299
+ [Claude Code](https://docs.anthropic.com/en/docs/claude-code/overview) 是 Anthropic 的 AI 编程助手。
499
300
 
500
- To get started, run the `start` command with the `--claude-code` flag:
301
+ ### 自动配置(推荐)
501
302
 
502
- ```sh
303
+ ```bash
304
+ # 使用 GitHub Copilot 作为后端
503
305
  npx copilot-api-plus@latest start --claude-code
504
- ```
505
306
 
506
- You will be prompted to select a primary model and a "small, fast" model for background tasks. After selecting the models, a command will be copied to your clipboard. This command sets the necessary environment variables for Claude Code to use the proxy.
307
+ # 使用 OpenCode Zen 作为后端
308
+ npx copilot-api-plus@latest start --zen --claude-code
507
309
 
508
- Paste and run this command in a new terminal to launch Claude Code.
310
+ # 使用 Google Antigravity 作为后端
311
+ npx copilot-api-plus@latest start --antigravity --claude-code
312
+ ```
509
313
 
510
- ### Manual Configuration with `settings.json`
314
+ 运行后:
315
+ 1. 选择主模型(用于代码生成)
316
+ 2. 选择快速模型(用于后台任务)
317
+ 3. 启动命令会自动复制到剪贴板
318
+ 4. **打开新终端**,粘贴并运行命令启动 Claude Code
511
319
 
512
- Alternatively, you can configure Claude Code by creating a `.claude/settings.json` file in your project's root directory. This file should contain the environment variables needed by Claude Code. This way you don't need to run the interactive setup every time.
320
+ ### 手动配置
513
321
 
514
- Here is an example `.claude/settings.json` file:
322
+ 在项目根目录创建 `.claude/settings.json`:
515
323
 
516
324
  ```json
517
325
  {
518
326
  "env": {
519
327
  "ANTHROPIC_BASE_URL": "http://localhost:4141",
520
328
  "ANTHROPIC_AUTH_TOKEN": "dummy",
521
- "ANTHROPIC_MODEL": "gpt-4.1",
522
- "ANTHROPIC_DEFAULT_SONNET_MODEL": "gpt-4.1",
329
+ "ANTHROPIC_MODEL": "claude-sonnet-4",
523
330
  "ANTHROPIC_SMALL_FAST_MODEL": "gpt-4.1",
524
- "ANTHROPIC_DEFAULT_HAIKU_MODEL": "gpt-4.1",
525
- "DISABLE_NON_ESSENTIAL_MODEL_CALLS": "1",
526
- "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
527
- },
528
- "permissions": {
529
- "deny": [
530
- "WebSearch"
531
- ]
331
+ "DISABLE_NON_ESSENTIAL_MODEL_CALLS": "1"
532
332
  }
533
333
  }
534
334
  ```
535
335
 
536
- You can find more options here: [Claude Code settings](https://docs.anthropic.com/en/docs/claude-code/settings#environment-variables)
336
+ 然后启动 copilot-api-plus 服务器后,在该项目目录运行 `claude` 命令。
537
337
 
538
- 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)
338
+ ---
539
339
 
540
- ## Using with opencode
340
+ ## 🔧 opencode 集成
541
341
 
542
- [opencode](https://github.com/sst/opencode) is a modern AI coding assistant that supports multiple providers. You can use copilot-api-plus as a custom provider for opencode.
342
+ [opencode](https://github.com/sst/opencode) 是一个现代 AI 编程助手。
543
343
 
544
- ### Configuration
344
+ ### 配置步骤
545
345
 
546
- Create or edit `opencode.json` in your project root directory:
346
+ 1. 在项目根目录创建 `opencode.json`:
547
347
 
548
348
  ```json
549
349
  {
@@ -560,56 +360,15 @@ Create or edit `opencode.json` in your project root directory:
560
360
  "name": "Claude Sonnet 4",
561
361
  "id": "claude-sonnet-4",
562
362
  "max_tokens": 64000,
563
- "default_tokens": 16000,
564
- "profile": "coder",
565
- "attachment": true,
566
- "limit": {
567
- "context": 200000
568
- }
569
- },
570
- "claude-sonnet-4.5": {
571
- "name": "Claude Sonnet 4.5",
572
- "id": "claude-sonnet-4.5",
573
- "max_tokens": 64000,
574
- "default_tokens": 16000,
575
363
  "profile": "coder",
576
- "attachment": true,
577
- "limit": {
578
- "context": 200000
579
- }
364
+ "limit": { "context": 200000 }
580
365
  },
581
366
  "gpt-4.1": {
582
367
  "name": "GPT-4.1",
583
368
  "id": "gpt-4.1",
584
369
  "max_tokens": 32768,
585
- "default_tokens": 16000,
586
- "profile": "coder",
587
- "attachment": true,
588
- "limit": {
589
- "context": 1047576
590
- }
591
- },
592
- "o4-mini": {
593
- "name": "o4-mini",
594
- "id": "o4-mini",
595
- "max_tokens": 100000,
596
- "default_tokens": 16000,
597
370
  "profile": "coder",
598
- "attachment": true,
599
- "limit": {
600
- "context": 200000
601
- }
602
- },
603
- "gemini-2.5-pro": {
604
- "name": "Gemini 2.5 Pro",
605
- "id": "gemini-2.5-pro",
606
- "max_tokens": 65536,
607
- "default_tokens": 16000,
608
- "profile": "coder",
609
- "attachment": true,
610
- "limit": {
611
- "context": 1048576
612
- }
371
+ "limit": { "context": 1047576 }
613
372
  }
614
373
  }
615
374
  }
@@ -617,65 +376,281 @@ Create or edit `opencode.json` in your project root directory:
617
376
  }
618
377
  ```
619
378
 
620
- ### Usage
379
+ 2. 启动 copilot-api-plus:
380
+ ```bash
381
+ npx copilot-api-plus@latest start
382
+ ```
621
383
 
622
- 1. Start copilot-api-plus:
623
- ```sh
624
- npx copilot-api-plus@latest start --proxy-env
625
- ```
384
+ 3. 在同一目录运行 opencode:
385
+ ```bash
386
+ npx opencode@latest
387
+ ```
626
388
 
627
- 2. Run opencode in the same project directory:
628
- ```sh
629
- npx opencode@latest
630
- ```
389
+ 4. 选择 `copilot-api-plus` 作为 provider
631
390
 
632
- 3. Select `copilot-api-plus` as your provider when prompted, or use the model switcher to change providers.
391
+ ### 快捷方式:使用环境变量
633
392
 
634
- ### Available Models
393
+ ```bash
394
+ # 设置环境变量
395
+ export OPENAI_BASE_URL=http://127.0.0.1:4141/v1
396
+ export OPENAI_API_KEY=dummy
635
397
 
636
- When using copilot-api-plus with opencode, you can access all GitHub Copilot models:
398
+ # 运行 opencode
399
+ npx opencode@latest
400
+ ```
637
401
 
638
- | Model | Description |
639
- | ----------------- | ------------------------------------ |
640
- | `claude-sonnet-4` | Claude Sonnet 4 (200K context) |
641
- | `claude-sonnet-4.5` | Claude Sonnet 4.5 (200K context) |
642
- | `gpt-4.1` | GPT-4.1 (1M context) |
643
- | `o4-mini` | OpenAI o4-mini reasoning model |
644
- | `gemini-2.5-pro` | Google Gemini 2.5 Pro (1M context) |
402
+ ---
645
403
 
646
- ### Environment Variables for opencode
404
+ ## 📡 API 端点
647
405
 
648
- If you prefer not to create a config file, you can also set environment variables:
406
+ 服务器启动后,默认监听 `http://localhost:4141`。
649
407
 
650
- ```sh
651
- # Set the base URL for opencode to use
652
- export OPENAI_BASE_URL=http://127.0.0.1:4141/v1
653
- export OPENAI_API_KEY=dummy
408
+ ### OpenAI 兼容端点
654
409
 
655
- # Start opencode
656
- npx opencode@latest
410
+ | 端点 | 方法 | 说明 |
411
+ |------|------|------|
412
+ | `/v1/chat/completions` | POST | 聊天补全(支持流式) |
413
+ | `/v1/models` | GET | 模型列表 |
414
+ | `/v1/embeddings` | POST | 文本嵌入(仅 Copilot) |
415
+
416
+ ### Anthropic 兼容端点
417
+
418
+ | 端点 | 方法 | 说明 |
419
+ |------|------|------|
420
+ | `/v1/messages` | POST | 消息 API(支持流式) |
421
+ | `/v1/messages/count_tokens` | POST | Token 计数 |
422
+
423
+ ### 专用端点
424
+
425
+ 各后端都有独立的专用路由,即使切换默认后端也能访问:
426
+
427
+ | 路由前缀 | 说明 |
428
+ |----------|------|
429
+ | `/copilot/v1/*` | GitHub Copilot 专用 |
430
+ | `/zen/v1/*` | OpenCode Zen 专用 |
431
+ | `/antigravity/v1/*` | Google Antigravity 专用 |
432
+
433
+ ### 监控端点
434
+
435
+ | 端点 | 方法 | 说明 |
436
+ |------|------|------|
437
+ | `/usage` | GET | 使用量统计(仅 Copilot) |
438
+ | `/token` | GET | 当前 Token 信息 |
439
+
440
+ ### 调用示例
441
+
442
+ ```bash
443
+ # OpenAI 格式
444
+ curl http://localhost:4141/v1/chat/completions \
445
+ -H "Content-Type: application/json" \
446
+ -d '{
447
+ "model": "claude-sonnet-4",
448
+ "messages": [{"role": "user", "content": "Hello!"}]
449
+ }'
450
+
451
+ # Anthropic 格式
452
+ curl http://localhost:4141/v1/messages \
453
+ -H "Content-Type: application/json" \
454
+ -H "x-api-key: dummy" \
455
+ -d '{
456
+ "model": "claude-sonnet-4",
457
+ "max_tokens": 1024,
458
+ "messages": [{"role": "user", "content": "Hello!"}]
459
+ }'
657
460
  ```
658
461
 
659
- ## Running from Source
462
+ ---
463
+
464
+ ## ⚙️ 命令行参考
465
+
466
+ ### 命令列表
467
+
468
+ | 命令 | 说明 |
469
+ |------|------|
470
+ | `start` | 启动 API 服务器 |
471
+ | `auth` | 仅执行 GitHub 认证流程 |
472
+ | `logout` | 清除已保存的凭证 |
473
+ | `proxy` | 配置代理设置 |
474
+ | `check-usage` | 查看 Copilot 使用量 |
475
+ | `debug` | 显示调试信息 |
476
+
477
+ ### start 命令参数
478
+
479
+ | 参数 | 别名 | 默认值 | 说明 |
480
+ |------|------|--------|------|
481
+ | `--port` | `-p` | 4141 | 监听端口 |
482
+ | `--verbose` | `-v` | false | 详细日志 |
483
+ | `--account-type` | `-a` | individual | 账户类型 (individual/business/enterprise) |
484
+ | `--claude-code` | `-c` | false | 生成 Claude Code 启动命令 |
485
+ | `--zen` | `-z` | false | 启用 OpenCode Zen 模式 |
486
+ | `--zen-api-key` | - | - | Zen API Key |
487
+ | `--antigravity` | - | false | 启用 Google Antigravity 模式 |
488
+ | `--rate-limit` | `-r` | - | 请求间隔(秒) |
489
+ | `--wait` | `-w` | false | 达到限制时等待而非报错 |
490
+ | `--manual` | - | false | 手动审批每个请求 |
491
+ | `--github-token` | `-g` | - | 直接提供 GitHub Token |
492
+ | `--show-token` | - | false | 显示 Token 信息 |
493
+ | `--proxy-env` | - | false | 从环境变量读取代理 |
494
+
495
+ ### proxy 命令参数
496
+
497
+ | 参数 | 说明 |
498
+ |------|------|
499
+ | `--set` | 交互式配置代理 |
500
+ | `--enable` | 启用已保存的代理 |
501
+ | `--disable` | 禁用代理(保留设置) |
502
+ | `--clear` | 清除代理配置 |
503
+ | `--show` | 显示当前配置 |
504
+ | `--http-proxy` | HTTP 代理 URL |
505
+ | `--https-proxy` | HTTPS 代理 URL |
506
+ | `--no-proxy` | 不走代理的主机列表 |
507
+
508
+ ### logout 命令参数
509
+
510
+ | 参数 | 说明 |
511
+ |------|------|
512
+ | `--zen` | 仅清除 Zen 凭证 |
513
+ | `--antigravity` | 仅清除 Antigravity 凭证 |
514
+ | `--all` | 清除所有凭证 |
515
+
516
+ ---
660
517
 
661
- The project can be run from source in several ways:
518
+ ## 🐳 Docker 部署
662
519
 
663
- ### Development Mode
520
+ ### 快速启动
664
521
 
665
- ```sh
666
- bun run dev
522
+ ```bash
523
+ # 使用预构建镜像
524
+ docker run -p 4141:4141 \
525
+ -v ./copilot-data:/root/.local/share/copilot-api-plus \
526
+ ghcr.io/imbuxiangnan-cyber/copilot-api-plus
667
527
  ```
668
528
 
669
- ### Production Mode
529
+ ### 自行构建
530
+
531
+ ```bash
532
+ # 构建镜像
533
+ docker build -t copilot-api-plus .
670
534
 
671
- ```sh
672
- bun run start
535
+ # 运行容器
536
+ docker run -p 4141:4141 \
537
+ -v ./copilot-data:/root/.local/share/copilot-api-plus \
538
+ copilot-api-plus
673
539
  ```
674
540
 
675
- ## Usage Tips
541
+ ### Docker Compose
542
+
543
+ ```yaml
544
+ version: "3.8"
545
+ services:
546
+ copilot-api-plus:
547
+ build: .
548
+ ports:
549
+ - "4141:4141"
550
+ volumes:
551
+ - ./copilot-data:/root/.local/share/copilot-api-plus
552
+ environment:
553
+ - GH_TOKEN=your_github_token # 可选
554
+ restart: unless-stopped
555
+ ```
556
+
557
+ ### 使用代理
558
+
559
+ ```bash
560
+ docker run -p 4141:4141 \
561
+ -e HTTP_PROXY=http://host.docker.internal:7890 \
562
+ -e HTTPS_PROXY=http://host.docker.internal:7890 \
563
+ -v ./copilot-data:/root/.local/share/copilot-api-plus \
564
+ copilot-api-plus start --proxy-env
565
+ ```
566
+
567
+ ---
568
+
569
+ ## ❓ 常见问题
570
+
571
+ ### 数据存储位置
572
+
573
+ 所有数据存储在 `~/.local/share/copilot-api-plus/` 目录下:
574
+
575
+ | 文件 | 说明 |
576
+ |------|------|
577
+ | `github_token` | GitHub Token |
578
+ | `zen-auth.json` | Zen API Key |
579
+ | `antigravity-accounts.json` | Antigravity 账户 |
580
+ | `config.json` | 代理等配置 |
581
+
582
+ ### 切换账户
583
+
584
+ ```bash
585
+ # 清除 GitHub 凭证
586
+ npx copilot-api-plus@latest logout
587
+
588
+ # 清除 Zen 凭证
589
+ npx copilot-api-plus@latest logout --zen
590
+
591
+ # 清除 Antigravity 凭证
592
+ npx copilot-api-plus@latest logout --antigravity
593
+
594
+ # 清除所有凭证
595
+ npx copilot-api-plus@latest logout --all
596
+ ```
597
+
598
+ ### 查看使用量
599
+
600
+ ```bash
601
+ # 命令行查看(仅 Copilot)
602
+ npx copilot-api-plus@latest check-usage
603
+ ```
604
+
605
+ 启动服务器后,也可以访问 Web 仪表盘:
606
+ ```
607
+ https://imbuxiangnan-cyber.github.io/copilot-api-plus?endpoint=http://localhost:4141/usage
608
+ ```
609
+
610
+ ### 调试问题
611
+
612
+ ```bash
613
+ # 显示调试信息
614
+ npx copilot-api-plus@latest debug
615
+
616
+ # JSON 格式输出
617
+ npx copilot-api-plus@latest debug --json
618
+
619
+ # 启用详细日志
620
+ npx copilot-api-plus@latest start --verbose
621
+ ```
622
+
623
+ ### 速率限制
624
+
625
+ 避免触发 GitHub 的滥用检测:
626
+
627
+ ```bash
628
+ # 设置请求间隔 30 秒
629
+ npx copilot-api-plus@latest start --rate-limit 30
630
+
631
+ # 达到限制时等待而非报错
632
+ npx copilot-api-plus@latest start --rate-limit 30 --wait
633
+
634
+ # 手动审批每个请求
635
+ npx copilot-api-plus@latest start --manual
636
+ ```
637
+
638
+ ---
639
+
640
+ ## ⚠️ 免责声明
641
+
642
+ > [!WARNING]
643
+ > 这是 GitHub Copilot API 的逆向工程代理。**不受 GitHub 官方支持**,可能随时失效。使用风险自负。
644
+
645
+ > [!WARNING]
646
+ > **GitHub 安全提示**:过度的自动化或脚本化使用 Copilot 可能触发 GitHub 的滥用检测系统,导致 Copilot 访问被暂停。请负责任地使用。
647
+ >
648
+ > 相关政策:
649
+ > - [GitHub 可接受使用政策](https://docs.github.com/site-policy/acceptable-use-policies/github-acceptable-use-policies)
650
+ > - [GitHub Copilot 条款](https://docs.github.com/site-policy/github-terms/github-terms-for-additional-products-and-features#github-copilot)
651
+
652
+ ---
653
+
654
+ ## 📄 许可证
676
655
 
677
- - To avoid hitting GitHub Copilot's rate limits, you can use the following flags:
678
- - `--manual`: Enables manual approval for each request, giving you full control over when requests are sent.
679
- - `--rate-limit <seconds>`: Enforces a minimum time interval between requests. For example, `copilot-api start --rate-limit 30` will ensure there's at least a 30-second gap between requests.
680
- - `--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.
681
- - 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.
656
+ MIT License