diff --git a/README.md b/README.md index 7f99c993..ed09837f 100644 --- a/README.md +++ b/README.md @@ -490,23 +490,16 @@ name = "crs" base_url = "http://127.0.0.1:3000/openai" # 根据实际填写你服务器的ip地址或者域名 wire_api = "responses" requires_openai_auth = true -env_key = "CRS_OAI_KEY" ``` 在 `~/.codex/auth.json` 文件中配置API密钥为 null: ```json { - "OPENAI_API_KEY": null + "OPENAI_API_KEY": "后台创建的API密钥" } ``` -环境变量设置: - -```bash -export CRS_OAI_KEY="后台创建的API密钥" -``` - > ⚠️ 在通过 Nginx 反向代理 CRS 服务并使用 Codex CLI 时,需要在 http 块中添加 underscores_in_headers on;。因为 Nginx 默认会移除带下划线的请求头(如 session_id),一旦该头被丢弃,多账号环境下的粘性会话功能将失效。 **Droid CLI 配置:** diff --git a/VERSION b/VERSION index 0aff1c08..7756c8c1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.271 +1.1.272 diff --git a/src/services/relay/claudeRelayService.js b/src/services/relay/claudeRelayService.js index 11a0bbad..71e8aaa5 100644 --- a/src/services/relay/claudeRelayService.js +++ b/src/services/relay/claudeRelayService.js @@ -1028,6 +1028,9 @@ class ClaudeRelayService { } } + // 移除 x-anthropic-billing-header 系统元素,避免将客户端 billing 标识传递给上游 API + this._removeBillingHeaderFromSystem(processedBody) + this._enforceCacheControlLimit(processedBody) // 处理原有的系统提示(如果配置了) @@ -1092,6 +1095,39 @@ class ClaudeRelayService { } } + // 🧹 移除 billing header 系统提示元素 + _removeBillingHeaderFromSystem(processedBody) { + if (!processedBody || !processedBody.system) { + return + } + + if (typeof processedBody.system === 'string') { + if (processedBody.system.trim().startsWith('x-anthropic-billing-header')) { + logger.debug('🧹 Removed billing header from string system prompt') + delete processedBody.system + } + return + } + + if (Array.isArray(processedBody.system)) { + const originalLength = processedBody.system.length + processedBody.system = processedBody.system.filter( + (item) => + !( + item && + item.type === 'text' && + typeof item.text === 'string' && + item.text.trim().startsWith('x-anthropic-billing-header') + ) + ) + if (processedBody.system.length < originalLength) { + logger.debug( + `🧹 Removed ${originalLength - processedBody.system.length} billing header element(s) from system array` + ) + } + } + } + // 🔢 验证并限制max_tokens参数 _validateAndLimitMaxTokens(body) { if (!body || !body.max_tokens) { diff --git a/web/admin-spa/src/components/tutorial/CodexTutorial.vue b/web/admin-spa/src/components/tutorial/CodexTutorial.vue index 3601c160..4ba5409f 100644 --- a/web/admin-spa/src/components/tutorial/CodexTutorial.vue +++ b/web/admin-spa/src/components/tutorial/CodexTutorial.vue @@ -67,16 +67,14 @@ class="overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm" >
- ⚠️ 必须将 OPENAI_API_KEY 设置为 null,否则 Codex 会优先使用它而忽略环境变量! -
-一键写入命令:
- 设置环境变量 CRS_OAI_KEY 为您的 API 密钥(格式如 cr_xxxxxxxxxx): -
- - - -- 系统级环境变量(推荐): -
-- 用户级环境变量 - (不推荐) -
-- 💡 设置后需要重新打开终端窗口才能生效 -
- - - - -
- 检查当前 shell:echo $SHELL
-
- 如果之前配置过,建议先检查并清理旧配置: -
-- 如果有输出,说明已配置过,可以手动编辑文件修改或删除旧配置 -
-- {{ platform === 'macos' ? 'zsh (macOS 默认)' : 'bash (Linux 默认)' }}: -
-- {{ platform === 'macos' ? 'bash' : 'zsh' }}: -
-- 💡 设置后需要重新打开终端窗口或执行 source 命令才能生效 -
- -- 重新打开终端后,验证环境变量是否设置成功: -
-删除用户级环境变量:
-删除系统级环境变量:
-从 zsh 配置中删除:
-从 bash 配置中删除:
-验证是否删除成功:
-