copilot-api-plus 1.0.57 → 1.0.59

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.en.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  English | [简体中文](README.md)
7
7
 
8
- > A proxy that converts GitHub Copilot, OpenCode Zen, and Google Antigravity into OpenAI & Anthropic compatible APIs. Works with Claude Code, opencode, and more.
8
+ > A proxy that converts GitHub Copilot into OpenAI & Anthropic compatible APIs. Works with Claude Code and more.
9
9
 
10
10
  ---
11
11
 
@@ -15,11 +15,8 @@ English | [简体中文](README.md)
15
15
  - [Quick Start](#-quick-start)
16
16
  - [Usage Guide](#-usage-guide)
17
17
  - [GitHub Copilot Mode](#1-github-copilot-mode-default)
18
- - [OpenCode Zen Mode](#2-opencode-zen-mode)
19
- - [Google Antigravity Mode](#3-google-antigravity-mode)
20
18
  - [Proxy Configuration](#-proxy-configuration)
21
19
  - [Claude Code Integration](#-claude-code-integration)
22
- - [opencode Integration](#-opencode-integration)
23
20
  - [API Endpoints](#-api-endpoints)
24
21
  - [API Key Authentication](#-api-key-authentication)
25
22
  - [Technical Details](#-technical-details)
@@ -33,7 +30,7 @@ English | [简体中文](README.md)
33
30
 
34
31
  | Feature | Description |
35
32
  |---------|-------------|
36
- | 🔌 **Multiple Backends** | Choose from GitHub Copilot, OpenCode Zen, or Google Antigravity |
33
+ | 🔌 **GitHub Copilot Backend** | Access AI models using your GitHub Copilot subscription |
37
34
  | 🤖 **Dual Protocol** | Supports both OpenAI Chat Completions API and Anthropic Messages API |
38
35
  | 💻 **Claude Code Integration** | One-command Claude Code setup (`--claude-code`) |
39
36
  | 📊 **Usage Monitoring** | Real-time API usage dashboard |
@@ -44,7 +41,6 @@ English | [简体中文](README.md)
44
41
  | 🔑 **API Key Auth** | Optional API key authentication for public deployments |
45
42
  | ✂️ **Context Passthrough** | Full context passthrough to upstream API; clients (e.g. Claude Code) manage compression |
46
43
  | 🔍 **Smart Model Matching** | Handles model name format differences (date suffixes, dash/dot versions, etc.) |
47
- | 🔁 **Antigravity Failover** | Circuit breaker state machine, weighted account dispatch, background task auto-downgrade, dual-endpoint auto-switching |
48
44
 
49
45
  ---
50
46
 
@@ -66,12 +62,6 @@ npx copilot-api-plus@latest start
66
62
  # Start server (defaults to GitHub Copilot)
67
63
  npx copilot-api-plus@latest start
68
64
 
69
- # Use OpenCode Zen
70
- npx copilot-api-plus@latest start --zen
71
-
72
- # Use Google Antigravity
73
- npx copilot-api-plus@latest start --antigravity
74
-
75
65
  # Use with Claude Code
76
66
  npx copilot-api-plus@latest start --claude-code
77
67
  ```
@@ -127,169 +117,6 @@ npx copilot-api-plus@latest start --account-type enterprise
127
117
 
128
118
  ---
129
119
 
130
- ### 2. OpenCode Zen Mode
131
-
132
- Use [OpenCode Zen](https://opencode.ai/zen)'s multi-model API service, supporting GPT-5, Claude, Gemini, and other top coding models.
133
-
134
- #### Prerequisites
135
- 1. Visit https://opencode.ai/zen
136
- 2. Register and create an API Key
137
-
138
- #### Getting Started
139
-
140
- **Option 1: Interactive setup**
141
- ```bash
142
- npx copilot-api-plus@latest start --zen
143
- ```
144
- First run will prompt for an API Key, which is saved for future use.
145
-
146
- **Option 2: Provide API Key directly**
147
- ```bash
148
- npx copilot-api-plus@latest start --zen --zen-api-key YOUR_API_KEY
149
- ```
150
-
151
- #### Available Models
152
-
153
- | Model | ID | Description |
154
- |-------|-----|-------------|
155
- | GPT-5.2 | `gpt-5.2` | OpenAI latest |
156
- | GPT-5.1 Codex Max | `gpt-5.1-codex-max` | Code-optimized |
157
- | GPT-5.1 Codex | `gpt-5.1-codex` | Code-focused |
158
- | GPT-5 Codex | `gpt-5-codex` | OpenAI Responses API |
159
- | Claude Opus 4.5 | `claude-opus-4-5` | Anthropic Claude (200K) |
160
- | Claude Sonnet 4.5 | `claude-sonnet-4-5` | Anthropic Claude (200K) |
161
- | Claude Sonnet 4 | `claude-sonnet-4` | Anthropic Claude |
162
- | Gemini 3 Pro | `gemini-3-pro` | Google Gemini |
163
- | Qwen3 Coder | `qwen3-coder` | Alibaba Qwen |
164
- | Kimi K2 | `kimi-k2` | Moonshot |
165
- | Grok Code Fast 1 | `grok-code-fast-1` | xAI |
166
-
167
- More models at [opencode.ai/zen](https://opencode.ai/zen)
168
-
169
- #### API Endpoints
170
-
171
- Zen mode supports the following endpoints:
172
-
173
- | Endpoint | Description |
174
- |----------|-------------|
175
- | `/v1/chat/completions` | OpenAI-compatible Chat API |
176
- | `/v1/messages` | Anthropic-compatible Messages API |
177
- | `/v1/responses` | OpenAI Responses API (GPT-5 series) |
178
- | `/v1/models` | List available models |
179
-
180
- Dedicated endpoints (accessible without `--zen` flag):
181
- - `/zen/v1/chat/completions`
182
- - `/zen/v1/messages`
183
- - `/zen/v1/responses`
184
- - `/zen/v1/models`
185
-
186
- #### Manage API Key
187
-
188
- ```bash
189
- # View/change API Key (clearing it will prompt for a new one on next start)
190
- npx copilot-api-plus@latest logout --zen
191
- ```
192
-
193
- ---
194
-
195
- ### 3. Google Antigravity Mode
196
-
197
- Use Google Antigravity API service, supporting Gemini and Claude models.
198
-
199
- #### Prerequisites
200
- - Google account
201
-
202
- #### Authentication Methods
203
-
204
- **Option 1: API Key (Recommended - Simplest)**
205
-
206
- 1. Get an API Key at https://aistudio.google.com/apikey
207
- 2. Start with environment variable:
208
-
209
- ```bash
210
- # Linux/macOS
211
- GEMINI_API_KEY=your_api_key npx copilot-api-plus@latest start --antigravity
212
-
213
- # Windows PowerShell
214
- $env:GEMINI_API_KEY = "your_api_key"
215
- npx copilot-api-plus@latest start --antigravity
216
-
217
- # Windows CMD
218
- set GEMINI_API_KEY=your_api_key
219
- npx copilot-api-plus@latest start --antigravity
220
- ```
221
-
222
- **Option 2: OAuth Web Login (Recommended)**
223
-
224
- ```bash
225
- npx copilot-api-plus@latest start --antigravity
226
- ```
227
-
228
- First run will prompt you to choose a login method:
229
- - **Web (Recommended)**: Opens browser for Google login, automatically captures the callback
230
- - **Manual**: Manually copy the callback URL to the terminal
231
-
232
- **Option 3: Custom OAuth Credentials**
233
-
234
- If you encounter an `invalid_client` error, create your own OAuth app:
235
-
236
- 1. Visit https://console.cloud.google.com/apis/credentials
237
- 2. Create an OAuth 2.0 Client ID (select "Desktop application" type)
238
- 3. Add redirect URI: `http://localhost:8046/callback`
239
- 4. Use environment variables or CLI arguments:
240
-
241
- ```bash
242
- # Environment variables
243
- ANTIGRAVITY_CLIENT_ID=your_client_id ANTIGRAVITY_CLIENT_SECRET=your_secret \
244
- npx copilot-api-plus@latest start --antigravity
245
-
246
- # CLI arguments
247
- npx copilot-api-plus@latest start --antigravity \
248
- --antigravity-client-id your_client_id \
249
- --antigravity-client-secret your_secret
250
- ```
251
-
252
- #### Available Models
253
-
254
- | Model | ID | Description |
255
- |-------|-----|-------------|
256
- | Gemini 2.5 Pro | `gemini-2.5-pro-exp-03-25` | Google Gemini |
257
- | Gemini 2.5 Pro Preview | `gemini-2.5-pro-preview-05-06` | Google Gemini |
258
- | Gemini 2.0 Flash | `gemini-2.0-flash-exp` | Fast responses |
259
- | Gemini 2.0 Flash Thinking | `gemini-2.0-flash-thinking-exp` | Chain-of-thought |
260
- | Claude Opus 4.5 | `claude-opus-4-5` | Anthropic Claude |
261
- | Claude Sonnet 4.5 | `claude-sonnet-4-5` | Anthropic Claude |
262
-
263
- #### Features
264
- - ✅ Automatic token refresh
265
- - ✅ Multi-account support with weighted smart dispatch (quota health 60% + token freshness 20% + reliability 20%)
266
- - ✅ Auto-switch on quota exhaustion
267
- - ✅ Circuit breaker state machine (CLOSED → OPEN → HALF_OPEN → CLOSED)
268
- - ✅ Multi-signal agent/background request detection with optional model downgrade to save quota
269
- - ✅ Thinking model support (chain-of-thought output)
270
-
271
- #### Multi-Account Management
272
-
273
- Add multiple Google accounts; the system auto-switches when quota is exhausted:
274
-
275
- ```bash
276
- # Add new account
277
- npx copilot-api-plus@latest antigravity add
278
-
279
- # List all accounts
280
- npx copilot-api-plus@latest antigravity list
281
-
282
- # Remove account by index
283
- npx copilot-api-plus@latest antigravity remove 0
284
-
285
- # Clear all accounts
286
- npx copilot-api-plus@latest antigravity clear
287
- # Or use logout
288
- npx copilot-api-plus@latest logout --antigravity
289
- ```
290
-
291
- ---
292
-
293
120
  ## 🌐 Proxy Configuration
294
121
 
295
122
  Two ways to configure a proxy:
@@ -376,14 +203,7 @@ npx copilot-api-plus@latest start --proxy-env
376
203
  ### Auto Configuration (Recommended)
377
204
 
378
205
  ```bash
379
- # Using GitHub Copilot as backend
380
206
  npx copilot-api-plus@latest start --claude-code
381
-
382
- # Using OpenCode Zen as backend
383
- npx copilot-api-plus@latest start --zen --claude-code
384
-
385
- # Using Google Antigravity as backend
386
- npx copilot-api-plus@latest start --antigravity --claude-code
387
207
  ```
388
208
 
389
209
  After running:
@@ -412,70 +232,6 @@ Then start the copilot-api-plus server and run `claude` in that project director
412
232
 
413
233
  ---
414
234
 
415
- ## 🔧 opencode Integration
416
-
417
- [opencode](https://github.com/sst/opencode) is a modern AI coding assistant.
418
-
419
- ### Setup
420
-
421
- 1. Create `opencode.json` in your project root:
422
-
423
- ```json
424
- {
425
- "$schema": "https://opencode.ai/config.json",
426
- "provider": {
427
- "copilot-api-plus": {
428
- "api": "openai-compatible",
429
- "name": "Copilot API Plus",
430
- "options": {
431
- "baseURL": "http://127.0.0.1:4141/v1"
432
- },
433
- "models": {
434
- "claude-sonnet-4": {
435
- "name": "Claude Sonnet 4",
436
- "id": "claude-sonnet-4",
437
- "max_tokens": 64000,
438
- "profile": "coder",
439
- "limit": { "context": 200000 }
440
- },
441
- "gpt-4.1": {
442
- "name": "GPT-4.1",
443
- "id": "gpt-4.1",
444
- "max_tokens": 32768,
445
- "profile": "coder",
446
- "limit": { "context": 1047576 }
447
- }
448
- }
449
- }
450
- }
451
- }
452
- ```
453
-
454
- 2. Start copilot-api-plus:
455
- ```bash
456
- npx copilot-api-plus@latest start
457
- ```
458
-
459
- 3. Run opencode in the same directory:
460
- ```bash
461
- npx opencode@latest
462
- ```
463
-
464
- 4. Select `copilot-api-plus` as the provider
465
-
466
- ### Shortcut: Environment Variables
467
-
468
- ```bash
469
- # Set environment variables
470
- export OPENAI_BASE_URL=http://127.0.0.1:4141/v1
471
- export OPENAI_API_KEY=dummy
472
-
473
- # Run opencode
474
- npx opencode@latest
475
- ```
476
-
477
- ---
478
-
479
235
  ## 📡 API Endpoints
480
236
 
481
237
  The server listens on `http://localhost:4141` by default.
@@ -497,13 +253,11 @@ The server listens on `http://localhost:4141` by default.
497
253
 
498
254
  ### Dedicated Endpoints
499
255
 
500
- Each backend has its own dedicated routes, accessible regardless of the default backend:
256
+ Each backend has its own dedicated routes:
501
257
 
502
258
  | Route Prefix | Description |
503
259
  |--------------|-------------|
504
260
  | `/copilot/v1/*` | GitHub Copilot |
505
- | `/zen/v1/*` | OpenCode Zen |
506
- | `/antigravity/v1/*` | Google Antigravity |
507
261
 
508
262
  ### Monitoring Endpoints
509
263
 
@@ -590,35 +344,6 @@ Anthropic-format model names (e.g. `claude-opus-4-6`) may differ from Copilot's
590
344
 
591
345
  For Anthropic endpoints (`/v1/messages`), `translateModelName` also handles legacy format conversion (e.g. `claude-3-5-sonnet` → `claude-sonnet-4.5`) before applying the above strategies.
592
346
 
593
- ### Antigravity Endpoint Failover
594
-
595
- Google Antigravity mode has multi-layered reliability features:
596
-
597
- - **Circuit breaker state machine**: Independent per model family (claude/gemini/other). Opens after 3 failures, half-opens after 30s for probing, closes after 2 consecutive successes
598
- - **Weighted account dispatch**: Replaces simple round-robin. Scoring formula: `score = quotaHealth×0.6 + tokenFreshness×0.2 + reliability×0.2`, always selects the healthiest account
599
- - **Background task detection & downgrade**: Multi-signal weighted detection (tool_calls +0.5, tool role +0.4, assistant density +0.2, long conversation +0.1). Score ≥ 0.6 identifies agent requests, which can be auto-downgraded to cheaper models (e.g. claude-sonnet-4-5 → gemini-2.5-flash). Enable via `ANTIGRAVITY_BACKGROUND_DOWNGRADE=1` env var (off by default)
600
- - **Dual-endpoint auto-switching**: Daily sandbox and production endpoints; automatically switches on failure
601
- - **Exponential backoff retry**: Auto-retry on 429/503 errors; short intervals stay on the same endpoint, longer intervals switch endpoints
602
-
603
- #### Background Downgrade Environment Variable
604
-
605
- | Variable | Default | Description |
606
- |----------|---------|-------------|
607
- | `ANTIGRAVITY_BACKGROUND_DOWNGRADE` | `0` (off) | Set to `1` to enable automatic model downgrade for agent/background requests |
608
-
609
- Downgrade mapping:
610
-
611
- | Original Model | Downgraded To |
612
- |----------------|---------------|
613
- | `claude-sonnet-4-5` | `gemini-2.5-flash` |
614
- | `claude-sonnet-4-5-thinking` | `gemini-2.5-flash-thinking` |
615
- | `claude-opus-4-5-thinking` | `claude-sonnet-4-5-thinking` |
616
- | `gemini-2.5-pro` | `gemini-2.5-flash` |
617
- | `gemini-3-pro-high` | `gemini-3-flash` |
618
- | `gemini-3-pro-low` | `gemini-3-flash` |
619
-
620
- Clients can also explicitly mark background requests via the `X-Request-Type: background` header, bypassing detection entirely.
621
-
622
347
  ### Request Logging
623
348
 
624
349
  Each API request outputs a log line with model name, status code, and duration:
@@ -648,7 +373,6 @@ Built-in retry for transient network errors (TLS disconnect, connection reset, e
648
373
  | `auth` | Run GitHub authentication only |
649
374
  | `logout` | Clear saved credentials |
650
375
  | `proxy` | Configure proxy settings |
651
- | `antigravity` | Manage Google Antigravity accounts |
652
376
  | `check-usage` | View Copilot usage |
653
377
  | `debug` | Show debug information |
654
378
 
@@ -660,11 +384,6 @@ Built-in retry for transient network errors (TLS disconnect, connection reset, e
660
384
  | `--verbose` | `-v` | false | Verbose logging |
661
385
  | `--account-type` | `-a` | individual | Account type (individual/business/enterprise) |
662
386
  | `--claude-code` | `-c` | false | Generate Claude Code launch command |
663
- | `--zen` | `-z` | false | Enable OpenCode Zen mode |
664
- | `--zen-api-key` | - | - | Zen API Key |
665
- | `--antigravity` | - | false | Enable Google Antigravity mode |
666
- | `--antigravity-client-id` | - | - | Antigravity OAuth Client ID |
667
- | `--antigravity-client-secret` | - | - | Antigravity OAuth Client Secret |
668
387
  | `--rate-limit` | `-r` | - | Request interval (seconds) |
669
388
  | `--wait` | `-w` | false | Wait instead of error when rate limited |
670
389
  | `--manual` | - | false | Manually approve each request |
@@ -691,29 +410,10 @@ Built-in retry for transient network errors (TLS disconnect, connection reset, e
691
410
  | Option | Alias | Description |
692
411
  |--------|-------|-------------|
693
412
  | `--github` | `-g` | Clear GitHub Copilot credentials only |
694
- | `--zen` | `-z` | Clear Zen credentials only |
695
- | `--antigravity` | - | Clear Antigravity credentials only |
696
413
  | `--all` | `-a` | Clear all credentials |
697
414
 
698
415
  > **Tip**: Running `logout` without arguments shows an interactive menu.
699
416
 
700
- ### antigravity Subcommands
701
-
702
- | Subcommand | Description |
703
- |------------|-------------|
704
- | `add` | Add a new Antigravity account (OAuth login) |
705
- | `list` | List all configured accounts and their status |
706
- | `remove <index>` | Remove account by index |
707
- | `clear` | Clear all Antigravity accounts (requires confirmation) |
708
-
709
- ```bash
710
- # Examples
711
- npx copilot-api-plus@latest antigravity add # Add account
712
- npx copilot-api-plus@latest antigravity list # List accounts
713
- npx copilot-api-plus@latest antigravity remove 0 # Remove account at index 0
714
- npx copilot-api-plus@latest antigravity clear # Clear all accounts
715
- ```
716
-
717
417
  ---
718
418
 
719
419
  ## 🐳 Docker Deployment
@@ -776,8 +476,6 @@ All data is stored in `~/.local/share/copilot-api-plus/`:
776
476
  | File | Description |
777
477
  |------|-------------|
778
478
  | `github_token` | GitHub Token |
779
- | `zen-auth.json` | Zen API Key |
780
- | `antigravity-accounts.json` | Antigravity accounts |
781
479
  | `config.json` | Proxy and other settings |
782
480
 
783
481
  ### Switching Accounts
@@ -791,12 +489,6 @@ npx copilot-api-plus@latest logout --github
791
489
  # Or shorthand
792
490
  npx copilot-api-plus@latest logout -g
793
491
 
794
- # Clear Zen credentials
795
- npx copilot-api-plus@latest logout --zen
796
-
797
- # Clear Antigravity credentials
798
- npx copilot-api-plus@latest logout --antigravity
799
-
800
492
  # Clear all credentials
801
493
  npx copilot-api-plus@latest logout --all
802
494
  ```