BerriAI/litellm · error · ValueError

Missing required Valkey configuration. Provide host and…

Error message

Missing required Valkey configuration. Provide host and port (or VALKEY_HOST/VALKEY_PORT), or pass redis_url.

What it means

ValkeySemanticCache could not build a connection target: no redis_url was passed and host/port (or VALKEY_HOST/VALKEY_PORT env vars) were not resolvable via _build_valkey_url, so there is no endpoint to create the vector index on.

Solutions

  1. Provide host and port (or set VALKEY_HOST/VALKEY_PORT), or pass a redis_url.
  2. Verify the Valkey server is reachable at the configured address.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/caching/valkey_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/a3a1aa8af92dcdd9. Report an issue: GitHub.

Appendix: source

Thrown at litellm/caching/valkey_semantic_cache.py:100

        self.key_prefix = f"{self.index_name}:"
        self._index_dim: int | None = None

        resolved_url = None
        if sync_client is None or async_client is None:
            resolved_url = redis_url or self._build_valkey_url(host, port, password, ssl)
        self.sync_client = sync_client if sync_client is not None else Redis.from_url(resolved_url)
        self.async_client = async_client if async_client is not None else AsyncRedis.from_url(resolved_url)

        print_verbose(f"Valkey semantic-cache initializing index - {self.index_name}")

    @staticmethod
    def _build_valkey_url(host: str | None, port: str | None, password: str | None, ssl: bool = False) -> str:
        host = host or os.environ.get("VALKEY_HOST") or os.environ.get("REDIS_HOST")
        port = port or os.environ.get("VALKEY_PORT") or os.environ.get("REDIS_PORT")
        password = password or os.environ.get("VALKEY_PASSWORD") or os.environ.get("REDIS_PASSWORD")

        if not host or not port:
            raise ValueError(
                "Missing required Valkey configuration. Provide host and port "
                "(or VALKEY_HOST/VALKEY_PORT), or pass redis_url."
            )

        credentials: Final = f":{password}@" if password else ""
        scheme: Final = "rediss" if ssl else "redis"
        return f"{scheme}://{credentials}{host}:{port}"

    @classmethod
    def _scope_tag(cls, key: str) -> str:
        # valkey-search TAG fields tokenize on punctuation and do not honour
        # backslash escaping, so an arbitrary cache key cannot be matched
        # verbatim. Hashing to hex yields a token that is always exact-match
        # safe and still uniquely isolates a caller's scope.
        return hashlib.sha256(str(key).encode("utf-8")).hexdigest()

    @staticmethod
    def _embedding_to_bytes(embedding: list[float]) -> bytes:

View on GitHub (pinned to 77b7c6c40c)