修正Anthropic端点授权转发逻辑:统一使用authorization header转发到上游端点

This commit is contained in:
1e0n
2025-10-09 15:21:42 +08:00
parent 27fdb7e157
commit e0129b7a83

View File

@@ -163,6 +163,7 @@ export function getAnthropicHeaders(authHeader, clientHeaders = {}, isStreaming
'accept': 'application/json',
'content-type': 'application/json',
'anthropic-version': clientHeaders['anthropic-version'] || '2023-06-01',
'authorization': authHeader || '',
'x-api-provider': 'anthropic',
'x-factory-client': 'cli',
'x-session-id': sessionId,
@@ -170,14 +171,6 @@ export function getAnthropicHeaders(authHeader, clientHeaders = {}, isStreaming
'user-agent': getUserAgent(),
'x-stainless-timeout': '600',
'connection': 'keep-alive'
};
// Prefer client-provided x-api-key for anthropic endpoint format
if (clientHeaders['x-api-key']) {
headers['x-api-key'] = clientHeaders['x-api-key'];
} else if (authHeader) {
// If no client x-api-key, use authorization header (from FACTORY_API_KEY or refresh token)
headers['authorization'] = authHeader;
}
// Handle anthropic-beta header based on reasoning configuration