File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
packages/cost/models/providers Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -23,20 +23,22 @@ export class AnthropicProvider extends BaseProvider {
2323 _modelProviderConfig : ModelProviderConfig ,
2424 userConfig : UserEndpointConfig
2525 ) : string {
26- if ( userConfig . gatewayMapping === "NO_MAPPING" ) {
27- return "https://api.anthropic.com/v1/messages" ;
28- }
2926 return "https://api.anthropic.com/v1/messages" ;
3027 }
3128
3229 authenticate ( context : AuthContext ) : AuthResult {
3330 const headers : Record < string , string > = { } ;
3431 headers [ "x-api-key" ] = context . apiKey || "" ;
35- headers [ "anthropic-version" ] = "2023-06-01" ;
32+ if ( context . bodyMapping === "OPENAI" ) {
33+ headers [ "anthropic-version" ] = "2023-06-01" ;
34+ } // if NO_MAPPING, then we can assume the header is already added (e.g by anthropic SDK)
3635 return { headers } ;
3736 }
3837
3938 buildRequestBody ( endpoint : Endpoint , context : RequestBodyContext ) : string {
39+ if ( context . bodyMapping === "NO_MAPPING" ) {
40+ return JSON . stringify ( context . parsedBody ) ; // return without mapping
41+ }
4042 const anthropicBody = context . toAnthropic ( context . parsedBody ) ;
4143 const updatedBody = {
4244 ...anthropicBody ,
You can’t perform that action at this time.
0 commit comments