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_native_redis_semantic_cache
Yujong Lee615a226a3087
diff --cc litellm-rust/Cargo.lockindex f39f5b3ea95,f4a74a69709..29e661dea9c--- a/litellm-rust/Cargo.lock+++ b/litellm-rust/Cargo.lock@@@ -2830,9 -2830,9 +2845,10 @@@ dependencies ="litellm-cache","litellm-cache-azure-blob","litellm-cache-disk",+ "litellm-cache-gcs","litellm-cache-memory","litellm-cache-redis",+ "litellm-cache-redis-semantic","litellm-cache-response","litellm-callbacks-legacy-python","litellm-core",diff --cc litellm-rust/Cargo.tomlindex c152409decb,e5b3c14ac5d..3e28c11347b--- a/litellm-rust/Cargo.toml+++ b/litellm-rust/Cargo.toml@@@ -32,8 -33,8 +33,9 @@@ litellm-cache = { path = "crates/cachelitellm-cache-azure-blob = { path = "crates/cache-azure-blob" }litellm-cache-memory = { path = "crates/cache-memory" }litellm-cache-redis = { path = "crates/cache-redis" }+ litellm-cache-gcs = { path = "crates/cache-gcs" }litellm-cache-disk = { path = "crates/cache-disk" }+litellm-cache-redis-semantic = { path = "crates/cache-redis-semantic" }litellm-cache-response = { path = "crates/cache-response" }litellm-token-counter = { path = "crates/token-counter" }litellm-token-counter-fast = { path = "crates/token-counter-fast" }diff --cc litellm-rust/crates/python-bridge/Cargo.tomlindex 02c3f9653dc,4a9ea633ac5..0080a972481--- a/litellm-rust/crates/python-bridge/Cargo.toml+++ b/litellm-rust/crates/python-bridge/Cargo.toml@@@ -24,8 -24,8 +24,9 @@@ litellm-cache.workspace = trulitellm-cache-azure-blob.workspace = truelitellm-cache-memory.workspace = truelitellm-cache-redis.workspace = true+ litellm-cache-gcs.workspace = truelitellm-cache-disk.workspace = true+litellm-cache-redis-semantic.workspace = truelitellm-cache-response.workspace = trueserde.workspace = truelitellm-auth.workspace = truediff --cc litellm-rust/crates/python-bridge/src/cache/config.rsindex 3166a228b9d,6c180708335..3a7ae5d618f--- a/litellm-rust/crates/python-bridge/src/cache/config.rs+++ b/litellm-rust/crates/python-bridge/src/cache/config.rs@@@ -111,9 -105,9 +118,10 @@@ const REDIS_PY_DEFAULT_MAX_CONNECTIONSpub(super) enum CacheBackendConfig {Memory(MemoryCacheConfig),Redis(Box<RedisCacheConfig>),+ Gcs(GcsCacheConfig),Disk(DiskCacheConfig),AzureBlob(AzureBlobCacheConfig),+ RedisSemantic(Box<RedisSemanticCacheConfig>),}#[allow(dead_code, reason = "consumed by the cache activation follow-up")]@@@ -195,21 -198,15 +212,17 @@@ impl NativeCacheConfigbackend: CacheBackendConfig::AzureBlob(backend),}))}),- Some(- CacheType::RedisSemantic- | CacheType::ValkeySemantic- | CacheType::S3- | CacheType::QdrantSemantic,- )- | None => Ok(CacheConfigProjection::Unsupported(- UnsupportedCacheConfig::Backend,- )),+ Some(CacheType::RedisSemantic) => project_redis_semantic(&backend).map(|backend| {+ CacheConfigProjection::Native(Box::new(Self {+ policy,+ backend: CacheBackendConfig::RedisSemantic(Box::new(backend)),+ }))+ }),- Some(- CacheType::ValkeySemantic- | CacheType::S3- | CacheType::QdrantSemantic- | CacheType::Gcs,- )- | None => Ok(CacheConfigProjection::Unsupported(- UnsupportedCacheConfig::Backend,- )),++ Some(CacheType::ValkeySemantic | CacheType::S3 | CacheType::QdrantSemantic) | None => {++ Ok(CacheConfigProjection::Unsupported(++ UnsupportedCacheConfig::Backend,++ ))++ }}}@@@ -217,8 -214,9 +230,10 @@@let default_ttl = match &self.backend {CacheBackendConfig::Memory(config) => Some(config.default_ttl),CacheBackendConfig::Redis(config) => Some(config.default_ttl),- CacheBackendConfig::Disk(_) => None,- CacheBackendConfig::AzureBlob(_) | CacheBackendConfig::RedisSemantic(_) => None,+ CacheBackendConfig::Disk(_)+ | CacheBackendConfig::AzureBlob(_)- | CacheBackendConfig::Gcs(_) => None,++ | CacheBackendConfig::Gcs(_)++ | CacheBackendConfig::RedisSemantic(_) => None,};if service.default_ttl() != default_ttl {return Some("facade and native backend default TTLs must match");diff --cc litellm-rust/crates/python-bridge/src/cache/facade.rsindex 5b49166541b,0fa4511b1c1..c4be7a9254a--- a/litellm-rust/crates/python-bridge/src/cache/facade.rs+++ b/litellm-rust/crates/python-bridge/src/cache/facade.rs@@@ -386,13 -370,9 +387,16 @@@ impl FacadeGuard"max_size_per_item","redis_kwargs","redis_flush_size",+ "similarity_threshold",+ "distance_threshold",+ "embedding_model",+ "embedding_max_input_tokens",+ "embedding_timeout",+ "_index_name",+ "_redis_url",+ "bucket_name",+ "key_prefix",+ "path_service_account",],)?,disk_store: (kind == "disk")diff --cc litellm-rust/crates/python-bridge/src/cache/handle.rsindex 9633e6c7158,64ac3696e80..8c64e5bbb19--- a/litellm-rust/crates/python-bridge/src/cache/handle.rs+++ b/litellm-rust/crates/python-bridge/src/cache/handle.rs@@@ -1,16 -1,10 +1,18 @@@use litellm_cache_redis::{RedisNode, RedisTopology};+use litellm_cache_redis_semantic::RedisSemanticConfig;use litellm_host_python::{release_gil, run_sync_value};-use pyo3::{PyTraverseError, PyVisit, exceptions::PyRuntimeError, prelude::*};+use pyo3::{+ PyTraverseError, PyVisit,+ exceptions::{PyRuntimeError, PyTypeError},+ prelude::*,+};+ use litellm_cache_gcs::{DEFAULT_ENDPOINT, GcsConfig};+-use super::{cache_error, facade::FacadeGuard, native::NativeResponseCache, request::duration};+use super::{+ cache_error, config::project_redis_semantic, embedder::PythonEmbedder, facade::FacadeGuard,+ native::NativeResponseCache, request::duration,+};#[pyclass(frozen, name = "_CacheTestHandle")]pub(crate) struct CacheTestHandle {diff --cc litellm-rust/crates/python-bridge/src/cache/native.rsindex da09b165aad,b10f9e2a443..d2bced66f2c--- a/litellm-rust/crates/python-bridge/src/cache/native.rs+++ b/litellm-rust/crates/python-bridge/src/cache/native.rs@@@ -1,11 -1,11 +1,12 @@@use std::{path::Path, sync::Arc, time::Duration};-use litellm_cache::{CacheCodec, CacheConnectionResult, Error};+use litellm_cache::{CacheCodec, CacheConnectionResult, Error, ExactCacheContext};use litellm_cache_azure_blob::AzureBlobCache;use litellm_cache_disk::DiskCache;+ use litellm_cache_gcs::{GcsCache, GcsConfig, StaticTokenSource};use litellm_cache_memory::InMemoryCache;use litellm_cache_redis::{RedisCache, RedisTopology};+use litellm_cache_redis_semantic::{RedisSemanticCache, RedisSemanticConfig};use litellm_cache_response::{CacheEntry, PartialHits, ResponseCache, ResponseCacheCodec, ResponseCacheRequest, WriteBuffer,};@@@ -21,9 -18,9 +22,10 @@@ pub(super) enum NativeResponseCachecache: Arc<ResponseCache<RedisCache<ResponseCacheCodec>>>,buffer: Option<Arc<WriteBuffer>>,},+ Gcs(Arc<ResponseCache<GcsCache<ResponseCacheCodec>>>),Disk(Arc<ResponseCache<DiskCache<ResponseCacheCodec>>>),AzureBlob(Arc<ResponseCache<AzureBlobCache<ResponseCacheCodec>>>),+ RedisSemantic(Arc<ResponseCache<RedisSemanticCache<PythonEmbedder>>>),}impl NativeResponseCache {@@@ -59,17 -56,18 +61,29 @@@Ok(Self::Disk(Arc::new(ResponseCache::new(Arc::new(cache)))))}+ pub fn redis_semantic(+ url: &str,+ embedder: PythonEmbedder,+ config: RedisSemanticConfig,+ ) -> Result<Self, Error> {+ let backend = RedisSemanticCache::new(url, embedder, config)?;+ Ok(Self::RedisSemantic(Arc::new(ResponseCache::new(Arc::new(+ backend,+ )))))+ }++ pub fn gcs(config: GcsConfig, token: Option<String>) -> Result<Self, Error> {+ let backend = match token {+ Some(token) => GcsCache::with_token_source(+ config,+ ResponseCacheCodec,+ Arc::new(StaticTokenSource(token)),+ )?,+ None => GcsCache::new(config, ResponseCacheCodec)?,+ };+ Ok(Self::Gcs(Arc::new(ResponseCache::new(Arc::new(backend)))))+ }+pub async fn azure_blob(account_url: &str, container: &str) -> Result<Self, Error> {let backend = AzureBlobCache::connect(account_url,@@@ -89,7 -87,7 +103,11 @@@cache.backend().account_url(),cache.backend().container_name(),)),- Self::Memory(_) | Self::Redis { .. } | Self::Disk(_) | Self::RedisSemantic(_) => None,- Self::Memory(_) | Self::Redis { .. } | Self::Disk(_) | Self::Gcs(_) => None,++ Self::Memory(_)++ | Self::Redis { .. }++ | Self::Disk(_)++ | Self::Gcs(_)++ | Self::RedisSemantic(_) => None,}}}@@@ -99,8 -97,8 +117,9 @@@ impl NativeResponseCachematch self {Self::Memory(_) => "memory",Self::Redis { .. } => "redis",+ Self::Gcs(_) => "gcs",Self::Disk(_) => "disk",+ Self::RedisSemantic(_) => "redis_semantic",Self::AzureBlob(_) => "azure-blob",}}@@@ -109,22 -107,23 +128,28 @@@match self {Self::Memory(cache) => cache.default_ttl(),Self::Redis { cache, .. } => cache.default_ttl(),+ Self::Gcs(cache) => cache.default_ttl(),Self::Disk(cache) => cache.default_ttl(),+ Self::RedisSemantic(cache) => cache.default_ttl(),Self::AzureBlob(cache) => cache.default_ttl(),}}pub fn namespace(&self) -> Option<&str> {match self {- Self::Memory(_) | Self::Disk(_) | Self::AzureBlob(_) => None,+ Self::Memory(_) | Self::Disk(_) | Self::AzureBlob(_) | Self::RedisSemantic(_) => None,Self::Redis { cache, .. } => cache.backend().namespace(),+ Self::Gcs(_) => None,}}pub fn topology(&self) -> Option<&RedisTopology> {match self {- Self::Memory(_) | Self::Disk(_) | Self::AzureBlob(_) | Self::RedisSemantic(_) => None,- Self::Memory(_) | Self::Disk(_) | Self::AzureBlob(_) | Self::Gcs(_) => None,++ Self::Memory(_)++ | Self::Disk(_)++ | Self::AzureBlob(_)++ | Self::Gcs(_)++ | Self::RedisSemantic(_) => None,Self::Redis { cache, .. } => Some(cache.backend().topology()),}}@@@ -132,54 -131,15 +157,74 @@@pub fn capacity(&self) -> Option<usize> {match self {Self::Memory(cache) => Some(cache.backend().max_size_in_memory()),- Self::Redis { .. } | Self::Disk(_) | Self::AzureBlob(_) | Self::RedisSemantic(_) => {- None- }- Self::Redis { .. } | Self::Disk(_) | Self::AzureBlob(_) | Self::Gcs(_) => None,++ Self::Redis { .. }++ | Self::Disk(_)++ | Self::AzureBlob(_)++ | Self::Gcs(_)++ | Self::RedisSemantic(_) => None,}}pub fn max_entry_bytes(&self) -> Option<usize> {match self {Self::Memory(cache) => cache.backend().max_entry_bytes(),- Self::Redis { .. } | Self::Disk(_) | Self::AzureBlob(_) | Self::RedisSemantic(_) => {- None- }- Self::Redis { .. } | Self::Disk(_) | Self::AzureBlob(_) | Self::Gcs(_) => None,++ Self::Redis { .. }++ | Self::Disk(_)++ | Self::AzureBlob(_)++ | Self::Gcs(_)++ | Self::RedisSemantic(_) => None,+ }+ }++ pub fn index_name(&self) -> Option<&str> {+ match self {+ Self::RedisSemantic(cache) => Some(cache.backend().index_name()),- Self::Memory(_) | Self::Redis { .. } | Self::AzureBlob(_) | Self::Disk(_) => None,++ Self::Memory(_)++ | Self::Redis { .. }++ | Self::AzureBlob(_)++ | Self::Disk(_)++ | Self::Gcs(_) => None,+ }+ }++ pub fn similarity_threshold(&self) -> Option<f32> {+ match self {+ Self::RedisSemantic(cache) => Some(cache.backend().similarity_threshold()),- Self::Memory(_) | Self::Redis { .. } | Self::AzureBlob(_) | Self::Disk(_) => None,++ Self::Memory(_)++ | Self::Redis { .. }++ | Self::AzureBlob(_)++ | Self::Disk(_)++ | Self::Gcs(_) => None,+ }+ }++ pub fn semantic_embedder(&self) -> Option<&PythonEmbedder> {+ match self {+ Self::RedisSemantic(cache) => Some(cache.backend().embedder()),- Self::Memory(_) | Self::Redis { .. } | Self::AzureBlob(_) | Self::Disk(_) => None,++ Self::Memory(_)++ | Self::Redis { .. }++ | Self::AzureBlob(_)++ | Self::Disk(_)++ | Self::Gcs(_) => None,+ }+ }++ pub fn embedder_object(&self) -> Option<&Py<PyAny>> {+ match self {+ Self::RedisSemantic(cache) => Some(cache.backend().embedder().object()),- Self::Memory(_) | Self::Redis { .. } | Self::AzureBlob(_) | Self::Disk(_) => None,++ Self::Memory(_)++ | Self::Redis { .. }++ | Self::AzureBlob(_)++ | Self::Disk(_)++ | Self::Gcs(_) => None,+ }+ }++ pub fn traverse(&self, visit: &PyVisit<'_>) -> Result<(), PyTraverseError> {+ if let Self::RedisSemantic(cache) = self {+ cache.backend().embedder().traverse(visit)?;}+ Ok(())}pub fn with_redis_flush_size(self, flush_size: Option<usize>) -> Self {@@@ -195,23 -155,21 +240,26 @@@pub fn directory(&self) -> Option<&Path> {match self {Self::Disk(cache) => Some(cache.backend().directory()),- Self::Memory(_) | Self::Redis { .. } | Self::AzureBlob(_) | Self::RedisSemantic(_) => {- None- }- Self::Memory(_) | Self::Redis { .. } | Self::AzureBlob(_) | Self::Gcs(_) => None,++ Self::Memory(_)++ | Self::Redis { .. }++ | Self::AzureBlob(_)++ | Self::Gcs(_)++ | Self::RedisSemantic(_) => None,}}- pub fn lookup(- &self,- request: &ResponseCacheRequest,- now: Duration,- ) -> Result<Option<Value>, Error> {+ fn exact_requests(requests: &[CacheRequest]) -> Vec<ResponseCacheRequest<ExactCacheContext>> {+ requests.iter().map(CacheRequest::exact).collect()+ }++ pub fn lookup(&self, request: &CacheRequest, now: Duration) -> Result<Option<Value>, Error> {match self {- Self::Memory(cache) => cache.lookup(request, now),- Self::Redis { cache, .. } => cache.lookup(request, now),- Self::Gcs(cache) => cache.lookup(request, now),- Self::Disk(cache) => cache.lookup(request, now),- Self::AzureBlob(cache) => cache.lookup(request, now),+ Self::Memory(cache) => cache.lookup(&request.exact(), now),+ Self::Redis { cache, .. } => cache.lookup(&request.exact(), now),++ Self::Gcs(cache) => cache.lookup(&request.exact(), now),+ Self::Disk(cache) => cache.lookup(&request.exact(), now),+ Self::AzureBlob(cache) => cache.lookup(&request.exact(), now),+ Self::RedisSemantic(cache) => cache.lookup(&request.semantic(), now),}}@@@ -222,11 -180,11 +270,12 @@@now: Duration,) -> Result<(), Error> {match self {- Self::Memory(cache) => cache.store(request, response, now),- Self::Redis { cache, .. } => cache.store(request, response, now),- Self::Gcs(cache) => cache.store(request, response, now),- Self::Disk(cache) => cache.store(request, response, now),- Self::AzureBlob(cache) => cache.store(request, response, now),+ Self::Memory(cache) => cache.store(&request.exact(), response, now),+ Self::Redis { cache, .. } => cache.store(&request.exact(), response, now),++ Self::Gcs(cache) => cache.store(&request.exact(), response, now),+ Self::Disk(cache) => cache.store(&request.exact(), response, now),+ Self::AzureBlob(cache) => cache.store(&request.exact(), response, now),+ Self::RedisSemantic(cache) => cache.store(&request.semantic(), response, now),}}@@@ -236,11 -194,11 +285,12 @@@now: Duration,) -> Result<PartialHits, Error> {match self {- Self::Memory(cache) => cache.lookup_batch(requests, now),- Self::Redis { cache, .. } => cache.lookup_batch(requests, now),- Self::Gcs(cache) => cache.lookup_batch(requests, now),- Self::Disk(cache) => cache.lookup_batch(requests, now),- Self::AzureBlob(cache) => cache.lookup_batch(requests, now),+ Self::Memory(cache) => cache.lookup_batch(&Self::exact_requests(requests), now),+ Self::Redis { cache, .. } => cache.lookup_batch(&Self::exact_requests(requests), now),++ Self::Gcs(cache) => cache.lookup_batch(&Self::exact_requests(requests), now),+ Self::Disk(cache) => cache.lookup_batch(&Self::exact_requests(requests), now),+ Self::AzureBlob(cache) => cache.lookup_batch(&Self::exact_requests(requests), now),+ Self::RedisSemantic(_) => Err(Error::UnsupportedOperation),}}@@@ -250,11 -208,11 +300,12 @@@now: Duration,) -> Result<Option<Value>, Error> {match self {- Self::Memory(cache) => cache.async_lookup(request, now).await,- Self::Redis { cache, .. } => cache.async_lookup(request, now).await,- Self::Gcs(cache) => cache.async_lookup(request, now).await,- Self::Disk(cache) => cache.async_lookup(request, now).await,- Self::AzureBlob(cache) => cache.async_lookup(request, now).await,+ Self::Memory(cache) => cache.async_lookup(&request.exact(), now).await,+ Self::Redis { cache, .. } => cache.async_lookup(&request.exact(), now).await,++ Self::Gcs(cache) => cache.async_lookup(&request.exact(), now).await,+ Self::Disk(cache) => cache.async_lookup(&request.exact(), now).await,+ Self::AzureBlob(cache) => cache.async_lookup(&request.exact(), now).await,+ Self::RedisSemantic(cache) => cache.async_lookup(&request.semantic(), now).await,}}@@@ -273,16 -231,10 +324,17 @@@Self::Redis {cache,buffer: Some(buffer),- } => buffer.async_store(cache, request, response, now).await,- Self::Gcs(cache) => cache.async_store(request, response, now).await,- Self::Disk(cache) => cache.async_store(request, response, now).await,- Self::AzureBlob(cache) => cache.async_store(request, response, now).await,+ } => {+ buffer+ .async_store(cache, &request.exact(), response, now)+ .await+ }++ Self::Gcs(cache) => cache.async_store(&request.exact(), response, now).await,+ Self::Disk(cache) => cache.async_store(&request.exact(), response, now).await,+ Self::AzureBlob(cache) => cache.async_store(&request.exact(), response, now).await,+ Self::RedisSemantic(cache) => {+ cache.async_store(&request.semantic(), response, now).await+ }}}@@@ -292,27 -244,11 +344,32 @@@now: Duration,) -> Result<PartialHits, Error> {match self {- Self::Memory(cache) => cache.async_lookup_batch(requests, now).await,- Self::Redis { cache, .. } => cache.async_lookup_batch(requests, now).await,- Self::Gcs(cache) => cache.async_lookup_batch(requests, now).await,- Self::Disk(cache) => cache.async_lookup_batch(requests, now).await,- Self::AzureBlob(cache) => cache.async_lookup_batch(requests, now).await,+ Self::Memory(cache) => {+ cache+ .async_lookup_batch(&Self::exact_requests(requests), now)+ .await+ }+ Self::Redis { cache, .. } => {+ cache+ .async_lookup_batch(&Self::exact_requests(requests), now)+ .await+ }++ Self::Gcs(cache) => {++ cache++ .async_lookup_batch(&Self::exact_requests(requests), now)++ .await++ }+ Self::Disk(cache) => {+ cache+ .async_lookup_batch(&Self::exact_requests(requests), now)+ .await+ }+ Self::AzureBlob(cache) => {+ cache+ .async_lookup_batch(&Self::exact_requests(requests), now)+ .await+ }+ Self::RedisSemantic(_) => Err(Error::UnsupportedOperation),}}@@@ -322,61 -258,11 +379,72 @@@now: Duration,) -> Result<(), Error> {match self {- Self::Memory(cache) => cache.async_store_batch(entries, now).await,- Self::Redis { cache, .. } => cache.async_store_batch(entries, now).await,- Self::Gcs(cache) => cache.async_store_batch(entries, now).await,- Self::Disk(cache) => cache.async_store_batch(entries, now).await,- Self::AzureBlob(cache) => cache.async_store_batch(entries, now).await,+ Self::Memory(cache) => {+ cache+ .async_store_batch(+ entries+ .into_iter()+ .map(|(request, value)| (request.exact(), value))+ .collect(),+ now,+ )+ .await+ }+ Self::Redis { cache, .. } => {+ cache+ .async_store_batch(+ entries+ .into_iter()+ .map(|(request, value)| (request.exact(), value))+ .collect(),+ now,+ )+ .await+ }++ Self::Gcs(cache) => {++ cache++ .async_store_batch(++ entries++ .into_iter()++ .map(|(request, value)| (request.exact(), value))++ .collect(),++ now,++ )++ .await++ }+ Self::Disk(cache) => {+ cache+ .async_store_batch(+ entries+ .into_iter()+ .map(|(request, value)| (request.exact(), value))+ .collect(),+ now,+ )+ .await+ }+ Self::AzureBlob(cache) => {+ cache+ .async_store_batch(+ entries+ .into_iter()+ .map(|(request, value)| (request.exact(), value))+ .collect(),+ now,+ )+ .await+ }+ Self::RedisSemantic(cache) => {+ cache+ .async_store_batch(+ entries+ .into_iter()+ .map(|(request, value)| (request.semantic(), value))+ .collect(),+ now,+ )+ .await+ }}}@@@ -389,8 -275,8 +457,9 @@@}cache.async_flush().await}+ Self::Gcs(cache) => cache.async_flush().await,Self::Disk(cache) => cache.async_flush().await,+ Self::RedisSemantic(_) => Err(Error::UnsupportedOperation),Self::AzureBlob(cache) => cache.async_flush().await,}}@@@ -399,8 -285,8 +468,9 @@@match self {Self::Memory(cache) => cache.test_connection().await,Self::Redis { cache, .. } => cache.test_connection().await,+ Self::Gcs(cache) => cache.test_connection().await,Self::Disk(cache) => cache.test_connection().await,+ Self::RedisSemantic(_) => Err(Error::UnsupportedOperation),Self::AzureBlob(cache) => cache.test_connection().await,}}diff --cc litellm/rust_bridge/_native.pyiindex 23dc26a6260,05a6df6d5af..f823dcfb135--- a/litellm/rust_bridge/_native.pyi+++ b/litellm/rust_bridge/_native.pyi@@@ -93,75 -93,6 +93,84 @@@ class ResponsesWebSocketConnectiondef recv_text(self) -> Future[str | None]: ...def close(self) -> Future[None]: ...+@final+class _CacheTestHandle:+ def __new__(cls, _uninstantiable: Never, /) -> Never: ...+ @staticmethod+ def memory(+ *,+ capacity: int = 200,+ ttl_seconds: float = 600.0,+ max_entry_bytes: int = 1048576,+ ) -> _CacheTestHandle: ...+ @staticmethod+ def redis(+ url: str,+ *,+ ttl_seconds: float = 60.0,+ namespace: str | None = None,+ startup_nodes: list[tuple[str, int]] | None = None,+ ) -> _CacheTestHandle: ...+ @staticmethod+ def disk(directory: str) -> _CacheTestHandle: ...+ @staticmethod++ def gcs(++ bucket_name: str,++ *,++ gcs_path: str | None = None,++ path_service_account: str | None = None,++ endpoint: str | None = None,++ token: str | None = None,++ ) -> _CacheTestHandle: ...++ @staticmethod+ def azure_blob(account_url: str, container: str) -> _CacheTestHandle: ...+ @staticmethod+ def redis_semantic(backend: object) -> _CacheTestHandle: ...+ @property+ def backend(+ self,- ) -> Literal["memory", "redis", "disk", "azure-blob", "redis_semantic"]: ...++ ) -> Literal["memory", "redis", "gcs", "disk", "azure-blob", "redis_semantic"]: ...+ def _bind_facade(self, facade: object) -> None: ...++@final+class _CacheTestBinding:+ def __new__(cls, _uninstantiable: Never, /) -> Never: ...+ @property+ def kind(self) -> Literal["disabled", "native", "python_callback"]: ...+ def lookup(+ self, request: object, *, callback_kwargs: object = None+ ) -> object: ...+ def store(+ self, request: object, response: object, *, callback_kwargs: object = None+ ) -> None: ...+ def lookup_batch(+ self, requests: object, *, callback_kwargs: object = None+ ) -> object: ...+ def async_lookup(+ self, request: object, *, callback_kwargs: object = None+ ) -> Future[object]: ...+ def async_store(+ self, request: object, response: object, *, callback_kwargs: object = None+ ) -> Future[object]: ...+ def async_lookup_batch(+ self, requests: object, *, callback_kwargs: object = None+ ) -> Future[object]: ...+ def async_store_batch(+ self,+ requests: object,+ responses: object,+ *,+ callback_result: object = None,+ callback_kwargs: object = None,+ ) -> Future[object]: ...+ def async_flush(self) -> Future[object]: ...+ def ping(self) -> Future[object]: ...++@final+class _CacheTestResolver:+ def __new__(cls, namespace: object) -> _CacheTestResolver: ...+ def resolve(self) -> _CacheTestBinding: ...+@finalclass TokenCounter:def __new__(cls, tokenizer_json: str) -> TokenCounter: ...diff --cc tests/test_litellm_rust/test_cache.pyindex 8a8c83cd82b,ba95b21d530..c11a43abc80--- a/tests/test_litellm_rust/test_cache.py+++ b/tests/test_litellm_rust/test_cache.py@@@ -29,16 -26,11 +30,17 @@@ from litellm.caching.gcs_cache import Gfrom litellm.caching.disk_cache import DiskCachefrom litellm.caching.in_memory_cache import InMemoryCachefrom litellm.caching.redis_cluster_cache import RedisClusterCache+from litellm.caching.redis_semantic_cache import RedisSemanticCachefrom litellm.rust_bridge import _nativefrom litellm.types.caching import LiteLLMCacheType+from litellm.types.llms.custom_llm import CustomLLMItem+from litellm.types.utils import EmbeddingResponse+ from tests.test_litellm_rust.support.fake_gcs import FakeGcsfrom tests.test_litellm_rust.support.isolation import rebound+_CacheTestHandle: Final = _native._CacheTestHandle # pyright: ignore[reportPrivateUsage] # test-only handle has no public module name+_CacheTestResolver: Final = _native._CacheTestResolver # pyright: ignore[reportPrivateUsage] # test-only resolver has no public module name+pytestmark: Final = pytest.mark.requires_rust_extension