@dianshuv/copilot-api 0.8.1 → 0.9.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.
Files changed (3) hide show
  1. package/README.md +32 -29
  2. package/dist/main.mjs +982 -1169
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -15,7 +15,6 @@
15
15
  - **Graceful shutdown**: 4-phase shutdown sequence — stops accepting requests, waits for in-flight requests to complete, sends abort signal, then force-closes. Configurable via `--shutdown-graceful-wait` and `--shutdown-abort-wait`.
16
16
  - **Stream repetition detection**: Detects when models get stuck in repetitive output loops using KMP-based pattern matching and logs a warning.
17
17
  - **Stale request reaping**: Automatically force-fails requests that exceed a configurable maximum age (default 600s) to prevent resource leaks.
18
- - **Gemini API compatibility**: `/v1beta/models` endpoints translate Gemini API requests to OpenAI format for Copilot. Enables Google Gemini CLI to use Copilot models via `GOOGLE_GEMINI_BASE_URL` environment variable.
19
18
  - **PostHog analytics**: Optional PostHog Cloud integration (`--posthog-key`) sends per-request token usage events for long-term trend analysis. Free tier (1M events/month) is more than sufficient for individual use.
20
19
 
21
20
  ## Quick Start
@@ -70,6 +69,7 @@ make down
70
69
  | `--github-token`, `-g` | Provide GitHub token directly | none |
71
70
  | `--claude-code`, `-c` | Generate Claude Code launch command | false |
72
71
  | `--show-token` | Show tokens on fetch/refresh | false |
72
+ | `--show-all-models` | Show all upstream models including the hardcoded blacklist (see "Hidden Models" below) | false |
73
73
  | `--proxy-env` | Use proxy from environment | false |
74
74
  | `--no-history` | Disable request history UI at `/history` | false |
75
75
  | `--history-limit` | Max history entries in memory | 1000 |
@@ -81,6 +81,35 @@ make down
81
81
  | `--timezone-offset` | Timezone offset in hours from UTC for log timestamps (e.g., +8, -5, 0) | +8 |
82
82
  | `--posthog-key` | PostHog API key for token usage analytics (opt-in) | none |
83
83
 
84
+ ### Hidden Models
85
+
86
+ By default the proxy hides 30 stale / duplicate / unused upstream model ids from
87
+ its **listing surfaces** (`/v1/models`, the startup banner, and the
88
+ `--claude-code` interactive prompts). Pass `--show-all-models` to see the full
89
+ upstream catalogue.
90
+
91
+ **Important**: this is a *display* filter only. The remaining POST endpoints
92
+ (`/v1/chat/completions`, `/v1/messages`, `/v1/responses`) do **not** reject
93
+ hidden ids — an explicit `POST` with a hidden id is still forwarded to
94
+ upstream verbatim, even without `--show-all-models`. (The embedding and
95
+ Gemini ids in the list have no callable endpoint in this proxy at all;
96
+ they're hidden purely to denoise the `/v1/models` listing — the upstream
97
+ `/models` catalogue still returns them.)
98
+
99
+ To change the blacklist, edit `src/lib/hidden-models.ts` and re-publish (this
100
+ fork uses `/publish`).
101
+
102
+ Currently hidden (grouped):
103
+
104
+ - **Legacy GPT** — `gpt-3.5-turbo`, `gpt-3.5-turbo-0613`, `gpt-4`, `gpt-4-0613`, `gpt-4-0125-preview`
105
+ - **GPT-4o family** — `gpt-4o`, `gpt-4o-mini`, `gpt-4-o-preview`, `gpt-4o-2024-05-13`, `gpt-4o-2024-08-06`, `gpt-4o-2024-11-20`, `gpt-4o-mini-2024-07-18`
106
+ - **GPT-4.1 family** — `gpt-4.1`, `gpt-4.1-2025-04-14`, `gpt-41-copilot`
107
+ - **Older / smaller GPT-5** — `gpt-5-mini`, `gpt-5.3-codex`, `gpt-5.4`
108
+ - **All embeddings** — `text-embedding-ada-002`, `text-embedding-3-small`, `text-embedding-3-small-inference`
109
+ - **Older Gemini** — `gemini-2.5-pro`, `gemini-3-flash-preview`
110
+ - **Older / variant Claude** — `claude-opus-4.5`, `claude-opus-4.6`, `claude-opus-4.7-high`, `claude-opus-4.7-xhigh`, `claude-sonnet-4.5`
111
+ - **Special-purpose** — `mai-code-1-flash-internal`, `trajectory-compaction`
112
+
84
113
  ### Patch-Claude Command Options
85
114
 
86
115
  | Option | Description | Default |
@@ -98,7 +127,6 @@ make down
98
127
  |----------|--------|-------------|
99
128
  | `/v1/chat/completions` | POST | Chat completions |
100
129
  | `/v1/models` | GET | List available models |
101
- | `/v1/embeddings` | POST | Text embeddings |
102
130
  | `/v1/responses` | POST | Responses API (for codex models) |
103
131
 
104
132
  ### Anthropic Compatible
@@ -109,14 +137,6 @@ make down
109
137
  | `/v1/messages/count_tokens` | POST | Token counting |
110
138
  | `/v1/event_logging/batch` | POST | Event logging (no-op) |
111
139
 
112
- ### Gemini Compatible
113
-
114
- | Endpoint | Method | Description |
115
- |----------|--------|-------------|
116
- | `/v1beta/models/{model}:generateContent` | POST | Non-streaming generation |
117
- | `/v1beta/models/{model}:streamGenerateContent` | POST | Streaming generation (SSE) |
118
- | `/v1beta/models/{model}:countTokens` | POST | Token counting |
119
-
120
140
  ### Utility
121
141
 
122
142
  | Endpoint | Method | Description |
@@ -146,8 +166,8 @@ Create `.claude/settings.json` in your project:
146
166
  "env": {
147
167
  "ANTHROPIC_BASE_URL": "http://localhost:4141",
148
168
  "ANTHROPIC_AUTH_TOKEN": "dummy",
149
- "ANTHROPIC_MODEL": "gpt-4.1",
150
- "ANTHROPIC_SMALL_FAST_MODEL": "gpt-4.1",
169
+ "ANTHROPIC_MODEL": "claude-opus-4.8",
170
+ "ANTHROPIC_SMALL_FAST_MODEL": "claude-haiku-4.5",
151
171
  "DISABLE_NON_ESSENTIAL_MODEL_CALLS": "1",
152
172
  "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
153
173
  },
@@ -163,23 +183,6 @@ Or use the interactive setup:
163
183
  bun run start --claude-code
164
184
  ```
165
185
 
166
- ## Using with Gemini CLI
167
-
168
- ```bash
169
- # Start the proxy
170
- copilot-api start
171
-
172
- # Configure Gemini CLI to use the proxy
173
- export GEMINI_API_KEY="placeholder"
174
- export GOOGLE_GEMINI_BASE_URL="http://localhost:4141"
175
-
176
- # Basic conversation
177
- gemini -p "Explain this code"
178
-
179
- # Pipe review
180
- git diff HEAD~1 | gemini -p "Review this diff for bugs"
181
- ```
182
-
183
186
  ## Upstream Project
184
187
 
185
188
  For the original project documentation, features, and updates, see: [ericc-ch/copilot-api](https://github.com/ericc-ch/copilot-api)