mlflow/mlflow · error · TypeError
Invalid config type {config.model.config}
Error message
Invalid config type {config.model.config} What it means
The AnthropicProvider constructor requires the endpoint's model config to be an AnthropicConfig instance. If config.model.config is None or a different config type (e.g., an OpenAI or Cohere config object), a TypeError is raised at endpoint/adapter initialization time, before any request is made.
Source
Thrown at mlflow/gateway/providers/anthropic.py:537
raise NotImplementedError
@classmethod
def model_to_embeddings(cls, resp, config):
raise NotImplementedError
class AnthropicProvider(BaseProvider, AnthropicAdapter):
DISPLAY_NAME = "Anthropic"
CONFIG_TYPE = AnthropicConfig
PASSTHROUGH_PROVIDER_PATHS = {
PassthroughAction.ANTHROPIC_MESSAGES: "messages",
}
def __init__(self, config: EndpointConfig, enable_tracing: bool = False) -> None:
super().__init__(config, enable_tracing=enable_tracing)
if config.model.config is None or not isinstance(config.model.config, AnthropicConfig):
raise TypeError(f"Invalid config type {config.model.config}")
self.anthropic_config: AnthropicConfig = config.model.config
@property
def headers(self) -> dict[str, str]:
return {
"x-api-key": self.anthropic_config.anthropic_api_key,
"anthropic-version": self.anthropic_config.anthropic_version,
}
@property
def base_url(self) -> str:
return self.anthropic_config.anthropic_api_base
@property
def adapter_class(self) -> type[ProviderAdapter]:
return AnthropicAdapter
def _get_headers(View on GitHub (pinned to 6a27f2decc)
Solutions
- Fix the gateway endpoint config so the model block includes a valid AnthropicConfig (anthropic_api_key and target_uri for Anthropic).
- Use AnthropicProvider only with endpoints whose provider is 'anthropic'; match provider class to the config type.
- Validate your config file (mlflow gateway start) and ensure required Anthropic keys are present before server start.
- If constructing programmatically, pass AnthropicConfig(...) explicitly instead of None or another provider's config.
Example fix
// before provider = AnthropicProvider(config=openai_endpoint_config) // after from mlflow.gateway.config import AnthropicConfig provider = AnthropicProvider(config=anthropic_endpoint_config) # config.model.config is AnthropicConfig
Defensive patterns
Strategy: type-guard
Validate before calling
from mlflow.gateway.config import AnthropicConfig
if config.model.config is None or not isinstance(config.model.config, AnthropicConfig):
raise ValueError("Endpoint config must include an AnthropicConfig model config block before creating AnthropicProvider") Type guard
def is_anthropic_config(config) -> bool:
from mlflow.gateway.config import AnthropicConfig
return config is not None and isinstance(getattr(config.model, "config", None), AnthropicConfig) Try / catch
try:
provider = AnthropicProvider(config=endpoint_config)
except TypeError as e:
if "Invalid config type" in str(e):
raise ValueError(
f"Endpoint '{endpoint_config.name}' is missing an Anthropic config block; "
"add anthropic_api_key and anthropic provider settings to your gateway config."
) from e
raise Prevention
- Ensure each gateway endpoint's config YAML includes a complete model config block for its provider.
- Match provider class to config type; never reuse one provider's EndpointConfig for another.
- Run 'mlflow gateway start' config validation locally before deploying.
When it happens
Trigger: Instantiating AnthropicProvider (directly or via the gateway server startup/route wiring) with an EndpointConfig whose model.config is None or of the wrong class.
Common situations: A gateway config YAML missing the provider's config block so model.config is None; copying an endpoint config from another provider; programmatic config construction passing the wrong config class; malformed config file not parsed into AnthropicConfig.
Related errors
- trackingUri must be a string
- experimentId must be a string
- Unexpected config type {config.model.config}
- Cannot set both 'temperature' and 'top_p' parameters.
- Invalid value for max_tokens: cannot exceed {MLFLOW_AI_GATEW
AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29).
Data as JSON: /api/errors/30b6e577187dda02.
Report an issue: GitHub.