Skip to content

Commit 6bf69a2

Browse files
fix
1 parent 05f0550 commit 6bf69a2

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/providers/anthropic/api.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,23 @@ import { ProviderAPIConfig } from '../types';
22

33
const AnthropicAPIConfig: ProviderAPIConfig = {
44
getBaseURL: () => 'https://api.anthropic.com/v1',
5-
headers: ({ providerOptions, fn, headers: requestHeaders }) => {
5+
6+
headers: ({ providerOptions, fn, headers: requestHeaders, gatewayRequestBody }) => {
67
const apiKey =
78
providerOptions.apiKey || requestHeaders?.['x-api-key'] || '';
89
const headers: Record<string, string> = {
910
'X-API-Key': apiKey,
1011
};
11-
12+
13+
// Accept anthropic_beta and anthropic_version in body to support enviroments which cannot send it in headers.
1214
const betaHeader =
13-
providerOptions?.['anthropicBeta'] ?? 'messages-2023-12-15';
14-
const version = providerOptions?.['anthropicVersion'] ?? '2023-06-01';
15+
providerOptions?.['anthropicBeta'] ??
16+
gatewayRequestBody?.['anthropic_beta'] ??
17+
'messages-2023-12-15';
18+
const version =
19+
providerOptions?.['anthropicVersion'] ??
20+
gatewayRequestBody?.['anthropic_version'] ??
21+
'2023-06-01';
1522

1623
if (fn === 'chatComplete') {
1724
headers['anthropic-beta'] = betaHeader;

0 commit comments

Comments
 (0)