[Fix] 404 Not Found on /api/event_logging/batch endpoint (#20504)

* fix typing

* add event_logging_batch

* TestEventLoggingBatchEndpoint
This commit is contained in:
Ishaan Jaff
2026-02-05 10:58:08 -08:00
committed by GitHub
parent f65eec8fa8
commit d2bd029fa4
2 changed files with 37 additions and 0 deletions
@@ -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"}
@@ -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"}