mlflow/mlflow · error · TypeError

Unexpected config type {config.model.config}

Error message

Unexpected config type {config.model.config}

What it means

Like the HuggingFace provider, LiteLLM requires model.config to be an instance of LiteLLMConfig. If it is None or a different config class, the provider raises TypeError at construction, since it stores the config as self.litellm_config and cannot proceed without it.

Source

Thrown at mlflow/gateway/providers/litellm.py:95

    PASSTHROUGH_PROVIDER_PATHS = {
        PassthroughAction.OPENAI_CHAT: "chat/completions",
        PassthroughAction.OPENAI_EMBEDDINGS: "embeddings",
        PassthroughAction.OPENAI_RESPONSES: "responses",
        PassthroughAction.ANTHROPIC_MESSAGES: "messages",
        PassthroughAction.GEMINI_GENERATE_CONTENT: "{model}:generateContent",
        PassthroughAction.GEMINI_STREAM_GENERATE_CONTENT: "{model}:streamGenerateContent",
    }

    def __init__(self, config: EndpointConfig, enable_tracing: bool = False) -> None:
        super().__init__(config, enable_tracing=enable_tracing)
        if importlib.util.find_spec("litellm") is None:
            raise MlflowException(
                "The `litellm` package is required to use the LiteLLM provider but is not "
                "installed. Please install it with: `pip install litellm`"
            )
        if config.model.config is None or not isinstance(config.model.config, LiteLLMConfig):
            raise TypeError(f"Unexpected config type {config.model.config}")
        self.litellm_config: LiteLLMConfig = config.model.config

    def get_provider_name(self) -> str:
        """
        Return the actual underlying provider name instead of "LiteLLM".

        For example, if litellm_provider is "anthropic", returns "anthropic"
        instead of "LiteLLM" for more accurate tracing and metrics.
        """
        if self.litellm_config.litellm_provider:
            return self.litellm_config.litellm_provider
        return self.DISPLAY_NAME

    @property
    def adapter_class(self):
        return LiteLLMAdapter

    def _build_litellm_kwargs(self, payload: dict[str, Any]) -> dict[str, Any]:

View on GitHub (pinned to 6a27f2decc)

Solutions

  1. Add the LiteLLMConfig block under model.config in the endpoint definition (it holds the litellm auth/auth_type fields).
  2. Programmatically, set model.config to a LiteLLMConfig instance.
  3. Verify the provider name matches the config class you are supplying.

Example fix

# before
model:
  provider: litellm
  name: gpt-4o
# after
model:
  provider: litellm
  name: gpt-4o
  config:
    litellm_config:
      auth_type: openai
Defensive patterns

Strategy: type-guard

Validate before calling

from mlflow.gateway.config import LiteLLMConfig
if not isinstance(config.model.config, LiteLLMConfig):
    raise TypeError("litellm endpoints require a LiteLLMConfig under model.config")

Type guard

def has_valid_litellm_config(config) -> bool:
    return isinstance(getattr(getattr(config, 'model', None), 'config', None), LiteLLMConfig)

Try / catch

try:
    provider = LiteLLMProvider(config)
except TypeError as e:
    logger.error("Bad LiteLLM endpoint config: %s", e)
    raise GatewayConfigError("model.config must be a LiteLLMConfig")

Prevention

When it happens

Trigger: Creating a litellm gateway endpoint without the model.config block, or with a config of another provider's type (e.g. OpenAI/HF config attached to a litellm endpoint), or passing a plain dict programmatically.

Common situations: Missing litellm_config section in the endpoint YAML; programmatic EndpointConfig built with the wrong CONFIG_TYPE; mixing provider endpoint templates.

Related errors


AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29). Data as JSON: /api/errors/731eeb8d0aeab43d. Report an issue: GitHub.