@jeffreycao/copilot-api 1.6.0-beta.2 → 1.6.1

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,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 `/` require authentication when `auth.apiKeys` is configured and non-empty.
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>`
@@ -605,7 +609,8 @@ Here is an example `.claude/settings.json` file:
605
609
  },
606
610
  "permissions": {
607
611
  "deny": [
608
- "WebSearch"
612
+ "WebSearch",
613
+ "mcp__ide__executeCode"
609
614
  ]
610
615
  }
611
616
  }
@@ -615,7 +620,7 @@ Here is an example `.claude/settings.json` file:
615
620
  - 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
621
  - Turning off CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION can prevent quota from being consumed unnecessarily.
617
622
  - 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, and cache hit rates are affected, so it does not necessarily save tokens,but it can save context. Only server tool search mode can save tokens.
623
+ - 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
624
 
620
625
  You can find more options here: [Claude Code settings](https://docs.anthropic.com/en/docs/claude-code/settings#environment-variables)
621
626
 
@@ -682,13 +687,13 @@ The project can be run from source in several ways:
682
687
  ### Development Mode
683
688
 
684
689
  ```sh
685
- bun run dev
690
+ bun run dev start
686
691
  ```
687
692
 
688
693
  ### Production Mode
689
694
 
690
695
  ```sh
691
- bun run start
696
+ bun run start start
692
697
  ```
693
698
 
694
699
  ## Usage Tips