Skip to content

Commit 4394eae

Browse files
authored
Merge branch 'main' into feat/aws-assume-role-setup
2 parents 6aae092 + f02f521 commit 4394eae

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/providers/anthropic/api.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@ import { ProviderAPIConfig } from '../types';
22

33
const AnthropicAPIConfig: ProviderAPIConfig = {
44
getBaseURL: () => 'https://api.anthropic.com/v1',
5-
headers: ({ providerOptions, fn }) => {
5+
headers: ({ providerOptions, fn, gatewayRequestBody }) => {
66
const headers: Record<string, string> = {
77
'X-API-Key': `${providerOptions.apiKey}`,
88
};
99

10+
// Accept anthropic_beta and anthropic_version in body to support enviroments which cannot send it in headers.
1011
const betaHeader =
11-
providerOptions?.['anthropicBeta'] ?? 'messages-2023-12-15';
12-
const version = providerOptions?.['anthropicVersion'] ?? '2023-06-01';
12+
providerOptions?.['anthropicBeta'] ??
13+
gatewayRequestBody?.['anthropic_beta'] ??
14+
'messages-2023-12-15';
15+
const version =
16+
providerOptions?.['anthropicVersion'] ??
17+
gatewayRequestBody?.['anthropic_version'] ??
18+
'2023-06-01';
1319

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

src/types/requestBody.ts

+3
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ export interface Params {
317317
};
318318
// Google Vertex AI specific
319319
safety_settings?: any;
320+
// Anthropic specific
321+
anthropic_beta?: string;
322+
anthropic_version?: string;
320323
}
321324

322325
interface Examples {

0 commit comments

Comments
 (0)