Merge pull request #1466 from BerriAI/litellm_fixes_budget_tracking

[Fix] Proxy - Budget Tracking for Streaming Requests for /key/generate
This commit is contained in:
Ishaan Jaff 2024-01-16 19:44:37 -08:00 committed by GitHub
commit ae481e5246
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -506,7 +506,9 @@ async def track_cost_callback(
if user_api_key and (
prisma_client is not None or custom_db_client is not None
):
await update_database(token=user_api_key, response_cost=response_cost)
await update_database(
token=user_api_key, response_cost=response_cost, user_id=user_id
)
elif kwargs["stream"] == False: # for non streaming responses
response_cost = litellm.completion_cost(
completion_response=completion_response