mlflow/mlflow · error · HTTPException

{str(e)}

Error message

{str(e)}

What it means

After validating vendor + key, _store_gateway_api_key calls ensure_gateway_connection to create/verify the gateway LLM connection. If the vendor is unsupported (GatewayUnsupportedError) or the arguments are invalid (ValueError), the exception is converted to an HTTP 400 whose detail is the underlying error message str(e).

Source

Thrown at mlflow/server/assistant/api.py:268

        raise HTTPException(
            status_code=400,
            detail="Gateway vendor connections require an API key.",
        )
    if name != MlflowGatewayProvider.GATEWAY_PROVIDER_NAME:
        raise HTTPException(
            status_code=400,
            detail="API keys must be stored in LLM Connections through the "
            "'mlflow_gateway' provider.",
        )
    if gateway_vendor is None:
        raise HTTPException(
            status_code=400,
            detail="Gateway API keys require a gateway_vendor.",
        )
    try:
        return ensure_gateway_connection(gateway_vendor, api_key)
    except (GatewayUnsupportedError, ValueError) as e:
        raise HTTPException(status_code=400, detail=str(e)) from e


def _gateway_vendor_options() -> dict[str, list[str]]:
    return {vendor: [model] for vendor, model in _GATEWAY_VENDOR_MODELS.items()}


def _gateway_vendor_from_managed_endpoint(model: str | None) -> str | None:
    if not model:
        return None
    prefix = "mlflow-assistant-"
    vendor = model.removeprefix(prefix)
    if vendor == model:
        return None
    return vendor if vendor in _GATEWAY_VENDOR_MODELS else None


def _resolved_provider_info(
    provider: AssistantProvider,

View on GitHub (pinned to 6a27f2decc)

Solutions

  1. Read the HTTP 400 detail (the str(e) message) — it names the actual problem; fix that specific issue.
  2. Use only vendors listed in the Assistant config's gateway vendor options (_gateway_vendor_options / _GATEWAY_VENDOR_MODELS).
  3. Upgrade MLflow if the vendor is newly supported but your installed version predates it.
  4. Verify the api_key format matches the vendor's expectations.

Example fix

// before
{"gateway_vendor": "openai-ai", "api_key": "sk-..."}   // 400: unsupported gateway vendor
// after
{"gateway_vendor": "openai", "api_key": "sk-..."}
Defensive patterns

Strategy: validation

Validate before calling

# fetch allowed vendors from the assistant config endpoint first
options = requests.get(f"{uri}/api/2.0/mlflow/assistant/config").json().get("gateway_vendor_options", {})
assert vendor in options, f"Unsupported gateway_vendor {vendor!r}; choose one of {list(options)}"

Try / catch

try:
    requests.put(config_url, json={"providers": [payload]}).raise_for_status()
except requests.HTTPError as e:
    if e.response.status_code == 400:
        # detail contains the underlying GatewayUnsupportedError/ValueError message
        raise ValueError(f"Gateway connection rejected: {e.response.json().get('detail')}") from e
    raise

Prevention

When it happens

Trigger: update_config with a gateway_vendor not present in the supported vendor list (_GATEWAY_VENDOR_MODELS / gateway server config), or a key/vendor combination that ensure_gateway_connection rejects (malformed key, unknown vendor alias).

Common situations: Typos in vendor names (e.g. 'anthropic' vs 'anthropic-' variants); using a gateway vendor the installed MLflow version doesn't support; empty or malformed API keys rejected by validation inside ensure_gateway_connection.

Related errors


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