BerriAI/litellm · error · ValueError

Missing required Redis configuration

Error message

Missing required Redis configuration: {missing_var}. Provide {missing_var} or redis_url.

What it means

RedisSemanticCache connection setup found neither a redis_url nor the required Redis environment variable (e.g. REDIS_HOST); the message names the exact missing variable so the caller knows whether to pass it directly or supply a full URL.

Solutions

  1. Provide the missing Redis configuration variable named in the error, or pass a single redis_url.
  2. Set REDIS_HOST/REDIS_PORT (and REDIS_PASSWORD if needed) in the environment, or configure redis_url directly.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/caching/redis_semantic_cache.py:100 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/82987ccace73a890. Report an issue: GitHub.

Appendix: source

Thrown at litellm/caching/redis_semantic_cache.py:100

        self.similarity_threshold = similarity_threshold

        # Convert similarity threshold [0,1] to distance threshold [0,2]
        # For cosine distance: 0 = most similar, 2 = least similar
        # While similarity: 1 = most similar, 0 = least similar
        self.distance_threshold = 1 - similarity_threshold
        self.embedding_model = embedding_model

        # Set up Redis connection
        if redis_url is None:
            try:
                # Attempt to use provided parameters or fallback to environment variables
                host = host or os.environ["REDIS_HOST"]
                port = port or os.environ["REDIS_PORT"]
                password = password or os.environ["REDIS_PASSWORD"]
            except KeyError as e:
                # Raise a more informative exception if any of the required keys are missing
                missing_var: Final = e.args[0]
                raise ValueError(
                    f"Missing required Redis configuration: {missing_var}. Provide {missing_var} or redis_url."
                ) from e

            redis_url = f"redis://:{password}@{host}:{port}"

        print_verbose(f"Redis semantic-cache redis_url: {redis_url}")

        # Defer redisvl index construction until first use. redisvl's
        # CustomTextVectorizer eagerly embeds a probe string at construction;
        # building lazily ensures that probe runs after llm_router is wired so
        # per-deployment auth (e.g. Bedrock aws_role_name) is applied.
        self._index_name = index_name
        self._redis_url = redis_url
        self._llmcache = None

    @property
    def llmcache(self) -> object:
        if getattr(self, "_llmcache", None) is None:

View on GitHub (pinned to 77b7c6c40c)