mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-10 16:22:17 +00:00
raise error on /spend/report endpoint
This commit is contained in:
@@ -1622,7 +1622,7 @@ class ProxyException(Exception):
|
||||
}
|
||||
|
||||
|
||||
class CommonProxyErrors(enum.Enum):
|
||||
class CommonProxyErrors(str, enum.Enum):
|
||||
db_not_connected_error = "DB not connected"
|
||||
no_llm_router = "No models configured on proxy"
|
||||
not_allowed_access = "Admin-only endpoint. Not allowed to access this."
|
||||
|
||||
@@ -860,7 +860,7 @@ async def get_global_spend_report(
|
||||
start_date_obj = datetime.strptime(start_date, "%Y-%m-%d")
|
||||
end_date_obj = datetime.strptime(end_date, "%Y-%m-%d")
|
||||
|
||||
from litellm.proxy.proxy_server import prisma_client
|
||||
from litellm.proxy.proxy_server import premium_user, prisma_client
|
||||
|
||||
try:
|
||||
if prisma_client is None:
|
||||
@@ -868,6 +868,11 @@ async def get_global_spend_report(
|
||||
f"Database not connected. Connect a database to your proxy - https://docs.litellm.ai/docs/simple_proxy#managing-auth---virtual-keys"
|
||||
)
|
||||
|
||||
if premium_user is not True:
|
||||
raise ValueError(
|
||||
"/spend/report endpoint" + CommonProxyErrors.not_premium_user.value
|
||||
)
|
||||
|
||||
if group_by == "team":
|
||||
# first get data from spend logs -> SpendByModelApiKey
|
||||
# then read data from "SpendByModelApiKey" to format the response obj
|
||||
|
||||
Reference in New Issue
Block a user