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
This commit is contained in:
1 parent
ce7147025d
commit
476d297e4b
1 file changed
+18
@@ -44,6 +44,24 @@ export class ProxyController {
|
|||||||
@Post('chat/completions')
|
@Post('chat/completions')
|
||||||
async chatCompletions(@Body() body: OpenAIChatRequest, @Res() res: FastifyReply) {
|
async chatCompletions(@Body() body: OpenAIChatRequest, @Res() res: FastifyReply) {
|
||||||
try {
|
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);
|
const result = await this.proxyService.handleChatCompletions(body);
|
||||||
|
|
||||||
if (body.stream && result instanceof Observable) {
|
if (body.stream && result instanceof Observable) {
|
||||||
|
|||||||
Reference in new issue
Block a user