diff --git a/src/proxy/anthropic.ts b/src/proxy/anthropic.ts index 7f96df5..8615fec 100644 --- a/src/proxy/anthropic.ts +++ b/src/proxy/anthropic.ts @@ -259,6 +259,22 @@ anthropicRouter.post( }), anthropicProxy ); +// This is not a valid route but clients may attempt to use it. +anthropicRouter.post("/v1/claude-3/messages", (req, res) => { + sendErrorToClient({ + req, + res, + options: { + title: "Proxy error (wrong endpoint)", + message: + "Your client is attempting to use the /anthropic/claude-3 compatibility endpoint, but it supports the new API format.\n\nUse the normal /anthropic endpoint instead.", + format: "unknown", + statusCode: 404, + reqId: req.id, + obj: { original_url: req.originalUrl, router_url: req.url }, + }, + }); +}); export function handleCompatibilityRequest( req: Request, @@ -268,7 +284,7 @@ export function handleCompatibilityRequest( const alreadyInChatFormat = Boolean(req.body.messages); const alreadyUsingClaude3 = req.body.model?.includes("claude-3"); if (!alreadyInChatFormat && !alreadyUsingClaude3) { - next(); + return next(); } if (alreadyInChatFormat) { diff --git a/src/proxy/aws.ts b/src/proxy/aws.ts index 1fcb1d9..98f073e 100644 --- a/src/proxy/aws.ts +++ b/src/proxy/aws.ts @@ -20,6 +20,7 @@ import { handleCompatibilityRequest, transformAnthropicChatResponseToAnthropicText, } from "./anthropic"; +import { sendErrorToClient } from "./middleware/response/error-generator"; const LATEST_AWS_V2_MINOR_VERSION = "1"; const CLAUDE_3_COMPAT_MODEL = "anthropic.claude-3-sonnet-20240229-v1:0"; @@ -202,6 +203,22 @@ awsRouter.post( ), awsProxy ); +// This is not a valid route but clients may attempt to use it. +awsRouter.post("/v1/claude-3/messages", (req, res) => { + sendErrorToClient({ + req, + res, + options: { + title: "Proxy error (wrong endpoint)", + message: + "Your client is attempting to use the /anthropic/v1/claude-3 compatibility endpoint, but supports the new API format and should use the normal /anthropic/v1 endpoint instead.", + format: "unknown", + statusCode: 404, + reqId: req.id, + obj: { original_url: req.originalUrl, router_url: req.url }, + }, + }); +}); // OpenAI-to-AWS Anthropic compatibility endpoint. awsRouter.post( "/v1/chat/completions", diff --git a/src/proxy/routes.ts b/src/proxy/routes.ts index 910237a..020e653 100644 --- a/src/proxy/routes.ts +++ b/src/proxy/routes.ts @@ -58,8 +58,10 @@ proxyRouter.use((req, res) => { reqId: req.id, format: "unknown", obj: { - proxy_note: "Your chat client is using the wrong endpoint. Please check your configuration.", - requested_url: req.url, + proxy_note: + "Your chat client is using the wrong endpoint. Please check your configuration.", + original_url: req.originalUrl, + router_url: req.url, }, }, });