BerriAI/litellm · error · ValueError

api_base is required for RAGFlow provider. Set it via api_ba

Error message

api_base is required for RAGFlow provider. Set it via api_base parameter, RAGFLOW_API_BASE environment variable, or litellm.api_base

What it means

Configuration guard in the RAGFlow get_complete_url: no base URL could be resolved from the argument, litellm_params, RAGFLOW_API_BASE env var, or global litellm.api_base, so the chat/agent endpoint URL cannot be constructed.

Source

Thrown at litellm/llms/ragflow/chat/transformation.py:97

        Args:
            api_base: Base API URL (e.g., http://ragflow-server:port or http://ragflow-server:port/v1)
            api_key: API key (not used in URL construction)
            model: Model name in format ragflow/{endpoint_type}/{id}/{model}
            optional_params: Optional parameters
            litellm_params: LiteLLM parameters (may contain api_base)
            stream: Whether streaming is enabled

        Returns:
            Complete URL for the API call
        """
        # Get api_base from multiple sources: input param, litellm_params, environment, or global litellm setting
        if litellm_params and hasattr(litellm_params, "api_base") and litellm_params.api_base:
            api_base = api_base or litellm_params.api_base

        api_base = api_base or litellm.api_base or get_secret("RAGFLOW_API_BASE") or get_secret_str("RAGFLOW_API_BASE")

        if api_base is None:
            raise ValueError(
                "api_base is required for RAGFlow provider. Set it via api_base parameter, RAGFLOW_API_BASE environment variable, or litellm.api_base"
            )

        # Parse model name to extract endpoint type and ID
        endpoint_type, entity_id, _ = self._parse_ragflow_model(model)

        # Remove trailing slash from api_base if present
        api_base = api_base.rstrip("/")

        # Strip /v1 or /api/v1 from api_base if present, since we'll add the full path
        # Check /api/v1 first because /api/v1 ends with /v1
        if api_base.endswith("/api/v1"):
            api_base = api_base[:-7]  # Remove /api/v1
        elif api_base.endswith("/v1"):
            api_base = api_base[:-3]  # Remove /v1

        # Construct the RAGFlow-specific path
        encoded_entity_id: Final = encode_url_path_segment(entity_id, field_name="entity_id")

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Set the RAGFLOW_API_BASE environment variable to your RAGFlow server URL.
  2. Or pass api_base parameter / set litellm.api_base.

Example fix

os.environ["RAGFLOW_API_BASE"] = "http://localhost:9380"
Defensive patterns

Strategy: validation

When it happens

Trigger: Triggered when calling the RAGFlow provider without api_base: parameter, RAGFLOW_API_BASE env var, and litellm.api_base all unset.

Common situations: See trigger scenarios.


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