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
Merge remote-tracking branch 'origin/main' into litellm_spend_log_cleanup_cancel_outcome
yucheng37ce0e47b658
diff --cc litellm/proxy/proxy_server.pyindex 3dac15a3721,7634237a59f..b105822376d--- a/litellm/proxy/proxy_server.py+++ b/litellm/proxy/proxy_server.py@@@ -687,12 -709,10 +709,15 @@@ from litellm.proxy.route_llm_request imfrom litellm.proxy.route_priority import hot_routes_firstfrom litellm.proxy.search_endpoints.endpoints import router as search_routerfrom litellm.proxy.shutdown.graceful_shutdown_manager import GracefulShutdownManager+from litellm.proxy.shutdown.scheduled_jobs import (+ AwaitableAsyncIOExecutor,+ pause_scheduled_jobs,+ stop_in_flight_scheduler_jobs,+)from litellm.proxy.spend_tracking.budget_reservation import get_budget_window_start+ from litellm.proxy.spend_tracking.daily_global_spend_rollup import (+ run_scheduled_daily_global_spend_reconcile,+ )from litellm.proxy.spend_tracking.spend_counter_batch import (PendingSpendIncrement,active_spend_counter_batch,@@@ -1463,15 -1510,14 +1519,21 @@@ async def proxy_startup_event(app: Fastexcept Exception as e:verbose_proxy_logger.error("Error stopping DB health watchdog task: %s", e)+ if prisma_client is not None and hasattr(prisma_client, "stop_view_setup_task"):+ try:+ await prisma_client.stop_view_setup_task()+ except Exception as e:+ verbose_proxy_logger.error("Error stopping the spend view setup task: %s", e)+await _drain_spend_event_producer_on_shutdown()+ # Shutdown event - finish or cancel in-flight scheduled jobs before the shutdown flushes and the DB disconnect+ if scheduler is not None and scheduler_executor is not None:+ try:+ await stop_in_flight_scheduler_jobs(scheduler, scheduler_executor)+ except Exception as e:+ verbose_proxy_logger.error("Error stopping in-flight scheduled jobs: %s", e)+await flush_spend_counters_on_shutdown()await _flush_spend_logs_queue_on_shutdown()