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(proxy_server.py): add info log when spend logs is skipped because `disable_spend_logs=True`.
Krrish Dholakiab3c7d63ec157
diff --git a/litellm/integrations/braintrust_logging.py b/litellm/integrations/braintrust_logging.pyindex 4a8c948d122..e8ef692da90 100644--- a/litellm/integrations/braintrust_logging.py+++ b/litellm/integrations/braintrust_logging.py@@ -7,6 +7,7 @@ import osimport threadingimport tracebackimport uuid+from datetime import datetimefrom typing import Literal, Optionalimport dotenv@@ -285,7 +286,6 @@ class BraintrustLogger(CustomLogger):for key, value in metadata.items():if (isinstance(value, list)- or isinstance(value, dict)or isinstance(value, str)or isinstance(value, int)or isinstance(value, float)@@ -293,6 +293,11 @@ class BraintrustLogger(CustomLogger):new_metadata[key] = valueelif isinstance(value, BaseModel):new_metadata[key] = value.model_dump_json()+ elif isinstance(value, dict):+ for k, v in value.items():+ if isinstance(v, datetime):+ value[k] = v.isoformat()+ new_metadata[key] = valuemetadata = new_metadatadiff --git a/litellm/proxy/_new_secret_config.yaml b/litellm/proxy/_new_secret_config.yamlindex 96a0242a8e4..1c789d3913a 100644--- a/litellm/proxy/_new_secret_config.yaml+++ b/litellm/proxy/_new_secret_config.yaml@@ -2,3 +2,6 @@ model_list:- model_name: "*"litellm_params:model: "*"++general_settings:+ disable_spend_logs: true\ No newline at end of filediff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.pyindex 527fe03cf86..c79a18a5ccd 100644--- a/litellm/proxy/proxy_server.py+++ b/litellm/proxy/proxy_server.py@@ -963,8 +963,12 @@ async def update_database(asyncio.create_task(_update_team_db())asyncio.create_task(_update_org_db())# asyncio.create_task(_insert_spend_log_to_db())- if disable_spend_logs == False:+ if disable_spend_logs is False:await _insert_spend_log_to_db()+ else:+ verbose_proxy_logger.info(+ "disable_spend_logs=True. Skipping writing spend logs to db. Other spend updates - Key/User/Team table will still occur."+ )verbose_proxy_logger.debug("Runs spend update on all tables")except Exception as e:@@ -2192,7 +2196,15 @@ class ProxyConfig:raise ValueError(f"Master key is not initialized or formatted. master_key={master_key}")- new_models = await prisma_client.db.litellm_proxymodeltable.find_many()+ try:+ new_models = await prisma_client.db.litellm_proxymodeltable.find_many()+ except Exception as e:+ verbose_proxy_logger.error(+ "litellm.proxy_server.py::add_deployment() - Error getting new models from DB - {}".format(+ str(e)+ )+ )+ new_models = []# update llm routerawait self._update_llm_router(new_models=new_models, proxy_logging_obj=proxy_logging_obj