From 476d297e4b2dd3015f7ebcbb915b643730816dc6 Mon Sep 17 00:00:00 2001 From: saianilsingi Date: Wed, 4 Feb 2026 15:52:53 +0530 Subject: [PATCH] fix(proxy): route Claude Code CLI requests on /v1/chat/completions to Anthropic handler (#61) * fix(proxy): route Claude models from chat completions to anthropic handler * style(proxy): minor formatting cleanup --- src/server/modules/proxy/proxy.controller.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/server/modules/proxy/proxy.controller.ts b/src/server/modules/proxy/proxy.controller.ts index ac94d32..744a6e7 100644 --- a/src/server/modules/proxy/proxy.controller.ts +++ b/src/server/modules/proxy/proxy.controller.ts @@ -44,6 +44,24 @@ export class ProxyController { @Post('chat/completions') async chatCompletions(@Body() body: OpenAIChatRequest, @Res() res: FastifyReply) { try { + // Claude Code CLI compatibility: + // Claude CLI uses OpenAI-style /v1/chat/completions + if (body.model?.startsWith('claude-')) { + const result = await this.proxyService.handleAnthropicMessages( + body as unknown as AnthropicChatRequest, + ); + + if (body.stream && result instanceof Observable) { + res.header('Content-Type', 'text/event-stream'); + res.header('Cache-Control', 'no-cache'); + res.header('Connection', 'keep-alive'); + res.send(result); + } else { + res.status(HttpStatus.OK).send(result); + } + return; + } + const result = await this.proxyService.handleChatCompletions(body); if (body.stream && result instanceof Observable) {