{"record":{"id":"64551e87194dbfe1","repo":"BerriAI/litellm","slug":"similarity-threshold-must-be-provided-passed-none-64551e","errorCode":null,"errorMessage":"similarity_threshold must be provided, passed None","messagePattern":"similarity_threshold must be provided, passed None","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/caching/redis_semantic_cache.py","lineNumber":79,"sourceCode":"            similarity_threshold: Threshold for semantic similarity (0.0 to 1.0)\n                where 1.0 requires exact matches and 0.0 accepts any match\n            embedding_model: Model to use for generating embeddings\n            index_name: Name for the Redis index\n            ttl: Default time-to-live for cache entries in seconds\n            **kwargs: Additional arguments passed to the Redis client\n\n        Raises:\n            Exception: If similarity_threshold is not provided or required Redis\n                connection information is missing\n        \"\"\"\n        if index_name is None:\n            index_name = self.DEFAULT_REDIS_INDEX_NAME\n\n        print_verbose(f\"Redis semantic-cache initializing index - {index_name}\")\n\n        # Validate similarity threshold\n        if similarity_threshold is None:\n            raise ValueError(\"similarity_threshold must be provided, passed None\")\n\n        # Store configuration\n        self.similarity_threshold = similarity_threshold\n\n        # Convert similarity threshold [0,1] to distance threshold [0,2]\n        # For cosine distance: 0 = most similar, 2 = least similar\n        # While similarity: 1 = most similar, 0 = least similar\n        self.distance_threshold = 1 - similarity_threshold\n        self.embedding_model = embedding_model\n\n        # Set up Redis connection\n        if redis_url is None:\n            try:\n                # Attempt to use provided parameters or fallback to environment variables\n                host = host or os.environ[\"REDIS_HOST\"]\n                port = port or os.environ[\"REDIS_PORT\"]\n                password = password or os.environ[\"REDIS_PASSWORD\"]\n            except KeyError as e:","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/caching/redis_semantic_cache.py#L61-L97","documentation":"RedisSemanticCache.__init__ requires an explicit similarity_threshold (0.0–1.0) to convert into a cosine-distance threshold; None means the cache cannot decide which stored embeddings count as semantic hits, so construction stops.","triggerScenarios":"Thrown at litellm/caching/redis_semantic_cache.py:79 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a non-None similarity_threshold (a float between 0 and 1) when constructing the Redis semantic cache.","Choose a threshold appropriate for your embedding model, e.g. 0.8 as a starting point."],"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"}