-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Conversation
@Huoyuuu
Huoyuuu
force-pushed
the
add-configurable-openai-headers
branch
from
June 15, 2026 17:28
1831925 to
a41fbc9
Compare
Some OpenAI-compatible relay/NewAPI providers sit behind WAF or Cloudflare rules that may block requests using the SDK default request headers. Allow users to configure additional HTTP headers, such as a custom User-Agent, without patching the extension source code. Changes: - add a top-level `headers` setting and normalize string header values - merge user and project headers with project-level precedence - pass configured headers to the OpenAI SDK via `defaultHeaders` - include headers in the shared client cache key - document the setting with a User-Agent example - add resolver coverage for header merging behavior Validation: - npx tsx --test src/tests/settings-and-notify.test.ts - npm run typecheck - npm run bundle
@Huoyuuu
Huoyuuu
force-pushed
the
add-configurable-openai-headers
branch
from
June 15, 2026 17:31
a41fbc9 to
505972d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
概述
本 PR 为 OpenAI 兼容接口新增可配置 HTTP Headers 的能力。
部分 NewAPI / 中转站部署在 WAF 或 Cloudflare 之后,可能会根据请求头拦截 SDK 默认请求,尤其是默认的 SDK
User-Agent。本次改动允许用户直接在~/.deepcode/settings.json或./.deepcode/settings.json中配置额外 headers,例如自定义User-Agent,无需修改扩展源码即可兼容这类中转站。已完成的工作
headers配置,并仅保留字符串类型的 header 值。headers传递给 OpenAI SDK 的defaultHeaders。headers纳入共享客户端缓存 key,确保 headers 变更后会重新创建客户端。docs/guide.md中补充headers配置示例和说明。配置示例
{ "env": { "MODEL": "deepseek-v4-pro", "BASE_URL": "https://example.com/v1", "API_KEY": "sk-..." }, "headers": { "User-Agent": "Mozilla/5.0 ..." }, "thinkingEnabled": true, "reasoningEffort": "max" }验证命令
说明
headers会覆盖用户级同名 header。User-Agent或其他请求头的 OpenAI 兼容中转站。