The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(spend_management_endpoints.py): add end user filtering
Krrish Dholakiabb5e71447dab
diff --git a/litellm/constants.py b/litellm/constants.pyindex e40f1a5da2d..c0ce0f265b5 100644--- a/litellm/constants.py+++ b/litellm/constants.py@@ -15,7 +15,7 @@ DEFAULT_SQS_FLUSH_INTERVAL_SECONDS = int(os.getenv("DEFAULT_SQS_FLUSH_INTERVAL_SECONDS", 10))DEFAULT_NUM_WORKERS_LITELLM_PROXY = int(- os.getenv("DEFAULT_NUM_WORKERS_LITELLM_PROXY", 4)+ os.getenv("DEFAULT_NUM_WORKERS_LITELLM_PROXY", 1))DEFAULT_SQS_BATCH_SIZE = int(os.getenv("DEFAULT_SQS_BATCH_SIZE", 512))SQS_SEND_MESSAGE_ACTION = "SendMessage"diff --git a/litellm/proxy/spend_tracking/spend_management_endpoints.py b/litellm/proxy/spend_tracking/spend_management_endpoints.pyindex e7d28bc317f..16985d76b33 100644--- a/litellm/proxy/spend_tracking/spend_management_endpoints.py+++ b/litellm/proxy/spend_tracking/spend_management_endpoints.py@@ -10,7 +10,6 @@ from fastapi import APIRouter, Depends, HTTPException, statusimport litellmfrom litellm._logging import verbose_proxy_logger-from litellm.router_strategy.budget_limiter import RouterBudgetLimitingfrom litellm.proxy._types import *from litellm.proxy._types import ProviderBudgetResponse, ProviderBudgetResponseObjectfrom litellm.proxy.auth.user_api_key_auth import user_api_key_auth@@ -18,6 +17,7 @@ from litellm.proxy.spend_tracking.spend_tracking_utils import (get_spend_by_team_and_customer,)from litellm.proxy.utils import handle_exception_on_proxy+from litellm.router_strategy.budget_limiter import RouterBudgetLimitingif TYPE_CHECKING:from litellm.proxy.proxy_server import PrismaClient@@ -1663,6 +1663,9 @@ async def ui_view_spend_logs( # noqa: PLR0915key_alias: Optional[str] = fastapi.Query(default=None, description="Filter logs by key alias"),+ end_user: Optional[str] = fastapi.Query(+ default=None, description="Filter logs by end user"+ ),):"""View spend logs for UI with pagination support@@ -1730,13 +1733,16 @@ async def ui_view_spend_logs( # noqa: PLR0915if model is not None:where_conditions["model"] = model-+if key_alias is not None:where_conditions["metadata"] = {"path": ["user_api_key_alias"],- "string_contains": key_alias+ "string_contains": key_alias,}+ if end_user is not None:+ where_conditions["end_user"] = end_user+if min_spend is not None or max_spend is not None:where_conditions["spend"] = {}if min_spend is not None: