How to Send a CSV File to an MLflow Model Server
An MLflow model server reads CSV as well as JSON, so a file exported from a spreadsheet or by pandas can go to it as it is. The request needs the header Content-Type: text/csv, and curl needs --data-binary to send the file unchanged. This guide sends two rows from a CSV file to a served model, with real output from MLflow 3.18.0.
Syntax
- macOS / Linux
- Windows (PowerShell)
curl http://HOST:PORT/invocations -H "Content-Type: text/csv" --data-binary @FILE.csv
Invoke-RestMethod http://HOST:PORT/invocations -Method Post -ContentType "text/csv" -InFile FILE.csv
| Part | What it means |
|---|---|
Content-Type: text/csv | Tells the server the body is CSV |
--data-binary @FILE.csv | Sends the file exactly as it is; -InFile does the same in PowerShell |
FILE.csv | A header row with the model's column names, then one row per prediction |
MLflow's guide to the inference server: "CSV input must be a valid pandas.DataFrame CSV representation." The same guide names the content type application/csv, but the server only accepts text/csv: Fixed: This predictor only supports the following content types ... Got 'application/csv'.
Prerequisites
- An MLflow tracking server at
http://127.0.0.1:8080, such asmlflow server --port 8080. mlflowandscikit-learnin your project, for example withuv add mlflow scikit-learn pandas.
Step 1: Log a Model and Write a CSV File
The example trains a logistic regression on the iris flowers, logs it, and writes two flowers, a setosa and a virginica, to flowers.csv:

import mlflow
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
mlflow.set_tracking_uri("http://127.0.0.1:8080")
mlflow.set_experiment("csv-request-example")
iris = load_iris(as_frame=True)
X, y = iris.data, iris.target_names[iris.target]
model = LogisticRegression(max_iter=1000).fit(X, y)
with mlflow.start_run():
info = mlflow.sklearn.log_model(model, name="model", input_example=X.head(3))
print("Model URI:", info.model_uri)
X.iloc[[0, 100]].to_csv("flowers.csv", index=False) # a setosa and a virginica
uv run python log_csv_model.py
Model URI: models:/m-04f61a4651704fe78403fe4c99feb8b7
The file it wrote:
sepal length (cm),sepal width (cm),petal length (cm),petal width (cm)
5.1,3.5,1.4,0.2
6.3,3.3,6.0,2.5
Step 2: Serve the Model
- macOS / Linux
- Windows (PowerShell)
export MLFLOW_TRACKING_URI=http://127.0.0.1:8080
uv run mlflow models serve -m "models:/m-04f61a4651704fe78403fe4c99feb8b7" -p 5001 --env-manager uv
$env:MLFLOW_TRACKING_URI = "http://127.0.0.1:8080"
uv run mlflow models serve -m "models:/m-04f61a4651704fe78403fe4c99feb8b7" -p 5001 --env-manager uv
Step 3: Send the CSV File
- macOS / Linux
- Windows (PowerShell)
curl http://127.0.0.1:5001/invocations -H "Content-Type: text/csv" --data-binary @flowers.csv
{"predictions": ["setosa", "virginica"]}
Invoke-RestMethod http://127.0.0.1:5001/invocations -Method Post -ContentType "text/csv" -InFile flowers.csv
predictions
-----------
{setosa, virginica}

The server read the header for the column names and answered with one species per row. The answer is JSON even though the request was CSV.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Content-Type: application/csv, as in MLflow's guide | 415 Unsupported Media Type | text/csv |
--data @flowers.csv instead of --data-binary | curl removes the line breaks, so the rows run together | --data-binary: How to Send a File in a POST Request with curl |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Model is missing inputs [...]. Note that there were extra inputs: ['0.2', '3.5', '5.1', '1.4'] | The file has no header, so its first row was read as the column names | Put the model's column names in the first row |
Failed to parse input as a Pandas DataFrame ... could not convert string to float: 'wide' | A value in a number column isn't a number | Fix the value in the file |
FAQ
Are whole numbers in the file a problem?
Not for the server: it reads the CSV with the column types in the model's signature. mlflow models predict -t csv on the command line reads it without them, which is why the same file can fail there: Fixed: Incompatible input types for column ... Can not safely convert int64 to float64.
Can the answer be CSV too?
No: the server always answers with JSON, {"predictions": [...]}.
Conclusion
flowers.csv, a header and two rows, sent with Content-Type: text/csv and --data-binary (or PowerShell's -InFile), came back from the iris model as {"predictions": ["setosa", "virginica"]}.
Additional Resources
- Deploy MLflow Model as a Local Inference Server — CSV input and the other formats.
- curl --data-binary — sending a file unchanged.
