fix: avoid sending empty anthropic-beta header (#11619)

Signed-off-by: f14xuanlv <2606574933@qq.com>
This commit is contained in:
f14XuanLv 2025-12-02 12:53:09 +08:00 committed by GitHub
parent 3e6dc56196
commit 3aedf6f138
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -177,8 +177,12 @@ export async function buildStreamTextParams(
let headers: Record<string, string | undefined> = options.requestOptions?.headers ?? {}
if (isAnthropicModel(model) && !isAwsBedrockProvider(provider)) {
const newBetaHeaders = { 'anthropic-beta': addAnthropicHeaders(assistant, model).join(',') }
headers = combineHeaders(headers, newBetaHeaders)
const betaHeaders = addAnthropicHeaders(assistant, model)
// Only add the anthropic-beta header if there are actual beta headers to include
if (betaHeaders.length > 0) {
const newBetaHeaders = { 'anthropic-beta': betaHeaders.join(',') }
headers = combineHeaders(headers, newBetaHeaders)
}
}
// 构建基础参数