mlflow/mlflow · error · MlflowException

INVALID_PARAMETER_VALUE

INVALID_PARAMETER_VALUE

Error message

Content type must be one of {_CONTENT_TYPE_JSON} or {_CONTENT_TYPE_CSV}.

What it means

mlflow.models.predict only accepts 'json' or 'csv' as content_type when testing a pyfunc model locally. Any other content_type value raises MlflowException.invalid_parameter_value immediately, before any input is read.

Source

Thrown at mlflow/models/python_api.py:230

            input_data={"x": 1, "y": 2},
            env_manager="uv",
            output_path="output.json",
        )

        # Run prediction with pre-release versions
        mlflow.models.predict(
            model_uri=f"runs:/{run_id}/model",
            input_data={"x": 1, "y": 2},
            env_manager="uv",
            extra_envs={"UV_PRERELEASE": "allow"},
        )

    """
    # to avoid circular imports
    from mlflow.pyfunc import _PREBUILD_ENV_ROOT_LOCATION

    if content_type not in [_CONTENT_TYPE_JSON, _CONTENT_TYPE_CSV]:
        raise MlflowException.invalid_parameter_value(
            f"Content type must be one of {_CONTENT_TYPE_JSON} or {_CONTENT_TYPE_CSV}."
        )
    if extra_envs and env_manager not in (
        _EnvManager.VIRTUALENV,
        _EnvManager.CONDA,
        _EnvManager.UV,
    ):
        raise MlflowException.invalid_parameter_value(
            "Extra environment variables are only supported when env_manager is "
            f"set to '{_EnvManager.VIRTUALENV}', '{_EnvManager.CONDA}' or '{_EnvManager.UV}'."
        )
    if env_manager == _EnvManager.UV:
        if not shutil.which("uv"):
            raise MlflowException(
                f"Found '{env_manager}' as env_manager, but the 'uv' command is not found in the "
                f"PATH. {UV_INSTALLATION_INSTRUCTIONS} Alternatively, you can use 'virtualenv' or "
                "'conda' as the environment manager, but note their performances are not "
                "as good as 'uv'."

View on GitHub (pinned to 6a27f2decc)

Solutions

  1. Set content_type="json" or content_type="csv" (lowercase literals).
  2. Omit content_type only when the input doesn't need serialization guidance (JSON path).
  3. If data is a DataFrame, use content_type="csv" or pass it directly as input_data with json-compatible types.

Example fix

// before
predict(model_uri=uri, input_data=df, content_type="text/csv")
// after
predict(model_uri=uri, input_data=df, content_type="csv")
Defensive patterns

Strategy: validation

Validate before calling

def valid_content_type(ct):
    return ct in ("json", "csv")

Try / catch

try:
    predict(model_uri=uri, input_data=data, content_type=ct)
except MlflowException as e:
    if e.error_code == "INVALID_PARAMETER_VALUE":
        print("use content_type='json' or 'csv'")

Prevention

When it happens

Trigger: Calling mlflow.models.predict(model_uri=..., input_data=..., content_type='json/object') or 'application/json', 'text/csv', 'parquet', or passing an uppercase 'JSON'.

Common situations: Copying a content type from an HTTP API call (application/json) into the Python API; confusing this parameter with serving-input content types; typos like 'jsn'.

Related errors


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