File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -2,16 +2,23 @@ import { ProviderAPIConfig } from '../types';
22
33const 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 ;
You can’t perform that action at this time.
0 commit comments