mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
feat: track per-model spend in increment_spend_counters
This commit is contained in:
parent
000d819620
commit
af31004761
1 changed files with 6 additions and 0 deletions
|
|
@ -1807,6 +1807,7 @@ async def increment_spend_counters(
|
|||
user_id: Optional[str],
|
||||
response_cost: Optional[float],
|
||||
org_id: Optional[str] = None,
|
||||
model: Optional[str] = None,
|
||||
):
|
||||
"""
|
||||
Atomically increment spend counters for budget enforcement.
|
||||
|
|
@ -1892,6 +1893,11 @@ async def increment_spend_counters(
|
|||
source_cache_key=f"team_membership:{user_id}:{team_id}",
|
||||
increment=response_cost,
|
||||
)
|
||||
if model is not None:
|
||||
await spend_counter_cache.async_increment_cache(
|
||||
key=f"spend:team_member:{user_id}:{team_id}:model:{model}",
|
||||
value=response_cost or 0.0,
|
||||
)
|
||||
|
||||
if user_id is not None:
|
||||
await _init_and_increment_spend_counter(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue