Deprecate legacy spend logs docs

Co-authored-by: ishaan-berri <ishaan-berri@users.noreply.github.com>
This commit is contained in:
oss-agent-shin 2026-05-07 18:34:14 +00:00
parent fee5900acc
commit e24b178088
No known key found for this signature in database
2 changed files with 24 additions and 28 deletions

View file

@ -2200,6 +2200,8 @@ async def ui_view_request_response_for_request_id(
"/spend/logs",
tags=["Budget & Spend Tracking"],
dependencies=[Depends(user_api_key_auth)],
deprecated=True,
summary="Deprecated: use /spend/logs/ui for paginated spend logs",
responses={
200: {"model": List[LiteLLM_SpendLogs]},
},
@ -2233,7 +2235,7 @@ async def view_spend_logs( # noqa: PLR0915
):
"""
[DEPRECATED] This endpoint is not paginated and can cause performance issues.
Please use `/spend/logs/v2` instead for paginated access to spend logs.
Please use `/spend/logs/ui` instead for paginated access to spend logs.
View all spend logs, if request_id is provided, only logs for that request_id will be returned
@ -2241,34 +2243,14 @@ async def view_spend_logs( # noqa: PLR0915
- summarize=true (default): Returns aggregated spend data grouped by date (maintains backward compatibility)
- summarize=false: Returns filtered individual log entries within the date range
Example Request for all logs
Recommended paginated UI spend logs request:
```
curl -X GET "http://0.0.0.0:8000/spend/logs" \
-H "Authorization: Bearer sk-1234"
```
Example Request for specific request_id
```
curl -X GET "http://0.0.0.0:8000/spend/logs?request_id=chatcmpl-6dcb2540-d3d7-4e49-bb27-291f863f112e" \
-H "Authorization: Bearer sk-1234"
```
Example Request for specific api_key
```
curl -X GET "http://0.0.0.0:8000/spend/logs?api_key=sk-test-example-key-123" \
-H "Authorization: Bearer sk-1234"
```
Example Request for specific user_id
```
curl -X GET "http://0.0.0.0:8000/spend/logs?user_id=ishaan@berri.ai" \
-H "Authorization: Bearer sk-1234"
```
Example Request for date range with individual logs (unsummarized)
```
curl -X GET "http://0.0.0.0:8000/spend/logs?start_date=2024-01-01&end_date=2024-01-02&summarize=false" \
-H "Authorization: Bearer sk-1234"
curl -G "http://0.0.0.0:4000/spend/logs/ui" \
-H "Authorization: Bearer <proxy-api-key>" \
--data-urlencode "start_date=2024-01-01 00:00:00" \
--data-urlencode "end_date=2024-01-02 00:00:00" \
--data-urlencode "page=1" \
--data-urlencode "page_size=50"
```
"""
from litellm.proxy.proxy_server import prisma_client

View file

@ -127,6 +127,20 @@ async def test_is_admin_view_safe_false():
assert spend_management_endpoints._is_admin_view_safe(auth) is False
def test_legacy_spend_logs_openapi_points_to_ui_endpoint(client):
response = client.get("/openapi.json")
assert response.status_code == 200
operation = response.json()["paths"]["/spend/logs"]["get"]
description = operation.get("description", "")
assert operation.get("deprecated") is True
assert "/spend/logs/ui" in description
assert "curl -G" in description
assert "page_size=50" in description
assert 'curl -X GET "http://0.0.0.0:8000/spend/logs"' not in description
@pytest.mark.asyncio
async def test_is_admin_view_safe_exception():
# Ensure exceptions are swallowed and return False