Merge pull request #9331 from BerriAI/litellm_patch_disable_spend_updates

[Patch] - Allow disabling all spend updates / writes to DB
This commit is contained in:
Ishaan Jaff 2025-03-17 22:22:09 -07:00 committed by GitHub
commit 82fe63dde9
3 changed files with 30 additions and 2 deletions

View file

@ -969,7 +969,9 @@ class ProxyLogging:
async def async_post_call_streaming_hook(
self,
response: Union[ModelResponse, EmbeddingResponse, ImageResponse],
response: Union[
ModelResponse, EmbeddingResponse, ImageResponse, ModelResponseStream
],
user_api_key_dict: UserAPIKeyAuth,
):
"""
@ -2474,6 +2476,18 @@ class ProxyUpdateSpend:
e=e, start_time=start_time, proxy_logging_obj=proxy_logging_obj
)
@staticmethod
def disable_spend_updates() -> bool:
"""
returns True if should not update spend in db
Skips writing spend logs and updates to key, team, user spend to DB
"""
from litellm.proxy.proxy_server import general_settings
if general_settings.get("disable_spend_updates") is True:
return True
return False
async def update_spend( # noqa: PLR0915
prisma_client: PrismaClient,