From d2bd029fa4beee1ec31932e0da7b4046fcf285dc Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Thu, 5 Feb 2026 10:58:08 -0800 Subject: [PATCH] [Fix] 404 Not Found on /api/event_logging/batch endpoint (#20504) * fix typing * add event_logging_batch * TestEventLoggingBatchEndpoint --- .../proxy/anthropic_endpoints/endpoints.py | 17 ++++++++++++++++ .../anthropic_endpoints/test_endpoints.py | 20 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/litellm/proxy/anthropic_endpoints/endpoints.py b/litellm/proxy/anthropic_endpoints/endpoints.py index 0033deb076..77bb1f53e6 100644 --- a/litellm/proxy/anthropic_endpoints/endpoints.py +++ b/litellm/proxy/anthropic_endpoints/endpoints.py @@ -80,6 +80,7 @@ async def anthropic_response( # noqa: PLR0915 # Create Anthropic-formatted response with violation message import uuid + from litellm.types.utils import AnthropicMessagesResponse _anthropic_response = AnthropicMessagesResponse( @@ -240,3 +241,19 @@ async def count_tokens( raise HTTPException( status_code=500, detail={"error": f"Internal server error: {str(e)}"} ) + + +@router.post( + "/api/event_logging/batch", + tags=["[beta] Anthropic Event Logging"], +) +async def event_logging_batch( + request: Request, +): + """ + Stubbed endpoint for Anthropic event logging batch requests. + + This endpoint accepts event logging requests but does nothing with them. + It exists to prevent 404 errors from Claude Code clients that send telemetry. + """ + return {"status": "ok"} diff --git a/tests/test_litellm/proxy/anthropic_endpoints/test_endpoints.py b/tests/test_litellm/proxy/anthropic_endpoints/test_endpoints.py index 4024983e26..f6189382d7 100644 --- a/tests/test_litellm/proxy/anthropic_endpoints/test_endpoints.py +++ b/tests/test_litellm/proxy/anthropic_endpoints/test_endpoints.py @@ -7,6 +7,7 @@ import unittest from unittest.mock import AsyncMock, MagicMock, patch import pytest +from fastapi.testclient import TestClient from litellm.proxy.common_request_processing import ProxyBaseLLMRequestProcessing @@ -66,3 +67,22 @@ class TestAnthropicEndpoints(unittest.TestCase): assert ( mock_safe_dumps.call_count == 2 ) # Called twice, once for each dict object + + +class TestEventLoggingBatchEndpoint: + """Test the stubbed event logging batch endpoint""" + + def test_event_logging_batch_endpoint_exists(self): + """Test that the event_logging_batch endpoint exists and returns 200""" + from fastapi import FastAPI + + from litellm.proxy.anthropic_endpoints.endpoints import router + + app = FastAPI() + app.include_router(router) + + client = TestClient(app) + response = client.post("/api/event_logging/batch", json={"events": []}) + + assert response.status_code == 200 + assert response.json() == {"status": "ok"}