{"record":{"id":"16ae0039ac7cffd5","repo":"BerriAI/litellm","slug":"please-install-litellm-with-litellm-caching-to","errorCode":null,"errorMessage":"Please install litellm with `litellm[caching]` to use disk caching.","messagePattern":"Please install litellm with `litellm\\[caching\\]` to use disk caching\\.","errorType":"exception","errorClass":"ModuleNotFoundError","httpStatus":null,"severity":"error","filePath":"litellm/caching/disk_cache.py","lineNumber":19,"sourceCode":"import json\nfrom typing import TYPE_CHECKING, Any, Final\n\nfrom .base_cache import BaseCache\n\nif TYPE_CHECKING:\n    from opentelemetry.trace import Span as _Span\n\n    Span = _Span | Any\nelse:\n    Span = Any\n\n\nclass DiskCache(BaseCache):\n    def __init__(self, disk_cache_dir: str | None = None):\n        try:\n            import diskcache as dc\n        except ModuleNotFoundError as e:\n            raise ModuleNotFoundError(\"Please install litellm with `litellm[caching]` to use disk caching.\") from e\n\n        # if users don't provider one, use the default litellm cache\n        if disk_cache_dir is None:\n            self.disk_cache = dc.Cache(\".litellm_cache\")\n        else:\n            self.disk_cache = dc.Cache(disk_cache_dir)\n\n    def set_cache(self, key, value, **kwargs):\n        if \"ttl\" in kwargs:\n            self.disk_cache.set(key, value, expire=kwargs[\"ttl\"])\n        else:\n            self.disk_cache.set(key, value)\n\n    async def async_set_cache(self, key, value, **kwargs):\n        self.set_cache(key=key, value=value, **kwargs)\n\n    async def async_set_cache_pipeline(self, cache_list, **kwargs):\n        for cache_key, cache_value in cache_list:","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/caching/disk_cache.py#L1-L37","documentation":"DiskCache.__init__ fails to import the optional `diskcache` dependency; the sentinel error tells the user the `litellm[caching]` extra was not installed, with the original ModuleNotFoundError chained as the cause.","triggerScenarios":"Thrown at litellm/caching/disk_cache.py:19 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Install the caching extra: pip install 'litellm[caching]'.","Alternatively use an in-memory or Redis cache instead of disk caching."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}