@nick3/copilot-api 1.10.29 → 1.10.34
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 +41 -9
- package/README.zh-CN.md +39 -7
- package/dist/admin/assets/index-Cl_ViIW_.js +110 -0
- package/dist/admin/index.html +1 -1
- package/dist/{auth-nO-eHeO_.js → auth-Cc11G9V9.js} +2 -2
- package/dist/{auth-nO-eHeO_.js.map → auth-Cc11G9V9.js.map} +1 -1
- package/dist/{check-usage-ZifYvA3w.js → check-usage-C2QE6R93.js} +2 -2
- package/dist/{check-usage-ZifYvA3w.js.map → check-usage-C2QE6R93.js.map} +1 -1
- package/dist/{config-CmhIPHn_.js → config-BaU_aWgi.js} +35 -4
- package/dist/config-BaU_aWgi.js.map +1 -0
- package/dist/{debug-DvpksqEL.js → debug-BKqoXB_p.js} +2 -2
- package/dist/{debug-DvpksqEL.js.map → debug-BKqoXB_p.js.map} +1 -1
- package/dist/main.js +4 -4
- package/dist/{responses-bridge-registry-BJ5Sbh6-.js → responses-bridge-registry-DqCoY6Ex.js} +14 -7
- package/dist/responses-bridge-registry-DqCoY6Ex.js.map +1 -0
- package/dist/{server-DJ3_UGc4.js → server-C7pCkArb.js} +636 -187
- package/dist/server-C7pCkArb.js.map +1 -0
- package/dist/{start-DaB0AcjZ.js → start-CdLbBkRA.js} +4 -4
- package/dist/{start-DaB0AcjZ.js.map → start-CdLbBkRA.js.map} +1 -1
- package/dist/token-671YFxgv.js +947 -0
- package/dist/token-671YFxgv.js.map +1 -0
- package/package.json +2 -2
- package/dist/admin/assets/index-BAh4eOwM.js +0 -110
- package/dist/config-CmhIPHn_.js.map +0 -1
- package/dist/responses-bridge-registry-BJ5Sbh6-.js.map +0 -1
- package/dist/server-DJ3_UGc4.js.map +0 -1
- package/dist/token-DrFDLVxa.js +0 -365
- package/dist/token-DrFDLVxa.js.map +0 -1
package/README.md
CHANGED
|
@@ -439,10 +439,38 @@ The `<target>` can be either the account ID (GitHub login) or a 1-based index.
|
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
|
-
}
|
|
442
|
+
},
|
|
443
|
+
"modelMappings": {},
|
|
444
|
+
"extraPrompts": {
|
|
445
|
+
"gpt-5-mini": "<built-in exploration prompt>",
|
|
446
|
+
"gpt-5.3-codex": "<built-in commentary prompt>",
|
|
447
|
+
"gpt-5.4-mini": "<built-in commentary prompt>",
|
|
448
|
+
"gpt-5.4": "<built-in commentary prompt>",
|
|
449
|
+
"gpt-5.5": "<built-in commentary prompt>"
|
|
450
|
+
},
|
|
451
|
+
"smallModel": "gpt-5-mini",
|
|
452
|
+
"useResponsesApiContextManagement": true,
|
|
453
|
+
"modelResponsesApiCompactThresholds": {
|
|
454
|
+
"gpt-5.4": 217600,
|
|
455
|
+
"gpt-5.5": 217600
|
|
456
|
+
},
|
|
457
|
+
"modelReasoningEfforts": {
|
|
458
|
+
"gpt-5-mini": "low",
|
|
459
|
+
"gpt-5.3-codex": "xhigh",
|
|
460
|
+
"gpt-5.4-mini": "xhigh",
|
|
461
|
+
"gpt-5.4": "xhigh",
|
|
462
|
+
"gpt-5.5": "xhigh"
|
|
463
|
+
},
|
|
464
|
+
"useMessagesApi": true,
|
|
465
|
+
"useResponsesApiWebSocket": true,
|
|
466
|
+
"useResponsesApiWebSearch": true
|
|
443
467
|
}
|
|
444
468
|
```
|
|
445
|
-
- **
|
|
469
|
+
- **auth.apiKeys:** API keys used for request authentication on non-admin routes. Supports multiple keys for rotation. Requests can authenticate with either `x-api-key: <key>` or `Authorization: Bearer <key>`. If empty or omitted, authentication for non-admin routes is disabled.
|
|
470
|
+
- **auth.adminApiKey:** Single admin key used only for `/admin/*` routes. If missing, the server generates a random key at startup and writes it back to `config.json`. Requests use the same `x-api-key` or `Authorization: Bearer` headers, but regular `auth.apiKeys` never grant access to `/admin/*`.
|
|
471
|
+
- **modelMappings:** Exact `sourceModel -> targetModel` rewrites shared by top-level `POST /v1/messages`, `POST /v1/messages/count_tokens`, `POST /v1/responses`, and `POST /v1/chat/completions` requests. Omit it or leave it as `{}` to disable rewrites. Both the source and target must be non-empty strings. Targets can be regular model IDs or `provider/model` aliases such as `dashscope/qwen3.6-plus`, and the rewrite happens before provider alias parsing. These mappings are not split per interface. The admin endpoints `GET/POST /admin/config/model-mappings` read and update only this field.
|
|
472
|
+
- **extraPrompts:** Map of `model -> prompt` appended to the first system prompt when translating Anthropic-style requests to Copilot. Use this to inject guardrails or guidance per model. Missing default entries are auto-added without overwriting your custom prompts. The built-in prompts for `gpt-5.3-codex` and `gpt-5.4` enable phase-aware commentary, which lets the model emit a short user-facing progress update before tools or deeper reasoning.
|
|
473
|
+
- **providers:** Global upstream provider map. Each provider key (for example `dashscope`) becomes a route prefix (`/dashscope/v1/messages`). Supports `type: "anthropic"`, `type: "openai-compatible"`, and `type: "openai-responses"`. Top-level clients can also use `model: "dashscope/model-id"` with `/v1/messages`, `/v1/messages/count_tokens`, `/v1/responses`, and `/v1/chat/completions`; the gateway strips the `dashscope/` prefix before forwarding upstream. `GET /v1/models` does not aggregate provider models; use `GET /dashscope/v1/models` for provider model lists.
|
|
446
474
|
- `enabled` defaults to `true` if omitted.
|
|
447
475
|
- `baseUrl` should be provider API base URL without the final endpoint. For Anthropic providers, omit `/v1/messages`; for OpenAI-compatible providers, omit `/v1/chat/completions`.
|
|
448
476
|
- `apiKey` is used as the upstream credential value.
|
|
@@ -456,10 +484,13 @@ The `<target>` can be either the account ID (GitHub login) or a 1-based index.
|
|
|
456
484
|
- `contextCache` (optional): Defaults to `true` for OpenAI-compatible providers. This enables Alibaba Cloud Model Studio/DashScope explicit context cache by injecting `cache_control: { "type": "ephemeral" }` on up to 4 content blocks using the Context Cache format. The cache breakpoint strategy matches opencode's main provider flow: the first 2 system messages plus the last 2 non-system messages. Marked string content is converted to text content part arrays for `system` / `user` / `assistant` / `tool` messages; existing array content is marked on the last part. Set this to `false` when the model already supports implicit caching, or when the upstream does not accept this explicit-cache extension field.
|
|
457
485
|
- `supportPdf` (optional): Controls whether the model supports PDF/document content. Defaults to `false`; unsupported PDFs are converted to a text notice. Set it to `true` to send PDF/document blocks as OpenAI Chat Completions file parts.
|
|
458
486
|
- `toolContentSupportType` (optional): Tool result content capabilities for that model, as an array of `array`, `image`, and `pdf`. Provider routes default to string-only tool content when omitted. If `supportPdf` is `true` but this list does not include `pdf`, file parts in tool results are moved to user role messages. This provider default does not change the Copilot main flow, which continues to support array + image and not PDF.
|
|
459
|
-
- **responsesApiContextManagementModels:**
|
|
487
|
+
- **responsesApiContextManagementModels:** Deprecated legacy list of GPT model IDs that should receive Responses API `context_management` compaction instructions. Prefer `useResponsesApiContextManagement`, which now defaults to `true`.
|
|
488
|
+
- **useResponsesApiContextManagement:** When `true` (default), the proxy adds Responses API `context_management` compaction instructions. Set it to `false` to disable this globally. When enabled, the request includes `context_management` in the body and keeps only the latest compaction carrier on follow-up turns. This is especially useful for long-running tasks.
|
|
489
|
+
- **modelResponsesApiCompactThresholds:** Per-model Responses API `compact_threshold` overrides used when the proxy adds `context_management`. These values take precedence over the fallback threshold from `resolveResponsesCompactThreshold` (`max_prompt_tokens * ratio`, or the default fallback). Defaults set `gpt-5.4` and `gpt-5.5` to `217600` (`272000 * 0.8`). Models not listed continue to use the normal fallback logic.
|
|
460
490
|
- **smallModel:** Fallback model used for tool-less warmup messages, compact/background requests, and other short housekeeping turns (for example from Claude Code or OpenCode) to avoid spending premium requests; defaults to `gpt-5-mini`. If original names are blocked and this points to an aliased target, it resolves to the preferred alias.
|
|
461
491
|
- **accountAffinity:** Enable sticky account routing based on session identity. When enabled, requests from the same session for the same model are routed to the account that last handled them successfully. Applies to both free and premium models. Defaults to `true`. Set to `false` to use sequential routing for all models.
|
|
462
|
-
- **apiKey (deprecated):** Legacy single-key field kept for migration compatibility. Prefer `auth.apiKeys`. When `auth.apiKeys` is empty, the server falls back to `COPILOT_API_KEY` and then `apiKey
|
|
492
|
+
- **apiKey (deprecated):** Legacy single-key field kept for migration compatibility. Prefer `auth.apiKeys`. When `auth.apiKeys` is empty, the server falls back to `COPILOT_API_KEY` and then `apiKey`.
|
|
493
|
+
- **modelReasoningEfforts:** Per-model `reasoning.effort` sent to the Copilot Responses API. Allowed values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. If a model isn’t listed, `high` is used by default.
|
|
463
494
|
- **modelAliases:** Map of `alias -> { target, allowOriginal? }` (legacy string values are still accepted). Alias keys are normalized (trim + lowercase) and must be non-empty; aliases cannot map to themselves (case-insensitive), and conflicting normalized aliases are rejected. `allowOriginal` overrides the global default per alias. If multiple aliases map to the same target, original names are allowed when any alias sets `allowOriginal: true` (allow-wins). Admin UI/API rejects blocked keys (`__proto__`, `constructor`, `prototype`). Aliases can be used in downstream requests, and targets may be configured `provider/model` aliases for top-level `/v1/messages` and `/v1/messages/count_tokens` routing.
|
|
464
495
|
- **allowOriginalModelNamesForAliases:** Global default for aliases that omit `allowOriginal`. When `false` (default), targets are blocked unless an alias explicitly allows them; when `true`, targets are allowed unless all aliases explicitly block them.
|
|
465
496
|
- **forceAgent:** When `true`, `POST /v1/responses` treats a request as agent-initiated if **any** input item has `role: "assistant"`. When `false` (default), only the **last** input item is checked.
|
|
@@ -467,11 +498,12 @@ The `<target>` can be either the account ID (GitHub login) or a 1-based index.
|
|
|
467
498
|
- **messageStartInputTokensFallback:** When `true`, the Anthropic streaming translation layer estimates `message_start.input_tokens` when upstream stream events do not provide it. Defaults to `false`.
|
|
468
499
|
- **modelRefreshIntervalHours:** Interval for refreshing account model lists in the background. Set to `0` to disable refresh. Defaults to `24`.
|
|
469
500
|
- **sessionAffinityRetentionDays:** Number of days to retain session affinity bindings. Defaults to `7`.
|
|
470
|
-
- **useMessagesApi:** When `true` (default), Claude-family models that support Copilot
|
|
471
|
-
- **useResponsesApiWebSocket:** When `true` (default), outbound Copilot Responses API requests use Copilot
|
|
501
|
+
- **useMessagesApi:** When `true` (default), Claude-family models that support Copilot’s native `/v1/messages` endpoint may use the Messages API path. Set to `false` to skip the Messages API candidate and fall back to `/responses` (if supported) or `/chat/completions`.
|
|
502
|
+
- **useResponsesApiWebSocket:** When `true` (default), outbound Copilot Responses API requests use Copilot’s WebSocket transport for models that advertise `ws:/responses`; models that only advertise `/responses` continue to use HTTP. Set to `false` to disable upstream WebSocket routing. This does not disable the inbound Codex-compatible WebSocket listener on `/v1/responses`.
|
|
472
503
|
- **useResponsesApiWebSearch:** When `true` (default), `/v1/responses` keeps tools with `type: "web_search"` and forwards them upstream. Set to `false` to strip them before the Copilot request is sent.
|
|
504
|
+
- **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.
|
|
473
505
|
- **logLevel:** Controls handler file-log verbosity under `logs/*.log`. Allowed values: `error`, `warn`, `info`, `debug`. Defaults to `info`. Set it to `debug` when you need payload- or stream-level diagnostics written into file logs.
|
|
474
|
-
- **anthropicApiKey:** Optional 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
|
|
506
|
+
- **anthropicApiKey:** Optional 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, or if the upstream call fails, token counting falls back to local GPT tokenizer estimation controlled by `claudeTokenMultiplier`.
|
|
475
507
|
|
|
476
508
|
`--verbose` no longer implicitly enables debug-level file logging. If you need detailed handler logs under `logs/*.log`, explicitly set `"logLevel": "debug"` in `config.json`.
|
|
477
509
|
|
|
@@ -505,9 +537,9 @@ These endpoints mimic the OpenAI API structure.
|
|
|
505
537
|
|
|
506
538
|
| Endpoint | Method | Description |
|
|
507
539
|
| --------------------------- | ------ | ---------------------------------------------------------------- |
|
|
508
|
-
| `POST /v1/responses` | `POST` | OpenAI Most advanced interface for generating model responses.
|
|
540
|
+
| `POST /v1/responses` | `POST` | OpenAI Most advanced interface for generating model responses. Supports `provider/model` aliases for `openai-responses` providers. |
|
|
509
541
|
| `GET /v1/responses` | `WS` | Codex-compatible Responses WebSocket transport. |
|
|
510
|
-
| `POST /v1/chat/completions` | `POST` | Creates a model response for the given chat conversation.
|
|
542
|
+
| `POST /v1/chat/completions` | `POST` | Creates a model response for the given chat conversation. Supports `provider/model` aliases for `openai-compatible` providers. |
|
|
511
543
|
| `GET /v1/models` | `GET` | Lists the currently available models. |
|
|
512
544
|
| `POST /v1/embeddings` | `POST` | Creates an embedding vector representing the input text. |
|
|
513
545
|
|
package/README.zh-CN.md
CHANGED
|
@@ -448,10 +448,38 @@ MCP HTTP 的浏览器 CORS 默认只允许 loopback origin。可设置 `COPILOT_
|
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
|
-
}
|
|
451
|
+
},
|
|
452
|
+
"modelMappings": {},
|
|
453
|
+
"extraPrompts": {
|
|
454
|
+
"gpt-5-mini": "<built-in exploration prompt>",
|
|
455
|
+
"gpt-5.3-codex": "<built-in commentary prompt>",
|
|
456
|
+
"gpt-5.4-mini": "<built-in commentary prompt>",
|
|
457
|
+
"gpt-5.4": "<built-in commentary prompt>",
|
|
458
|
+
"gpt-5.5": "<built-in commentary prompt>"
|
|
459
|
+
},
|
|
460
|
+
"smallModel": "gpt-5-mini",
|
|
461
|
+
"useResponsesApiContextManagement": true,
|
|
462
|
+
"modelResponsesApiCompactThresholds": {
|
|
463
|
+
"gpt-5.4": 217600,
|
|
464
|
+
"gpt-5.5": 217600
|
|
465
|
+
},
|
|
466
|
+
"modelReasoningEfforts": {
|
|
467
|
+
"gpt-5-mini": "low",
|
|
468
|
+
"gpt-5.3-codex": "xhigh",
|
|
469
|
+
"gpt-5.4-mini": "xhigh",
|
|
470
|
+
"gpt-5.4": "xhigh",
|
|
471
|
+
"gpt-5.5": "xhigh"
|
|
472
|
+
},
|
|
473
|
+
"useMessagesApi": true,
|
|
474
|
+
"useResponsesApiWebSocket": true,
|
|
475
|
+
"useResponsesApiWebSearch": true
|
|
452
476
|
}
|
|
453
477
|
```
|
|
454
|
-
- **
|
|
478
|
+
- **auth.apiKeys:** 用于普通非 admin 路由的 API key。支持多个 key 轮换使用。请求可通过 `x-api-key: <key>` 或 `Authorization: Bearer <key>` 进行认证。若为空或省略,则普通路由的认证会被禁用。
|
|
479
|
+
- **auth.adminApiKey:** 仅用于 `/admin/*` 路由的单个 admin key。若未配置,服务会在启动时自动生成一个随机 key,并回写到 `config.json`。它同样使用 `x-api-key` 或 `Authorization: Bearer` 这两种头,但普通 `auth.apiKeys` 不能访问 `/admin/*`。
|
|
480
|
+
- **modelMappings:** 用于顶层 `POST /v1/messages`、`POST /v1/messages/count_tokens`、`POST /v1/responses` 和 `POST /v1/chat/completions` 请求的精确 `sourceModel -> targetModel` 重写映射,这几类接口共用同一份规则。省略该字段或保留为 `{}` 时,不会做模型重写。`source` 和 `target` 都必须是非空字符串。`target` 可以是普通模型 ID,也可以是 `provider/model` 形式的别名,例如 `dashscope/qwen3.6-plus`;重写发生在 provider alias 解析之前。这些映射不再按接口区分。`GET/POST /admin/config/model-mappings` 管理接口读写的也只有这个字段。
|
|
481
|
+
- **extraPrompts:** `model -> prompt` 的映射。把 Anthropic 风格请求翻译给 Copilot 时,会将其附加到第一条 system prompt 后面。你可以借此为不同模型注入护栏或指引。缺失的默认项会自动补齐,但不会覆盖你自定义的 prompt。内置的 `gpt-5.3-codex` 和 `gpt-5.4` prompt 会启用带阶段感知的 commentary,让模型在工具调用或更深层推理前先发出简短的用户可见进度说明。
|
|
482
|
+
- **providers:** 全局上游 provider 映射。每个 provider key(例如 `dashscope`)都会变成一个路由前缀(`/dashscope/v1/messages`)。支持 `type: "anthropic"`、`type: "openai-compatible"` 和 `type: "openai-responses"`。顶层客户端也可以在 `/v1/messages`、`/v1/messages/count_tokens`、`/v1/responses` 和 `/v1/chat/completions` 中使用 `model: "dashscope/model-id"`;AI gateway 会在转发上游前移除 `dashscope/` 前缀。`GET /v1/models` 不聚合 provider 模型;provider 模型列表请使用 `GET /dashscope/v1/models`。
|
|
455
483
|
- `enabled`:可选,若省略则默认为 `true`。
|
|
456
484
|
- `baseUrl`:provider API 的基础 URL,不要带结尾的 endpoint。Anthropic provider 不要带 `/v1/messages`;OpenAI 兼容 provider 不要带 `/v1/chat/completions`。
|
|
457
485
|
- `apiKey`:作为上游凭据值使用。
|
|
@@ -465,10 +493,13 @@ MCP HTTP 的浏览器 CORS 默认只允许 loopback origin。可设置 `COPILOT_
|
|
|
465
493
|
- `contextCache`:可选,OpenAI 兼容 provider 默认 `true`,用于启用阿里云百炼/DashScope 的显式缓存(explicit context cache),会按其 Context Cache 格式在最多 4 个 content block 上注入 `cache_control: { "type": "ephemeral" }`。缓存断点策略与 opencode 主链路保持一致:前 2 条 system 消息 + 最后 2 条非 system 消息。标记字符串 content 时会把 `system` / `user` / `assistant` / `tool` 消息转换为 text content part 数组;已有数组 content 则标记最后一个 part。如果模型本身已经支持隐式缓存,或上游不支持该显式缓存扩展字段,可在模型配置中设为 `false`。
|
|
466
494
|
- `supportPdf`:可选,控制该模型是否支持 PDF/document content。默认 `false`,不支持时会把 PDF 转成提示文本;设为 `true` 时会把 PDF/document 转成 OpenAI Chat Completions 的 file part。
|
|
467
495
|
- `toolContentSupportType`:可选,配置该模型的 tool result content 支持能力,值为 `array`、`image`、`pdf` 的数组。provider 侧未配置时默认只发送 string tool content。若 `supportPdf` 为 `true` 但这里不包含 `pdf`,tool result 里的 file part 会被转成 user role 消息。Copilot 主链路不使用这个 provider 默认,仍按 array + image 且不支持 PDF 的能力处理。
|
|
468
|
-
- **responsesApiContextManagementModels:**
|
|
496
|
+
- **responsesApiContextManagementModels:** 已弃用的旧配置,用于列出需要启用 Responses API `context_management` 压缩指令的 GPT 模型 ID。请优先使用 `useResponsesApiContextManagement`,该配置现在默认开启。
|
|
497
|
+
- **useResponsesApiContextManagement:** 当为 `true`(默认)时,代理会为 Responses API 附加 `context_management` 压缩指令。如需全局关闭,可设为 `false`。启用后,请求体会带上 `context_management`,并在后续轮次中仅保留最新的压缩承载内容,因此特别适合长任务场景。
|
|
498
|
+
- **modelResponsesApiCompactThresholds:** 按模型覆盖 Responses API 的 `compact_threshold`,仅在代理自动附加 `context_management` 时使用。它的优先级高于 `resolveResponsesCompactThreshold` 基于 `max_prompt_tokens * ratio` 的兜底阈值。默认将 `gpt-5.4` 和 `gpt-5.5` 设为 `217600`(`272000 * 0.8`)。未列出的模型继续使用原有兜底逻辑。
|
|
469
499
|
- **smallModel:** 用于无工具预热消息、compact/background 请求以及其他短小维护型轮次(例如 Claude Code 或 OpenCode 发出的 housekeeping 请求)的回退模型,用来避免消耗 premium requests;默认是 `gpt-5-mini`。如果原始模型名被屏蔽,而这里指向的是某个别名目标模型,则会解析为首选别名。
|
|
470
500
|
- **accountAffinity:** 是否根据 session 标识启用粘性账号路由。开启后,同一 session 针对同一模型的请求会优先路由到上次成功处理它的账号。该策略同时适用于免费模型和付费模型。默认值为 `true`。设为 `false` 则所有模型都改为顺序路由。
|
|
471
|
-
- **apiKey(已弃用):** 兼容迁移的旧单 key 字段。优先使用 `auth.apiKeys`。当 `auth.apiKeys` 为空时,服务端会回退到 `COPILOT_API_KEY`,再回退到 `apiKey
|
|
501
|
+
- **apiKey(已弃用):** 兼容迁移的旧单 key 字段。优先使用 `auth.apiKeys`。当 `auth.apiKeys` 为空时,服务端会回退到 `COPILOT_API_KEY`,再回退到 `apiKey`。
|
|
502
|
+
- **modelReasoningEfforts:** 按模型配置发送到 Copilot Responses API 的 `reasoning.effort`。可选值包括 `none`、`minimal`、`low`、`medium`、`high` 和 `xhigh`。若某模型未配置,则默认使用 `high`。
|
|
472
503
|
- **modelAliases:** `alias -> { target, allowOriginal? }` 的映射(也仍然接受旧的字符串写法)。别名 key 会先做标准化(trim + lowercase),且不能为空;别名不能映射回自己(大小写不敏感),冲突的标准化别名会被拒绝。`allowOriginal` 可为单个别名覆盖全局默认值。如果多个别名映射到同一个 target,只要其中任意一个设置了 `allowOriginal: true`,原始模型名就会被允许(allow-wins)。Admin UI/API 会拒绝被屏蔽的键(`__proto__`、`constructor`、`prototype`)。下游请求可以直接使用这些别名,target 也可以是 `provider/model` 形式,用于顶层 `/v1/messages` 与 `/v1/messages/count_tokens` 路由。
|
|
473
504
|
- **allowOriginalModelNamesForAliases:** 对未显式设置 `allowOriginal` 的别名所采用的全局默认值。当其为 `false`(默认)时,target 原名默认被屏蔽,除非某个别名显式允许;当其为 `true` 时,target 原名默认可用,除非所有别名都显式阻止。
|
|
474
505
|
- **forceAgent:** 当为 `true` 时,只要 `POST /v1/responses` 的任一 input item 带有 `role: "assistant"`,就会把请求视为由 agent 发起;当为 `false`(默认)时,只检查最后一个 input item。
|
|
@@ -479,8 +510,9 @@ MCP HTTP 的浏览器 CORS 默认只允许 loopback origin。可设置 `COPILOT_
|
|
|
479
510
|
- **useMessagesApi:** 当为 `true`(默认)时,支持 Copilot 原生 `/v1/messages` 端点的 Claude 系模型会走 Messages API 路径。设为 `false` 时,将跳过 Messages API 候选,回退到 `/responses`(如支持)或 `/chat/completions`。
|
|
480
511
|
- **useResponsesApiWebSocket:** 当为 `true`(默认)时,发往上游 Copilot Responses API 的请求会对声明了 `ws:/responses` 的模型使用 Copilot WebSocket transport;仅声明 `/responses` 的模型仍走 HTTP。设为 `false` 可禁用上游 WebSocket 路由。该配置不会禁用 `/v1/responses` 上面向 Codex 的入站 WebSocket listener。
|
|
481
512
|
- **useResponsesApiWebSearch:** 当为 `true`(默认)时,`/v1/responses` 会保留 `type: "web_search"` 的工具并转发到上游。设为 `false` 则会在发送 Copilot 请求之前将其剥离。
|
|
513
|
+
- **claudeTokenMultiplier:** 用于 Claude `/v1/messages/count_tokens` 请求在本地走 GPT tokenizer 估算时的乘数。默认值为 `1.15`。如果你的客户端仍然过晚触发上下文压缩,可以适当调大。这个配置只会在代理本地估算 Claude token 时生效;如果已经配置 `anthropicApiKey` 且 Anthropic token counting 调用成功,则会直接返回 Anthropic 的精确计数,不会使用这个乘数。
|
|
482
514
|
- **logLevel:** 控制 `logs/*.log` 下 handler 文件日志的详细级别。可选值:`error`、`warn`、`info`、`debug`。默认值为 `info`。如果你需要把 payload 级或 stream 级的调试内容写入文件日志,请显式设置为 `debug`。
|
|
483
|
-
- **anthropicApiKey:** 可选的 Anthropic API key,用于精确的 Claude token 计数(见下文 [精确的 Claude Token 计数](#accurate-claude-token-counting))。也可通过环境变量 `ANTHROPIC_API_KEY`
|
|
515
|
+
- **anthropicApiKey:** 可选的 Anthropic API key,用于精确的 Claude token 计数(见下文 [精确的 Claude Token 计数](#accurate-claude-token-counting))。也可通过环境变量 `ANTHROPIC_API_KEY` 设置。若未配置,或上游调用失败,则回退到由 `claudeTokenMultiplier` 控制的本地 GPT tokenizer 估算。
|
|
484
516
|
|
|
485
517
|
`--verbose` 不再隐式开启 debug 级别文件日志。如果你需要 `logs/*.log` 下更详细的 handler 日志,请在 `config.json` 中显式设置 `"logLevel": "debug"`。
|
|
486
518
|
|
|
@@ -514,9 +546,9 @@ curl http://localhost:4141/v1/models \
|
|
|
514
546
|
|
|
515
547
|
| 端点 | 方法 | 说明 |
|
|
516
548
|
| --- | --- | --- |
|
|
517
|
-
| `POST /v1/responses` | `POST` | OpenAI
|
|
549
|
+
| `POST /v1/responses` | `POST` | OpenAI 中用于生成模型响应的高级接口。支持 `openai-responses` provider 的 `provider/model` 别名。 |
|
|
518
550
|
| `GET /v1/responses` | `WS` | Codex 兼容的 Responses WebSocket transport。 |
|
|
519
|
-
| `POST /v1/chat/completions` | `POST` |
|
|
551
|
+
| `POST /v1/chat/completions` | `POST` | 为给定聊天对话创建模型响应。支持 `openai-compatible` provider 的 `provider/model` 别名。 |
|
|
520
552
|
| `GET /v1/models` | `GET` | 列出当前可用模型。 |
|
|
521
553
|
| `POST /v1/embeddings` | `POST` | 创建表示输入文本的向量嵌入。 |
|
|
522
554
|
|