diff --git a/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py b/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py index 9a3bc82c6fa..ca7c6d88636 100644 --- a/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py +++ b/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py @@ -74,6 +74,7 @@ if TYPE_CHECKING: vertex_llm_base: Final = VertexBase() router: Final = APIRouter() openai_passthrough_router: Final = APIRouter() +anthropic_passthrough_router: Final = APIRouter() default_vertex_config: Final = None passthrough_endpoint_router: Final = PassthroughEndpointRouter() @@ -605,7 +606,7 @@ async def is_streaming_request_fn(request: Request) -> bool: return False -@router.api_route( +@anthropic_passthrough_router.api_route( "/anthropic/{endpoint:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH"], tags=["Anthropic Pass-through", "pass-through"], diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index e55b254ab8e..8e3f11634fc 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -574,6 +574,7 @@ from litellm.proxy.openai_files_endpoints.files_endpoints import ( set_files_config, ) from litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints import ( + anthropic_passthrough_router, openai_passthrough_router, passthrough_endpoint_router, vertex_ai_live_websocket_passthrough, @@ -17498,6 +17499,7 @@ app.include_router(image_router) app.include_router(fine_tuning_router) app.include_router(credential_router) app.include_router(openai_passthrough_router) +app.include_router(anthropic_passthrough_router) app.include_router(batches_router) app.include_router(openai_files_router) app.include_router(llm_passthrough_router) diff --git a/tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py b/tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py index 3b506324ad7..19ed225eefd 100644 --- a/tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py +++ b/tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py @@ -3067,6 +3067,26 @@ def test_native_provider_routes_are_unchanged(method, path, expected_name): assert _resolve_route_name(method, path) == expected_name +@pytest.mark.parametrize( + "method, path", + [ + ("POST", "/anthropic/v1/files"), + ("GET", "/anthropic/v1/files"), + ("GET", "/anthropic/v1/files/file-abc123"), + ("DELETE", "/anthropic/v1/files/file-abc123"), + ("POST", "/anthropic/v1/batches"), + ("POST", "/anthropic/v1/messages"), + ], +) +def test_anthropic_passthrough_prefix_wins_over_native_provider_routes(method, path): + """ + Anthropic's Files API has no `purpose` field and no `files_settings` config, + so the native /{provider}/v1/files and /{provider}/v1/batches routes must never + capture /anthropic/... with provider="anthropic". + """ + assert _resolve_route_name(method, path) == "anthropic_proxy_route" + + class TestCursorProxyRoute: """Tests for the Cursor Cloud Agents pass-through route."""