修正Anthropic端点授权转发逻辑:统一使用authorization header转发到上游端点
This commit is contained in:
@@ -163,6 +163,7 @@ export function getAnthropicHeaders(authHeader, clientHeaders = {}, isStreaming
|
|||||||
'accept': 'application/json',
|
'accept': 'application/json',
|
||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
'anthropic-version': clientHeaders['anthropic-version'] || '2023-06-01',
|
'anthropic-version': clientHeaders['anthropic-version'] || '2023-06-01',
|
||||||
|
'authorization': authHeader || '',
|
||||||
'x-api-provider': 'anthropic',
|
'x-api-provider': 'anthropic',
|
||||||
'x-factory-client': 'cli',
|
'x-factory-client': 'cli',
|
||||||
'x-session-id': sessionId,
|
'x-session-id': sessionId,
|
||||||
@@ -170,14 +171,6 @@ export function getAnthropicHeaders(authHeader, clientHeaders = {}, isStreaming
|
|||||||
'user-agent': getUserAgent(),
|
'user-agent': getUserAgent(),
|
||||||
'x-stainless-timeout': '600',
|
'x-stainless-timeout': '600',
|
||||||
'connection': 'keep-alive'
|
'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
|
// Handle anthropic-beta header based on reasoning configuration
|
||||||
|
|||||||
Reference in New Issue
Block a user