Skip to content

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]

add spend_report_frequency as a general setting

Ishaan Jaff805e4c575448
diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py
index f4f3a1e586d..b6ebbe1df84 100644
--- a/litellm/proxy/proxy_server.py
+++ b/litellm/proxy/proxy_server.py
@@ -2961,11 +2961,26 @@ async def startup_event():
and prisma_client is not None
):
print("Alerting: Initializing Weekly/Monthly Spend Reports") # noqa
- ### Schedule weekly/monhtly spend reports ###
+ ### Schedule weekly/monthly spend reports ###
+ ### Schedule spend reports ###
+ spend_report_frequency: str = (
+ general_settings.get("spend_report_frequency", "7d") or "7d"
+ )
+
+ # Parse the frequency
+ days = int(spend_report_frequency[:-1])
+ if spend_report_frequency[-1].lower() != "d":
+ raise ValueError(
+ "spend_report_frequency must be specified in days, e.g., '1d', '7d'"
+ )
+
scheduler.add_job(
proxy_logging_obj.slack_alerting_instance.send_weekly_spend_report,
- "cron",
- day_of_week="mon",
+ "interval",
+ days=days,
+ next_run_time=datetime.now()
+ + timedelta(seconds=10), # Start 10 seconds from now
+ args=[spend_report_frequency],
)
scheduler.add_job(