@jeffreycao/copilot-api 1.6.0-beta.1 → 1.6.0
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 +35 -31
- package/README.zh-CN.md +723 -0
- package/dist/main.js +1 -1
- package/dist/{server-BZfT6g7P.js → server-DYDw_yEw.js} +7 -7
- package/dist/server-DYDw_yEw.js.map +1 -0
- package/dist/{start-BBJU_Vu_.js → start-JMKr-2eK.js} +2 -2
- package/dist/{start-BBJU_Vu_.js.map → start-JMKr-2eK.js.map} +1 -1
- package/package.json +1 -1
- package/dist/server-BZfT6g7P.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Copilot API Proxy
|
|
2
2
|
|
|
3
|
+
English | [简体中文](./README.zh-CN.md)
|
|
4
|
+
|
|
3
5
|
> [!WARNING]
|
|
4
6
|
> 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. In the current version, if not using opencode OAuth, the device ID and machine ID will be sent to GitHub Copilot. It is not recommended to use a large number of accounts on a single device; if necessary, it is advised to run them in Docker containers.
|
|
5
7
|
|
|
@@ -42,7 +44,7 @@
|
|
|
42
44
|
|
|
43
45
|
## Project Overview
|
|
44
46
|
|
|
45
|
-
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).
|
|
47
|
+
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 / Responses API or the Anthropic Messages API, including to power [Claude Code](https://docs.anthropic.com/en/docs/claude-code/overview).
|
|
46
48
|
|
|
47
49
|
Compared with routing everything through plain Chat Completions compatibility, this proxy can prefer Copilot's native Anthropic-style Messages API for Claude-family models, preserve more native thinking/tool semantics, reduce unnecessary Premium request consumption on warmup or resumed tool turns, and expose phase-aware `gpt-5.4` / `gpt-5.3-codex` responses that are easier for users to follow.
|
|
48
50
|
|
|
@@ -124,10 +126,6 @@ When an Anthropic API key is configured, the proxy forwards Claude model token c
|
|
|
124
126
|
> [!NOTE]
|
|
125
127
|
> Anthropic's `/v1/messages/count_tokens` endpoint is **free** (no per-token cost). It is rate-limited to 100 RPM at Tier 1. The $5 credit purchase is only needed to activate API access — the token counting calls themselves cost nothing.
|
|
126
128
|
|
|
127
|
-
## Demo
|
|
128
|
-
|
|
129
|
-
https://github.com/user-attachments/assets/7654b383-669d-4eb9-b23c-06d7aefee8c5
|
|
130
|
-
|
|
131
129
|
## Prerequisites
|
|
132
130
|
|
|
133
131
|
- Bun (>= 1.2.x)
|
|
@@ -141,6 +139,32 @@ To install dependencies, run:
|
|
|
141
139
|
bun install
|
|
142
140
|
```
|
|
143
141
|
|
|
142
|
+
To start the server directly from source:
|
|
143
|
+
|
|
144
|
+
```sh
|
|
145
|
+
bun run start start
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Using with npx
|
|
149
|
+
|
|
150
|
+
You can run the project directly using npx:
|
|
151
|
+
|
|
152
|
+
```sh
|
|
153
|
+
npx @jeffreycao/copilot-api@latest start
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
With options:
|
|
157
|
+
|
|
158
|
+
```sh
|
|
159
|
+
npx @jeffreycao/copilot-api@latest start --port 8080
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
For authentication only:
|
|
163
|
+
|
|
164
|
+
```sh
|
|
165
|
+
npx @jeffreycao/copilot-api@latest auth
|
|
166
|
+
```
|
|
167
|
+
|
|
144
168
|
## Using with Docker
|
|
145
169
|
|
|
146
170
|
Build image
|
|
@@ -200,26 +224,6 @@ The Docker image includes:
|
|
|
200
224
|
- Health check for container monitoring
|
|
201
225
|
- Pinned base image version for reproducible builds
|
|
202
226
|
|
|
203
|
-
## Using with npx
|
|
204
|
-
|
|
205
|
-
You can run the project directly using npx:
|
|
206
|
-
|
|
207
|
-
```sh
|
|
208
|
-
npx @jeffreycao/copilot-api@latest start
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
With options:
|
|
212
|
-
|
|
213
|
-
```sh
|
|
214
|
-
npx @jeffreycao/copilot-api@latest start --port 8080
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
For authentication only:
|
|
218
|
-
|
|
219
|
-
```sh
|
|
220
|
-
npx @jeffreycao/copilot-api@latest auth
|
|
221
|
-
```
|
|
222
|
-
|
|
223
227
|
## Command Structure
|
|
224
228
|
|
|
225
229
|
Copilot API now uses a subcommand structure with these main commands:
|
|
@@ -312,8 +316,7 @@ The following command line options are available for the `start` command:
|
|
|
312
316
|
},
|
|
313
317
|
"useFunctionApplyPatch": true,
|
|
314
318
|
"useMessagesApi": true,
|
|
315
|
-
"useResponsesApiWebSearch": true
|
|
316
|
-
"anthropicApiKey": ""
|
|
319
|
+
"useResponsesApiWebSearch": true
|
|
317
320
|
}
|
|
318
321
|
```
|
|
319
322
|
- **auth.apiKeys:** API keys used for request authentication. Supports multiple keys for rotation. Requests can authenticate with either `x-api-key: <key>` or `Authorization: Bearer <key>`. If empty or omitted, authentication is disabled.
|
|
@@ -334,13 +337,14 @@ The following command line options are available for the `start` command:
|
|
|
334
337
|
- **useFunctionApplyPatch:** When `true`, the server will convert any custom tool named `apply_patch` in Responses payloads into an OpenAI-style function tool (`type: "function"`) with a parameter schema so assistants can call it using function-calling semantics to edit files. Set to `false` to leave tools unchanged. Defaults to `true`.
|
|
335
338
|
- **useMessagesApi:** When `true`, Claude-family models that support Copilot's native `/v1/messages` endpoint will use the Messages API; otherwise they fall back to `/chat/completions`. Set to `false` to disable Messages API routing and always use `/chat/completions`. Defaults to `true`.
|
|
336
339
|
- **useResponsesApiWebSearch:** When `true`, the server keeps Responses API tools with `type: "web_search"` and forwards them upstream. Set to `false` to strip those tools from `/responses` payloads. Defaults to `true`.
|
|
340
|
+
- **claudeTokenMultiplier:** Multiplier applied to the fallback GPT-tokenizer estimate for Claude `/v1/messages/count_tokens` requests. Defaults to `1.15`. Increase it if your client is still compacting too late. This setting is only used when the proxy is estimating Claude tokens locally; if `anthropicApiKey` is configured and Anthropic token counting succeeds, the exact Anthropic count is returned instead.
|
|
337
341
|
- **anthropicApiKey:** Anthropic API key used for accurate Claude token counting (see [Accurate Claude Token Counting](#accurate-claude-token-counting) below). Can also be set via the `ANTHROPIC_API_KEY` environment variable. If not set, token counting falls back to GPT tokenizer estimation.
|
|
338
342
|
|
|
339
343
|
Edit this file to customize prompts or swap in your own fast model. Restart the server (or rerun the command) after changes so the cached config is refreshed.
|
|
340
344
|
|
|
341
345
|
## API Authentication
|
|
342
346
|
|
|
343
|
-
- **Protected routes:** All routes except
|
|
347
|
+
- **Protected routes:** All routes except `/`, `/usage-viewer`, and `/usage-viewer/` require authentication when `auth.apiKeys` is configured and non-empty.
|
|
344
348
|
- **Allowed auth headers:**
|
|
345
349
|
- `x-api-key: <your_key>`
|
|
346
350
|
- `Authorization: Bearer <your_key>`
|
|
@@ -615,7 +619,7 @@ Here is an example `.claude/settings.json` file:
|
|
|
615
619
|
- Setting CLAUDE_CODE_ATTRIBUTION_HEADER to 0 can prevent Claude code from adding billing and version information in system prompts, thereby avoiding prompt cache invalidation.
|
|
616
620
|
- Turning off CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION can prevent quota from being consumed unnecessarily.
|
|
617
621
|
- Permissions deny WebSearch because the GitHub Copilot API does not support natie websearch (some gpt models support websearch, but the current project has not adapted websearch); it is recommended to install the mcp mcp_server_fetch tool or other search tools as alternatives..
|
|
618
|
-
- If using a non-Claude model, do not enable ENABLE_TOOL_SEARCH. If using the Claude model, can enable ENABLE_TOOL_SEARCH. The current Claude Code uses the client tool search mode. In this mode, loading defer tools requires an additional request each time
|
|
622
|
+
- If using a non-Claude model, do not enable ENABLE_TOOL_SEARCH. If using the Claude model, can enable ENABLE_TOOL_SEARCH. The current Claude Code uses the client tool search mode. In this mode, loading defer tools requires an additional request each time.
|
|
619
623
|
|
|
620
624
|
You can find more options here: [Claude Code settings](https://docs.anthropic.com/en/docs/claude-code/settings#environment-variables)
|
|
621
625
|
|
|
@@ -682,13 +686,13 @@ The project can be run from source in several ways:
|
|
|
682
686
|
### Development Mode
|
|
683
687
|
|
|
684
688
|
```sh
|
|
685
|
-
bun run dev
|
|
689
|
+
bun run dev start
|
|
686
690
|
```
|
|
687
691
|
|
|
688
692
|
### Production Mode
|
|
689
693
|
|
|
690
694
|
```sh
|
|
691
|
-
bun run start
|
|
695
|
+
bun run start start
|
|
692
696
|
```
|
|
693
697
|
|
|
694
698
|
## Usage Tips
|