diff --git a/src/anthropic/anthropic-proxy.controller.ts b/src/anthropic/anthropic-proxy.controller.ts index bd54ce1..b5b974b 100644 --- a/src/anthropic/anthropic-proxy.controller.ts +++ b/src/anthropic/anthropic-proxy.controller.ts @@ -17,7 +17,7 @@ export class AnthropicProxyController { @Inject() private readonly service: AnthropicProxyService; - @Post('/anthropic/v1/chat/completions') + @Post('/anthropic/v1/messages') @HttpCode(200) async chatCompletion(@Body() body: any, @Headers() headers: any) { const result = await this.service.chatCompletion(body, headers); diff --git a/src/anthropic/anthropic-proxy.service.ts b/src/anthropic/anthropic-proxy.service.ts index a05d3bb..d0eb21a 100644 --- a/src/anthropic/anthropic-proxy.service.ts +++ b/src/anthropic/anthropic-proxy.service.ts @@ -13,7 +13,7 @@ export class AnthropicProxyService { private readonly configService: ConfigService; async chatCompletion(body: any, headers: any) { - const url = 'https://api.anthropic.com/v1/chat/completions'; + const url = 'https://api.anthropic.com/v1/messages'; return this.makeRequest(url, headers, body, body.stream); } @@ -58,8 +58,9 @@ export class AnthropicProxyService { httpsAgent, method: 'POST', headers: { - ...headers, - Host: 'api.anthropic.com', + 'Content-Type': 'application/json', + 'anthropic-version': headers['anthropic-version'], + 'x-api-key': headers['x-api-key'], }, responseType: stream ? 'stream' : 'json', data: body,