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]

Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_redis_pubsub_config_sync

mateo-berrib2fd79f48712
diff --cc litellm/proxy/proxy_server.py
index 7d3e58bfe52,9023f5fb23f..33af268cf93
--- a/litellm/proxy/proxy_server.py
+++ b/litellm/proxy/proxy_server.py
@@@ -6209,38 -6217,8 +6222,40 @@@ class ProxyConfig
"litellm.proxy.proxy_server.py::ProxyConfig:add_deployment - {}".format(str(e))
)
+ return still_desired_ids
+
+ def start_config_sync_subscriber(
+ self,
+ prisma_client: PrismaClient,
+ proxy_logging_obj: ProxyLogging,
+ redis_cache: Optional[RedisCache],
+ ) -> None:
+ if redis_cache is None or self.config_sync_subscriber is not None:
+ return
+
+ async def _resync_config_from_db() -> None:
+ await self.add_deployment(prisma_client=prisma_client, proxy_logging_obj=proxy_logging_obj)
+
+ async def _resync_credentials_from_db() -> None:
+ await self.get_credentials(prisma_client=prisma_client)
+
+ subscriber = ConfigSyncSubscriber(
+ redis_cache=redis_cache,
+ resync_callbacks=(_resync_config_from_db, _resync_credentials_from_db),
+ )
+ self.config_sync_subscriber = subscriber
+ subscriber.start()
+
+ async def stop_config_sync_subscriber(self) -> None:
+ subscriber = self.config_sync_subscriber
+ if subscriber is None:
+ return
+ self.config_sync_subscriber = None
+ try:
+ await subscriber.stop()
+ except Exception as e:
+ verbose_proxy_logger.error(f"Error stopping config sync subscriber: {e}")
+
async def _init_non_llm_objects_in_db(self, prisma_client: PrismaClient):
"""
Use this to read non-llm objects from the db and initialize them