Skip to content

Commit

Permalink
fix anthropic completion endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
windmemory committed Nov 21, 2024
1 parent 491ae48 commit 4536205
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/anthropic/anthropic-proxy.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions src/anthropic/anthropic-proxy.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 4536205

Please sign in to comment.