copilot-api-plus 1.0.9 → 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 +476 -579
- package/dist/main.js +238 -1
- package/dist/main.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,759 +1,656 @@
|
|
|
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
|
-
|
|
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
|
-
##
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
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
|
-
##
|
|
40
|
-
|
|
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).
|
|
27
|
+
## ✨ 功能特点
|
|
42
28
|
|
|
43
|
-
|
|
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 部署方案 |
|
|
44
39
|
|
|
45
|
-
|
|
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
|
-
|
|
57
|
-
- GitHub account with Copilot subscription (individual, business, or enterprise)
|
|
42
|
+
## 🚀 快速开始
|
|
58
43
|
|
|
59
|
-
|
|
44
|
+
### 安装
|
|
60
45
|
|
|
61
|
-
|
|
46
|
+
```bash
|
|
47
|
+
# 全局安装
|
|
48
|
+
npm install -g copilot-api-plus
|
|
62
49
|
|
|
63
|
-
|
|
64
|
-
|
|
50
|
+
# 或使用 npx 直接运行(推荐)
|
|
51
|
+
npx copilot-api-plus@latest start
|
|
65
52
|
```
|
|
66
53
|
|
|
67
|
-
|
|
54
|
+
### 基本用法
|
|
68
55
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
mkdir -p ./copilot-data
|
|
60
|
+
# 使用 OpenCode Zen
|
|
61
|
+
npx copilot-api-plus@latest start --zen
|
|
80
62
|
|
|
81
|
-
#
|
|
82
|
-
|
|
63
|
+
# 使用 Google Antigravity
|
|
64
|
+
npx copilot-api-plus@latest start --antigravity
|
|
83
65
|
|
|
84
|
-
|
|
66
|
+
# 与 Claude Code 配合
|
|
67
|
+
npx copilot-api-plus@latest start --claude-code
|
|
85
68
|
```
|
|
86
69
|
|
|
87
|
-
|
|
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.
|
|
70
|
+
服务器启动后,默认监听 `http://localhost:4141`。
|
|
89
71
|
|
|
90
|
-
|
|
72
|
+
---
|
|
91
73
|
|
|
92
|
-
|
|
74
|
+
## 📖 详细使用指南
|
|
93
75
|
|
|
94
|
-
|
|
95
|
-
# Build with GitHub token
|
|
96
|
-
docker build --build-arg GH_TOKEN=your_github_token_here -t copilot-api-plus .
|
|
76
|
+
### 1. GitHub Copilot 模式(默认)
|
|
97
77
|
|
|
98
|
-
|
|
99
|
-
docker run -p 4141:4141 -e GH_TOKEN=your_github_token_here copilot-api-plus
|
|
78
|
+
使用你的 GitHub Copilot 订阅访问 AI 模型。
|
|
100
79
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
80
|
+
#### 前置要求
|
|
81
|
+
- GitHub 账户
|
|
82
|
+
- 有效的 Copilot 订阅(Individual / Business / Enterprise)
|
|
104
83
|
|
|
105
|
-
|
|
84
|
+
#### 启动步骤
|
|
106
85
|
|
|
107
|
-
```
|
|
108
|
-
|
|
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
|
|
86
|
+
```bash
|
|
87
|
+
npx copilot-api-plus@latest start
|
|
117
88
|
```
|
|
118
89
|
|
|
119
|
-
|
|
90
|
+
**首次运行**会引导你完成 GitHub OAuth 认证:
|
|
120
91
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
92
|
+
1. 终端显示设备码,例如:`XXXX-XXXX`
|
|
93
|
+
2. 打开浏览器访问:https://github.com/login/device
|
|
94
|
+
3. 输入设备码,点击授权
|
|
95
|
+
4. 返回终端,等待认证完成
|
|
125
96
|
|
|
126
|
-
|
|
97
|
+
认证成功后,Token 会保存到本地,下次启动无需重新认证。
|
|
127
98
|
|
|
128
|
-
|
|
99
|
+
#### 企业/商业账户
|
|
129
100
|
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
With options:
|
|
101
|
+
```bash
|
|
102
|
+
# Business 计划
|
|
103
|
+
npx copilot-api-plus@latest start --account-type business
|
|
135
104
|
|
|
136
|
-
|
|
137
|
-
npx copilot-api-plus@latest start --
|
|
105
|
+
# Enterprise 计划
|
|
106
|
+
npx copilot-api-plus@latest start --account-type enterprise
|
|
138
107
|
```
|
|
139
108
|
|
|
140
|
-
|
|
109
|
+
#### 可用模型
|
|
141
110
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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 |
|
|
145
118
|
|
|
146
|
-
|
|
119
|
+
---
|
|
147
120
|
|
|
148
|
-
|
|
121
|
+
### 2. OpenCode Zen 模式
|
|
149
122
|
|
|
150
|
-
|
|
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.
|
|
123
|
+
使用 [OpenCode Zen](https://opencode.ai/zen) 的多模型 API 服务。
|
|
155
124
|
|
|
156
|
-
|
|
125
|
+
#### 前置要求
|
|
126
|
+
1. 访问 https://opencode.ai/zen
|
|
127
|
+
2. 注册账号并创建 API Key
|
|
157
128
|
|
|
158
|
-
|
|
129
|
+
#### 启动步骤
|
|
159
130
|
|
|
160
|
-
|
|
131
|
+
**方式一:交互式设置**
|
|
132
|
+
```bash
|
|
133
|
+
npx copilot-api-plus@latest start --zen
|
|
134
|
+
```
|
|
135
|
+
首次运行会提示输入 API Key,保存后下次自动使用。
|
|
161
136
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
| --antigravity | Enable Google Antigravity mode (proxy to Antigravity) | false | none |
|
|
137
|
+
**方式二:直接指定 API Key**
|
|
138
|
+
```bash
|
|
139
|
+
npx copilot-api-plus@latest start --zen --zen-api-key YOUR_API_KEY
|
|
140
|
+
```
|
|
177
141
|
|
|
178
|
-
|
|
142
|
+
#### 可用模型
|
|
179
143
|
|
|
180
|
-
|
|
|
181
|
-
|
|
182
|
-
|
|
|
183
|
-
|
|
|
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 |
|
|
184
153
|
|
|
185
|
-
|
|
154
|
+
更多模型请访问 [opencode.ai/zen](https://opencode.ai/zen)
|
|
186
155
|
|
|
187
|
-
|
|
188
|
-
| ------ | ------------------------- | ------- | ----- |
|
|
189
|
-
| --json | Output debug info as JSON | false | none |
|
|
156
|
+
#### 管理 API Key
|
|
190
157
|
|
|
191
|
-
|
|
158
|
+
```bash
|
|
159
|
+
# 查看/更换 API Key(清除后重新启动会提示输入)
|
|
160
|
+
npx copilot-api-plus@latest logout --zen
|
|
161
|
+
```
|
|
192
162
|
|
|
193
|
-
|
|
163
|
+
---
|
|
194
164
|
|
|
195
|
-
###
|
|
165
|
+
### 3. Google Antigravity 模式
|
|
196
166
|
|
|
197
|
-
|
|
167
|
+
使用 Google Antigravity API 服务,支持 Gemini 和 Claude 模型。
|
|
198
168
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
export HTTP_PROXY=http://your-proxy-server:8080
|
|
202
|
-
export HTTPS_PROXY=http://your-proxy-server:8080
|
|
169
|
+
#### 前置要求
|
|
170
|
+
- Google 账户
|
|
203
171
|
|
|
204
|
-
|
|
205
|
-
|
|
172
|
+
#### 启动步骤
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
npx copilot-api-plus@latest start --antigravity
|
|
206
176
|
```
|
|
207
177
|
|
|
208
|
-
|
|
178
|
+
**首次运行**会引导你完成 Google OAuth 认证:
|
|
209
179
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
180
|
+
1. 终端显示 Google 授权 URL
|
|
181
|
+
2. 在浏览器中打开该 URL
|
|
182
|
+
3. 使用 Google 账号登录并授权
|
|
183
|
+
4. 授权成功后,浏览器会跳转到一个 `localhost:8046/callback?code=...` 的页面
|
|
184
|
+
5. **复制浏览器地址栏中的完整 URL**
|
|
185
|
+
6. 粘贴到终端,按回车完成认证
|
|
215
186
|
|
|
216
|
-
|
|
187
|
+
#### 可用模型
|
|
217
188
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
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 |
|
|
223
197
|
|
|
224
|
-
|
|
198
|
+
#### 特性
|
|
199
|
+
- ✅ 自动 Token 刷新
|
|
200
|
+
- ✅ 多账户支持,自动轮换
|
|
201
|
+
- ✅ 配额用尽自动切换账户
|
|
202
|
+
- ✅ 支持 Thinking 模型(思考链输出)
|
|
225
203
|
|
|
226
|
-
|
|
227
|
-
| ------------- | ----------------------------------------- |
|
|
228
|
-
| `HTTP_PROXY` | Proxy URL for HTTP connections |
|
|
229
|
-
| `HTTPS_PROXY` | Proxy URL for HTTPS connections |
|
|
230
|
-
| `http_proxy` | Alternative (lowercase) for HTTP proxy |
|
|
231
|
-
| `https_proxy` | Alternative (lowercase) for HTTPS proxy |
|
|
232
|
-
| `NO_PROXY` | Comma-separated list of hosts to bypass |
|
|
233
|
-
| `no_proxy` | Alternative (lowercase) for no-proxy list |
|
|
204
|
+
#### 多账户管理
|
|
234
205
|
|
|
235
|
-
|
|
206
|
+
可以添加多个 Google 账户,系统会在配额用尽时自动切换:
|
|
236
207
|
|
|
237
|
-
|
|
208
|
+
```bash
|
|
209
|
+
# 添加新账户:重新运行启动命令,选择添加账户
|
|
210
|
+
npx copilot-api-plus@latest start --antigravity
|
|
238
211
|
|
|
239
|
-
|
|
240
|
-
|
|
212
|
+
# 清除所有账户
|
|
213
|
+
npx copilot-api-plus@latest logout --antigravity
|
|
241
214
|
```
|
|
242
215
|
|
|
243
|
-
|
|
216
|
+
---
|
|
244
217
|
|
|
245
|
-
|
|
218
|
+
## 🌐 代理配置
|
|
246
219
|
|
|
247
|
-
|
|
248
|
-
docker run -p 4141:4141 \
|
|
249
|
-
-e HTTP_PROXY=http://your-proxy:8080 \
|
|
250
|
-
-e HTTPS_PROXY=http://your-proxy:8080 \
|
|
251
|
-
copilot-api-plus start --proxy-env
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
## API Endpoints
|
|
220
|
+
如果你需要通过代理访问网络,有两种配置方式:
|
|
255
221
|
|
|
256
|
-
|
|
222
|
+
### 方式一:持久化配置(推荐)
|
|
257
223
|
|
|
258
|
-
|
|
224
|
+
配置一次,永久生效,下次启动自动使用。
|
|
259
225
|
|
|
260
|
-
|
|
226
|
+
```bash
|
|
227
|
+
# 交互式配置
|
|
228
|
+
npx copilot-api-plus@latest proxy --set
|
|
261
229
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
| `POST /v1/chat/completions` | `POST` | Creates a model response for the given chat conversation. |
|
|
265
|
-
| `GET /v1/models` | `GET` | Lists the currently available models. |
|
|
266
|
-
| `POST /v1/embeddings` | `POST` | Creates an embedding vector representing the input text. |
|
|
230
|
+
# 或直接设置
|
|
231
|
+
npx copilot-api-plus@latest proxy --http-proxy http://127.0.0.1:7890
|
|
267
232
|
|
|
268
|
-
|
|
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
|
|
235
|
+
```
|
|
269
236
|
|
|
270
|
-
|
|
237
|
+
#### 代理管理命令
|
|
271
238
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
| `POST /v1/messages/count_tokens` | `POST` | Calculates the number of tokens for a given set of messages. |
|
|
239
|
+
```bash
|
|
240
|
+
# 查看当前代理配置
|
|
241
|
+
npx copilot-api-plus@latest proxy
|
|
276
242
|
|
|
277
|
-
|
|
243
|
+
# 启用代理
|
|
244
|
+
npx copilot-api-plus@latest proxy --enable
|
|
278
245
|
|
|
279
|
-
|
|
246
|
+
# 禁用代理(保留设置)
|
|
247
|
+
npx copilot-api-plus@latest proxy --disable
|
|
280
248
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
| `GET /token` | `GET` | Get the current Copilot token being used by the API. |
|
|
249
|
+
# 清除代理配置
|
|
250
|
+
npx copilot-api-plus@latest proxy --clear
|
|
251
|
+
```
|
|
285
252
|
|
|
286
|
-
|
|
253
|
+
#### 示例:配置 Clash 代理
|
|
287
254
|
|
|
288
|
-
|
|
255
|
+
```bash
|
|
256
|
+
# Clash 默认端口 7890
|
|
257
|
+
npx copilot-api-plus@latest proxy --http-proxy http://127.0.0.1:7890
|
|
289
258
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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
|
+
```
|
|
293
267
|
|
|
294
|
-
|
|
295
|
-
npx copilot-api-plus@latest start --port 8080 --verbose
|
|
268
|
+
### 方式二:环境变量(临时)
|
|
296
269
|
|
|
297
|
-
|
|
298
|
-
npx copilot-api-plus@latest start --account-type business
|
|
270
|
+
仅当次启动生效:
|
|
299
271
|
|
|
300
|
-
|
|
301
|
-
|
|
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
|
|
302
277
|
|
|
303
|
-
#
|
|
304
|
-
|
|
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
|
|
305
282
|
|
|
306
|
-
#
|
|
307
|
-
|
|
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
|
+
```
|
|
308
288
|
|
|
309
|
-
|
|
310
|
-
npx copilot-api-plus@latest start --rate-limit 30 --wait
|
|
289
|
+
### 代理配置优先级
|
|
311
290
|
|
|
312
|
-
|
|
313
|
-
|
|
291
|
+
1. `--proxy-env` 参数(从环境变量读取)
|
|
292
|
+
2. 持久化配置(`proxy --set` 设置的)
|
|
293
|
+
3. 无代理
|
|
314
294
|
|
|
315
|
-
|
|
316
|
-
npx copilot-api-plus@latest auth
|
|
295
|
+
---
|
|
317
296
|
|
|
318
|
-
|
|
319
|
-
npx copilot-api-plus@latest auth --verbose
|
|
297
|
+
## 💻 Claude Code 集成
|
|
320
298
|
|
|
321
|
-
|
|
322
|
-
npx copilot-api-plus@latest check-usage
|
|
299
|
+
[Claude Code](https://docs.anthropic.com/en/docs/claude-code/overview) 是 Anthropic 的 AI 编程助手。
|
|
323
300
|
|
|
324
|
-
|
|
325
|
-
npx copilot-api-plus@latest debug
|
|
301
|
+
### 自动配置(推荐)
|
|
326
302
|
|
|
327
|
-
|
|
328
|
-
|
|
303
|
+
```bash
|
|
304
|
+
# 使用 GitHub Copilot 作为后端
|
|
305
|
+
npx copilot-api-plus@latest start --claude-code
|
|
329
306
|
|
|
330
|
-
#
|
|
331
|
-
npx copilot-api-plus@latest
|
|
307
|
+
# 使用 OpenCode Zen 作为后端
|
|
308
|
+
npx copilot-api-plus@latest start --zen --claude-code
|
|
332
309
|
|
|
333
|
-
#
|
|
334
|
-
npx copilot-api-plus@latest start --
|
|
310
|
+
# 使用 Google Antigravity 作为后端
|
|
311
|
+
npx copilot-api-plus@latest start --antigravity --claude-code
|
|
335
312
|
```
|
|
336
313
|
|
|
337
|
-
|
|
314
|
+
运行后:
|
|
315
|
+
1. 选择主模型(用于代码生成)
|
|
316
|
+
2. 选择快速模型(用于后台任务)
|
|
317
|
+
3. 启动命令会自动复制到剪贴板
|
|
318
|
+
4. **打开新终端**,粘贴并运行命令启动 Claude Code
|
|
338
319
|
|
|
339
|
-
|
|
320
|
+
### 手动配置
|
|
340
321
|
|
|
341
|
-
|
|
342
|
-
```sh
|
|
343
|
-
npx copilot-api-plus@latest start
|
|
344
|
-
```
|
|
345
|
-
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:
|
|
346
|
-
`https://imbuxiangnan-cyber.github.io/copilot-api-plus?endpoint=http://localhost:4141/usage`
|
|
347
|
-
- If you use the `start.bat` script on Windows, this page will open automatically.
|
|
322
|
+
在项目根目录创建 `.claude/settings.json`:
|
|
348
323
|
|
|
349
|
-
|
|
324
|
+
```json
|
|
325
|
+
{
|
|
326
|
+
"env": {
|
|
327
|
+
"ANTHROPIC_BASE_URL": "http://localhost:4141",
|
|
328
|
+
"ANTHROPIC_AUTH_TOKEN": "dummy",
|
|
329
|
+
"ANTHROPIC_MODEL": "claude-sonnet-4",
|
|
330
|
+
"ANTHROPIC_SMALL_FAST_MODEL": "gpt-4.1",
|
|
331
|
+
"DISABLE_NON_ESSENTIAL_MODEL_CALLS": "1"
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
```
|
|
350
335
|
|
|
351
|
-
|
|
352
|
-
- **Fetch Data**: Click the "Fetch" button to load or refresh the usage data. The dashboard will automatically fetch data on load.
|
|
353
|
-
- **Usage Quotas**: View a summary of your usage quotas for different services like Chat and Completions, displayed with progress bars for a quick overview.
|
|
354
|
-
- **Detailed Information**: See the full JSON response from the API for a detailed breakdown of all available usage statistics.
|
|
355
|
-
- **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:
|
|
356
|
-
`https://imbuxiangnan-cyber.github.io/copilot-api-plus?endpoint=http://your-api-server/usage`
|
|
336
|
+
然后启动 copilot-api-plus 服务器后,在该项目目录运行 `claude` 命令。
|
|
357
337
|
|
|
358
|
-
|
|
338
|
+
---
|
|
359
339
|
|
|
340
|
+
## 🔧 opencode 集成
|
|
360
341
|
|
|
361
|
-
|
|
342
|
+
[opencode](https://github.com/sst/opencode) 是一个现代 AI 编程助手。
|
|
362
343
|
|
|
363
|
-
|
|
344
|
+
### 配置步骤
|
|
364
345
|
|
|
365
|
-
|
|
366
|
-
1. 访问 [https://opencode.ai/zen](https://opencode.ai/zen)
|
|
367
|
-
2. 注册并登录,进入“API Keys”页面,创建你的 API Key
|
|
346
|
+
1. 在项目根目录创建 `opencode.json`:
|
|
368
347
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
348
|
+
```json
|
|
349
|
+
{
|
|
350
|
+
"$schema": "https://opencode.ai/config.json",
|
|
351
|
+
"provider": {
|
|
352
|
+
"copilot-api-plus": {
|
|
353
|
+
"api": "openai-compatible",
|
|
354
|
+
"name": "Copilot API Plus",
|
|
355
|
+
"options": {
|
|
356
|
+
"baseURL": "http://127.0.0.1:4141/v1"
|
|
357
|
+
},
|
|
358
|
+
"models": {
|
|
359
|
+
"claude-sonnet-4": {
|
|
360
|
+
"name": "Claude Sonnet 4",
|
|
361
|
+
"id": "claude-sonnet-4",
|
|
362
|
+
"max_tokens": 64000,
|
|
363
|
+
"profile": "coder",
|
|
364
|
+
"limit": { "context": 200000 }
|
|
365
|
+
},
|
|
366
|
+
"gpt-4.1": {
|
|
367
|
+
"name": "GPT-4.1",
|
|
368
|
+
"id": "gpt-4.1",
|
|
369
|
+
"max_tokens": 32768,
|
|
370
|
+
"profile": "coder",
|
|
371
|
+
"limit": { "context": 1047576 }
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
377
|
```
|
|
378
378
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
npx copilot-api-plus@latest start --zen --claude-code
|
|
383
|
-
```
|
|
384
|
-
会自动生成 Claude Code 启动命令,支持模型选择。
|
|
385
|
-
|
|
386
|
-
#### 4. 支持的模型(部分示例)
|
|
387
|
-
| 名称 | ID | 说明 |
|
|
388
|
-
|---------------------|----------------------|---------------------------|
|
|
389
|
-
| Claude Sonnet 4.5 | claude-sonnet-4-5 | Anthropic Claude 200K |
|
|
390
|
-
| Claude Opus 4.5 | claude-opus-4-5 | Anthropic Claude 200K |
|
|
391
|
-
| GPT-5 Codex | gpt-5-codex | OpenAI Responses API |
|
|
392
|
-
| Gemini 3 Pro | gemini-3-pro | Google Gemini |
|
|
393
|
-
| Qwen3 Coder 480B | qwen3-coder | Alibaba Qwen |
|
|
394
|
-
| Kimi K2 | kimi-k2 | Moonshot |
|
|
395
|
-
| Grok Code Fast 1 | grok-code | xAI |
|
|
396
|
-
更多模型请见 [Zen 官网](https://opencode.ai/zen)。
|
|
397
|
-
|
|
398
|
-
#### 5. API 路径
|
|
399
|
-
Zen 模式下,所有 OpenAI/Anthropic 兼容路径均可用:
|
|
400
|
-
- `POST /v1/chat/completions` (OpenAI 格式)
|
|
401
|
-
- `POST /v1/messages` (Anthropic 格式)
|
|
402
|
-
- `GET /v1/models` (模型列表)
|
|
403
|
-
Zen 专属路径(始终可用):
|
|
404
|
-
- `POST /zen/v1/chat/completions`
|
|
405
|
-
- `POST /zen/v1/messages`
|
|
406
|
-
- `GET /zen/v1/models`
|
|
407
|
-
|
|
408
|
-
#### 6. 常见问题
|
|
409
|
-
- **API Key 存储位置**:`~/.local/share/copilot-api-plus/zen-auth.json`
|
|
410
|
-
- **切换/清除 API Key**:
|
|
411
|
-
- 只清除 Zen:`npx copilot-api-plus@latest logout --zen`
|
|
412
|
-
- 全部清除:`npx copilot-api-plus@latest logout --all`
|
|
413
|
-
- **模型选择**:启动时会自动显示可用模型列表
|
|
414
|
-
- **与 opencode 配合**:在 `opencode.json` 里设置 `baseURL` 为 `http://127.0.0.1:4141/v1`,或用环境变量 `OPENAI_BASE_URL`
|
|
415
|
-
|
|
416
|
-
#### 7. 使用技巧
|
|
417
|
-
- 推荐用 `--claude-code` 生成 Claude Code 启动命令
|
|
418
|
-
- 支持所有 Zen 公开模型,按需选择
|
|
419
|
-
- 支持 Docker 部署,API Key 持久化
|
|
420
|
-
|
|
421
|
-
如需详细配置示例、opencode 配置、更多高级用法,请继续阅读下方文档。
|
|
422
|
-
|
|
423
|
-
### Why Use Zen Mode?
|
|
424
|
-
|
|
425
|
-
- **Access to many models**: Claude Sonnet 4.5, Claude Opus 4.5, GPT-5 Codex, Gemini 3 Pro, Qwen3 Coder, and more
|
|
426
|
-
- **Transparent pricing**: Pay per request with zero markups
|
|
427
|
-
- **Tested & verified**: All models are tested by the OpenCode team for coding tasks
|
|
428
|
-
- **Single API key**: One key for all Zen models
|
|
429
|
-
|
|
430
|
-
### Getting Started with Zen
|
|
431
|
-
|
|
432
|
-
1. **Get your API key**: Go to [opencode.ai/zen](https://opencode.ai/zen), sign up, and create an API key.
|
|
433
|
-
|
|
434
|
-
2. **Start the server in Zen mode**:
|
|
435
|
-
```sh
|
|
436
|
-
npx copilot-api-plus@latest start --zen
|
|
437
|
-
```
|
|
438
|
-
|
|
439
|
-
You will be prompted to enter your Zen API key on first run. The key will be saved for future use.
|
|
440
|
-
|
|
441
|
-
3. **Or provide the API key directly**:
|
|
442
|
-
```sh
|
|
443
|
-
npx copilot-api-plus@latest start --zen --zen-api-key your_api_key_here
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
### Using Zen with Claude Code
|
|
447
|
-
|
|
448
|
-
Start the server with both `--zen` and `--claude-code` flags:
|
|
449
|
-
|
|
450
|
-
```sh
|
|
451
|
-
npx copilot-api-plus@latest start --zen --claude-code
|
|
379
|
+
2. 启动 copilot-api-plus:
|
|
380
|
+
```bash
|
|
381
|
+
npx copilot-api-plus@latest start
|
|
452
382
|
```
|
|
453
383
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
### Available Zen Models
|
|
460
|
-
|
|
461
|
-
When using Zen mode, you can access models like:
|
|
462
|
-
|
|
463
|
-
| Model | ID | Description |
|
|
464
|
-
| ------------------ | ----------------- | ------------------------------ |
|
|
465
|
-
| Claude Sonnet 4.5 | claude-sonnet-4-5 | Anthropic Claude (200K context)|
|
|
466
|
-
| Claude Opus 4.5 | claude-opus-4-5 | Anthropic Claude (200K context)|
|
|
467
|
-
| GPT 5 Codex | gpt-5-codex | OpenAI (Responses API) |
|
|
468
|
-
| Gemini 3 Pro | gemini-3-pro | Google Gemini |
|
|
469
|
-
| Qwen3 Coder 480B | qwen3-coder | Alibaba Qwen |
|
|
470
|
-
| Kimi K2 | kimi-k2 | Moonshot |
|
|
471
|
-
| Grok Code Fast 1 | grok-code | xAI |
|
|
384
|
+
3. 在同一目录运行 opencode:
|
|
385
|
+
```bash
|
|
386
|
+
npx opencode@latest
|
|
387
|
+
```
|
|
472
388
|
|
|
473
|
-
|
|
389
|
+
4. 选择 `copilot-api-plus` 作为 provider
|
|
474
390
|
|
|
475
|
-
###
|
|
391
|
+
### 快捷方式:使用环境变量
|
|
476
392
|
|
|
477
|
-
|
|
393
|
+
```bash
|
|
394
|
+
# 设置环境变量
|
|
395
|
+
export OPENAI_BASE_URL=http://127.0.0.1:4141/v1
|
|
396
|
+
export OPENAI_API_KEY=dummy
|
|
478
397
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
| `POST /v1/messages` | Anthropic-compatible messages |
|
|
483
|
-
| `GET /v1/models` | List available Zen models |
|
|
398
|
+
# 运行 opencode
|
|
399
|
+
npx opencode@latest
|
|
400
|
+
```
|
|
484
401
|
|
|
485
|
-
|
|
402
|
+
---
|
|
486
403
|
|
|
487
|
-
|
|
488
|
-
| -------------------------------- | ------------------------ |
|
|
489
|
-
| `POST /zen/v1/chat/completions` | Zen chat completions |
|
|
490
|
-
| `POST /zen/v1/messages` | Zen messages |
|
|
491
|
-
| `GET /zen/v1/models` | Zen models |
|
|
404
|
+
## 📡 API 端点
|
|
492
405
|
|
|
493
|
-
|
|
406
|
+
服务器启动后,默认监听 `http://localhost:4141`。
|
|
494
407
|
|
|
495
|
-
###
|
|
408
|
+
### OpenAI 兼容端点
|
|
496
409
|
|
|
497
|
-
|
|
410
|
+
| 端点 | 方法 | 说明 |
|
|
411
|
+
|------|------|------|
|
|
412
|
+
| `/v1/chat/completions` | POST | 聊天补全(支持流式) |
|
|
413
|
+
| `/v1/models` | GET | 模型列表 |
|
|
414
|
+
| `/v1/embeddings` | POST | 文本嵌入(仅 Copilot) |
|
|
498
415
|
|
|
499
|
-
|
|
416
|
+
### Anthropic 兼容端点
|
|
500
417
|
|
|
501
|
-
|
|
418
|
+
| 端点 | 方法 | 说明 |
|
|
419
|
+
|------|------|------|
|
|
420
|
+
| `/v1/messages` | POST | 消息 API(支持流式) |
|
|
421
|
+
| `/v1/messages/count_tokens` | POST | Token 计数 |
|
|
502
422
|
|
|
503
|
-
|
|
423
|
+
### 专用端点
|
|
504
424
|
|
|
505
|
-
|
|
506
|
-
npx copilot-api-plus@latest start --antigravity
|
|
507
|
-
```
|
|
425
|
+
各后端都有独立的专用路由,即使切换默认后端也能访问:
|
|
508
426
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
427
|
+
| 路由前缀 | 说明 |
|
|
428
|
+
|----------|------|
|
|
429
|
+
| `/copilot/v1/*` | GitHub Copilot 专用 |
|
|
430
|
+
| `/zen/v1/*` | OpenCode Zen 专用 |
|
|
431
|
+
| `/antigravity/v1/*` | Google Antigravity 专用 |
|
|
513
432
|
|
|
514
|
-
|
|
433
|
+
### 监控端点
|
|
515
434
|
|
|
516
|
-
|
|
|
517
|
-
|
|
518
|
-
|
|
|
519
|
-
|
|
|
520
|
-
| Gemini 2.0 Flash | gemini-2.0-flash-exp | Google Gemini |
|
|
521
|
-
| Gemini 2.0 Flash Thinking | gemini-2.0-flash-thinking-exp | 支持思考链 |
|
|
522
|
-
| Gemini 2.0 Pro | gemini-2.0-pro-exp-02-05 | Google Gemini |
|
|
523
|
-
| Claude Opus 4.5 | claude-opus-4-5 | Anthropic Claude|
|
|
524
|
-
| Claude Sonnet 4.5 | claude-sonnet-4-5 | Anthropic Claude|
|
|
435
|
+
| 端点 | 方法 | 说明 |
|
|
436
|
+
|------|------|------|
|
|
437
|
+
| `/usage` | GET | 使用量统计(仅 Copilot) |
|
|
438
|
+
| `/token` | GET | 当前 Token 信息 |
|
|
525
439
|
|
|
526
|
-
|
|
440
|
+
### 调用示例
|
|
527
441
|
|
|
528
|
-
|
|
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
|
+
}'
|
|
529
450
|
|
|
530
|
-
|
|
531
|
-
|
|
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
|
+
}'
|
|
532
460
|
```
|
|
533
461
|
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
#### 4. API 路径
|
|
537
|
-
|
|
538
|
-
Antigravity 模式下:
|
|
539
|
-
|
|
540
|
-
| 路径 | 说明 |
|
|
541
|
-
| --------------------------------- | ---------------------------- |
|
|
542
|
-
| `POST /v1/chat/completions` | OpenAI 兼容聊天补全 |
|
|
543
|
-
| `POST /v1/messages` | Anthropic 兼容消息 API |
|
|
544
|
-
| `GET /v1/models` | 模型列表 |
|
|
462
|
+
---
|
|
545
463
|
|
|
546
|
-
|
|
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` | 清除所有凭证 |
|
|
547
515
|
|
|
548
|
-
|
|
549
|
-
| ----------------------------------------- | ------------------ |
|
|
550
|
-
| `POST /antigravity/v1/chat/completions` | Antigravity 聊天 |
|
|
551
|
-
| `POST /antigravity/v1/messages` | Antigravity 消息 |
|
|
552
|
-
| `GET /antigravity/v1/models` | Antigravity 模型 |
|
|
516
|
+
---
|
|
553
517
|
|
|
554
|
-
|
|
518
|
+
## 🐳 Docker 部署
|
|
555
519
|
|
|
556
|
-
|
|
557
|
-
- **清除账户**:
|
|
558
|
-
```sh
|
|
559
|
-
npx copilot-api-plus@latest logout --antigravity
|
|
560
|
-
```
|
|
561
|
-
- **支持多账户**:可添加多个 Google 账户,自动轮换
|
|
520
|
+
### 快速启动
|
|
562
521
|
|
|
563
|
-
|
|
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
|
|
527
|
+
```
|
|
564
528
|
|
|
565
|
-
|
|
566
|
-
- 多账户支持与自动轮换
|
|
567
|
-
- 配额用尽自动切换账户
|
|
568
|
-
- 支持 Thinking 模型(思考链输出)
|
|
529
|
+
### 自行构建
|
|
569
530
|
|
|
570
|
-
|
|
531
|
+
```bash
|
|
532
|
+
# 构建镜像
|
|
533
|
+
docker build -t copilot-api-plus .
|
|
571
534
|
|
|
572
|
-
|
|
535
|
+
# 运行容器
|
|
536
|
+
docker run -p 4141:4141 \
|
|
537
|
+
-v ./copilot-data:/root/.local/share/copilot-api-plus \
|
|
538
|
+
copilot-api-plus
|
|
539
|
+
```
|
|
573
540
|
|
|
574
|
-
|
|
541
|
+
### Docker Compose
|
|
575
542
|
|
|
576
|
-
|
|
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
|
+
```
|
|
577
556
|
|
|
578
|
-
|
|
557
|
+
### 使用代理
|
|
579
558
|
|
|
580
|
-
```
|
|
581
|
-
|
|
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
|
|
582
565
|
```
|
|
583
566
|
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
Paste and run this command in a new terminal to launch Claude Code.
|
|
567
|
+
---
|
|
587
568
|
|
|
588
|
-
|
|
569
|
+
## ❓ 常见问题
|
|
589
570
|
|
|
590
|
-
|
|
571
|
+
### 数据存储位置
|
|
591
572
|
|
|
592
|
-
|
|
573
|
+
所有数据存储在 `~/.local/share/copilot-api-plus/` 目录下:
|
|
593
574
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
"ANTHROPIC_DEFAULT_SONNET_MODEL": "gpt-4.1",
|
|
601
|
-
"ANTHROPIC_SMALL_FAST_MODEL": "gpt-4.1",
|
|
602
|
-
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "gpt-4.1",
|
|
603
|
-
"DISABLE_NON_ESSENTIAL_MODEL_CALLS": "1",
|
|
604
|
-
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
|
|
605
|
-
},
|
|
606
|
-
"permissions": {
|
|
607
|
-
"deny": [
|
|
608
|
-
"WebSearch"
|
|
609
|
-
]
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
```
|
|
575
|
+
| 文件 | 说明 |
|
|
576
|
+
|------|------|
|
|
577
|
+
| `github_token` | GitHub Token |
|
|
578
|
+
| `zen-auth.json` | Zen API Key |
|
|
579
|
+
| `antigravity-accounts.json` | Antigravity 账户 |
|
|
580
|
+
| `config.json` | 代理等配置 |
|
|
613
581
|
|
|
614
|
-
|
|
582
|
+
### 切换账户
|
|
615
583
|
|
|
616
|
-
|
|
584
|
+
```bash
|
|
585
|
+
# 清除 GitHub 凭证
|
|
586
|
+
npx copilot-api-plus@latest logout
|
|
617
587
|
|
|
618
|
-
|
|
588
|
+
# 清除 Zen 凭证
|
|
589
|
+
npx copilot-api-plus@latest logout --zen
|
|
619
590
|
|
|
620
|
-
|
|
591
|
+
# 清除 Antigravity 凭证
|
|
592
|
+
npx copilot-api-plus@latest logout --antigravity
|
|
621
593
|
|
|
622
|
-
|
|
594
|
+
# 清除所有凭证
|
|
595
|
+
npx copilot-api-plus@latest logout --all
|
|
596
|
+
```
|
|
623
597
|
|
|
624
|
-
|
|
598
|
+
### 查看使用量
|
|
625
599
|
|
|
626
|
-
```
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
"provider": {
|
|
630
|
-
"copilot-api-plus": {
|
|
631
|
-
"api": "openai-compatible",
|
|
632
|
-
"name": "Copilot API Plus",
|
|
633
|
-
"options": {
|
|
634
|
-
"baseURL": "http://127.0.0.1:4141/v1"
|
|
635
|
-
},
|
|
636
|
-
"models": {
|
|
637
|
-
"claude-sonnet-4": {
|
|
638
|
-
"name": "Claude Sonnet 4",
|
|
639
|
-
"id": "claude-sonnet-4",
|
|
640
|
-
"max_tokens": 64000,
|
|
641
|
-
"default_tokens": 16000,
|
|
642
|
-
"profile": "coder",
|
|
643
|
-
"attachment": true,
|
|
644
|
-
"limit": {
|
|
645
|
-
"context": 200000
|
|
646
|
-
}
|
|
647
|
-
},
|
|
648
|
-
"claude-sonnet-4.5": {
|
|
649
|
-
"name": "Claude Sonnet 4.5",
|
|
650
|
-
"id": "claude-sonnet-4.5",
|
|
651
|
-
"max_tokens": 64000,
|
|
652
|
-
"default_tokens": 16000,
|
|
653
|
-
"profile": "coder",
|
|
654
|
-
"attachment": true,
|
|
655
|
-
"limit": {
|
|
656
|
-
"context": 200000
|
|
657
|
-
}
|
|
658
|
-
},
|
|
659
|
-
"gpt-4.1": {
|
|
660
|
-
"name": "GPT-4.1",
|
|
661
|
-
"id": "gpt-4.1",
|
|
662
|
-
"max_tokens": 32768,
|
|
663
|
-
"default_tokens": 16000,
|
|
664
|
-
"profile": "coder",
|
|
665
|
-
"attachment": true,
|
|
666
|
-
"limit": {
|
|
667
|
-
"context": 1047576
|
|
668
|
-
}
|
|
669
|
-
},
|
|
670
|
-
"o4-mini": {
|
|
671
|
-
"name": "o4-mini",
|
|
672
|
-
"id": "o4-mini",
|
|
673
|
-
"max_tokens": 100000,
|
|
674
|
-
"default_tokens": 16000,
|
|
675
|
-
"profile": "coder",
|
|
676
|
-
"attachment": true,
|
|
677
|
-
"limit": {
|
|
678
|
-
"context": 200000
|
|
679
|
-
}
|
|
680
|
-
},
|
|
681
|
-
"gemini-2.5-pro": {
|
|
682
|
-
"name": "Gemini 2.5 Pro",
|
|
683
|
-
"id": "gemini-2.5-pro",
|
|
684
|
-
"max_tokens": 65536,
|
|
685
|
-
"default_tokens": 16000,
|
|
686
|
-
"profile": "coder",
|
|
687
|
-
"attachment": true,
|
|
688
|
-
"limit": {
|
|
689
|
-
"context": 1048576
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
}
|
|
600
|
+
```bash
|
|
601
|
+
# 命令行查看(仅 Copilot)
|
|
602
|
+
npx copilot-api-plus@latest check-usage
|
|
696
603
|
```
|
|
697
604
|
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
npx copilot-api-plus@latest start --proxy-env
|
|
703
|
-
```
|
|
605
|
+
启动服务器后,也可以访问 Web 仪表盘:
|
|
606
|
+
```
|
|
607
|
+
https://imbuxiangnan-cyber.github.io/copilot-api-plus?endpoint=http://localhost:4141/usage
|
|
608
|
+
```
|
|
704
609
|
|
|
705
|
-
|
|
706
|
-
```sh
|
|
707
|
-
npx opencode@latest
|
|
708
|
-
```
|
|
610
|
+
### 调试问题
|
|
709
611
|
|
|
710
|
-
|
|
612
|
+
```bash
|
|
613
|
+
# 显示调试信息
|
|
614
|
+
npx copilot-api-plus@latest debug
|
|
711
615
|
|
|
712
|
-
|
|
616
|
+
# JSON 格式输出
|
|
617
|
+
npx copilot-api-plus@latest debug --json
|
|
713
618
|
|
|
714
|
-
|
|
619
|
+
# 启用详细日志
|
|
620
|
+
npx copilot-api-plus@latest start --verbose
|
|
621
|
+
```
|
|
715
622
|
|
|
716
|
-
|
|
717
|
-
| ----------------- | ------------------------------------ |
|
|
718
|
-
| `claude-sonnet-4` | Claude Sonnet 4 (200K context) |
|
|
719
|
-
| `claude-sonnet-4.5` | Claude Sonnet 4.5 (200K context) |
|
|
720
|
-
| `gpt-4.1` | GPT-4.1 (1M context) |
|
|
721
|
-
| `o4-mini` | OpenAI o4-mini reasoning model |
|
|
722
|
-
| `gemini-2.5-pro` | Google Gemini 2.5 Pro (1M context) |
|
|
623
|
+
### 速率限制
|
|
723
624
|
|
|
724
|
-
|
|
625
|
+
避免触发 GitHub 的滥用检测:
|
|
725
626
|
|
|
726
|
-
|
|
627
|
+
```bash
|
|
628
|
+
# 设置请求间隔 30 秒
|
|
629
|
+
npx copilot-api-plus@latest start --rate-limit 30
|
|
727
630
|
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
export OPENAI_BASE_URL=http://127.0.0.1:4141/v1
|
|
731
|
-
export OPENAI_API_KEY=dummy
|
|
631
|
+
# 达到限制时等待而非报错
|
|
632
|
+
npx copilot-api-plus@latest start --rate-limit 30 --wait
|
|
732
633
|
|
|
733
|
-
#
|
|
734
|
-
npx
|
|
634
|
+
# 手动审批每个请求
|
|
635
|
+
npx copilot-api-plus@latest start --manual
|
|
735
636
|
```
|
|
736
637
|
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
The project can be run from source in several ways:
|
|
638
|
+
---
|
|
740
639
|
|
|
741
|
-
|
|
640
|
+
## ⚠️ 免责声明
|
|
742
641
|
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
```
|
|
642
|
+
> [!WARNING]
|
|
643
|
+
> 这是 GitHub Copilot API 的逆向工程代理。**不受 GitHub 官方支持**,可能随时失效。使用风险自负。
|
|
746
644
|
|
|
747
|
-
|
|
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)
|
|
748
651
|
|
|
749
|
-
|
|
750
|
-
bun run start
|
|
751
|
-
```
|
|
652
|
+
---
|
|
752
653
|
|
|
753
|
-
##
|
|
654
|
+
## 📄 许可证
|
|
754
655
|
|
|
755
|
-
|
|
756
|
-
- `--manual`: Enables manual approval for each request, giving you full control over when requests are sent.
|
|
757
|
-
- `--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.
|
|
758
|
-
- `--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.
|
|
759
|
-
- 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
|