{"record":{"id":"3776fc4c3e7dc4bf","repo":"mlflow/mlflow","slug":"str-e-3776fc","errorCode":null,"errorMessage":"{str(e)}","messagePattern":"\\{str\\(e\\)\\}","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"mlflow/server/assistant/api.py","lineNumber":268,"sourceCode":"        raise HTTPException(\n            status_code=400,\n            detail=\"Gateway vendor connections require an API key.\",\n        )\n    if name != MlflowGatewayProvider.GATEWAY_PROVIDER_NAME:\n        raise HTTPException(\n            status_code=400,\n            detail=\"API keys must be stored in LLM Connections through the \"\n            \"'mlflow_gateway' provider.\",\n        )\n    if gateway_vendor is None:\n        raise HTTPException(\n            status_code=400,\n            detail=\"Gateway API keys require a gateway_vendor.\",\n        )\n    try:\n        return ensure_gateway_connection(gateway_vendor, api_key)\n    except (GatewayUnsupportedError, ValueError) as e:\n        raise HTTPException(status_code=400, detail=str(e)) from e\n\n\ndef _gateway_vendor_options() -> dict[str, list[str]]:\n    return {vendor: [model] for vendor, model in _GATEWAY_VENDOR_MODELS.items()}\n\n\ndef _gateway_vendor_from_managed_endpoint(model: str | None) -> str | None:\n    if not model:\n        return None\n    prefix = \"mlflow-assistant-\"\n    vendor = model.removeprefix(prefix)\n    if vendor == model:\n        return None\n    return vendor if vendor in _GATEWAY_VENDOR_MODELS else None\n\n\ndef _resolved_provider_info(\n    provider: AssistantProvider,","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/server/assistant/api.py#L250-L286","documentation":"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).","triggerScenarios":"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).","commonSituations":"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.","solutions":["Read the HTTP 400 detail (the str(e) message) — it names the actual problem; fix that specific issue.","Use only vendors listed in the Assistant config's gateway vendor options (_gateway_vendor_options / _GATEWAY_VENDOR_MODELS).","Upgrade MLflow if the vendor is newly supported but your installed version predates it.","Verify the api_key format matches the vendor's expectations."],"exampleFix":"// before\n{\"gateway_vendor\": \"openai-ai\", \"api_key\": \"sk-...\"}   // 400: unsupported gateway vendor\n// after\n{\"gateway_vendor\": \"openai\", \"api_key\": \"sk-...\"}","handlingStrategy":"validation","validationCode":"# fetch allowed vendors from the assistant config endpoint first\noptions = requests.get(f\"{uri}/api/2.0/mlflow/assistant/config\").json().get(\"gateway_vendor_options\", {})\nassert vendor in options, f\"Unsupported gateway_vendor {vendor!r}; choose one of {list(options)}\"","typeGuard":null,"tryCatchPattern":"try:\n    requests.put(config_url, json={\"providers\": [payload]}).raise_for_status()\nexcept requests.HTTPError as e:\n    if e.response.status_code == 400:\n        # detail contains the underlying GatewayUnsupportedError/ValueError message\n        raise ValueError(f\"Gateway connection rejected: {e.response.json().get('detail')}\") from e\n    raise","preventionTips":["Only offer vendors returned by the server's gateway_vendor_options in your UI/script","Keep MLflow upgraded so newly added gateway vendors are available","Log the 400 detail message; it names the exact ensure_gateway_connection failure"],"tags":["http-400","gateway","validation","api-key"],"backgroundTag":"unsupported-gateway-vendor","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}