Skip to main content

How to Serve a Registered Model by Alias with mlflow models serve

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

mlflow models serve can serve whichever version of a registered model an alias points to, such as production. The address is read once, when the server starts: move the alias, and the running server keeps the version it loaded until you restart it. This guide shows both, with real output from MLflow 3.18.0.

Syntax​

Syntax
mlflow models serve -m "models:/NAME@ALIAS" -p PORT --env-manager uv
PartWhat it means
models:/NAME@ALIASThe version of the registered model NAME that the alias ALIAS points to
models:/NAME/VERSIONA fixed version instead, such as models:/diabetes-progression/2
-p PORTThe port to listen on
--env-manager uvBuild the model's environment with uv

MLflow's Model Registry guide describes the alias address as models:/<registered model name>@<alias>.

Prerequisites​

  • An MLflow tracking server with a database backend at http://127.0.0.1:8080, such as mlflow server --port 8080 with its default SQLite database. The registry needs one.
  • mlflow and scikit-learn in your project, for example with uv add mlflow scikit-learn pandas.

Step 1: Register Two Versions and Set the Alias​

The example trains two Ridge regressions on scikit-learn's diabetes data, which predicts how far the disease progresses in a year, with a different alpha each. It registers both as diabetes-progression, points production at version 1, and saves one patient in a file, in the layout the server reads:

The register_diabetes.py script in a macOS-style code window: two Ridge models with alpha 1.0 and 0.01 logged and registered as diabetes-progression, the production alias set on version 1, and the first patient saved to first_patient.json in the dataframe_split layout.

register_diabetes.py
import json

import mlflow
from mlflow import MlflowClient
from sklearn.datasets import load_diabetes
from sklearn.linear_model import Ridge

mlflow.set_tracking_uri("http://127.0.0.1:8080")
mlflow.set_experiment("serve-alias-example")

X, y = load_diabetes(return_X_y=True, as_frame=True)
for alpha in (1.0, 0.01): # version 1, then version 2
with mlflow.start_run():
mlflow.sklearn.log_model(
Ridge(alpha=alpha).fit(X, y),
name="model",
registered_model_name="diabetes-progression",
input_example=X.head(3),
)
MlflowClient().set_registered_model_alias("diabetes-progression", "production", "1")

# One patient, in the layout the model server reads
with open("first_patient.json", "w") as f:
json.dump({"dataframe_split": X.head(1).to_dict(orient="split", index=False)}, f)
print("production is version", MlflowClient().get_model_version_by_alias("diabetes-progression", "production").version)
Terminal
uv run python register_diabetes.py
Output (excerpt)
Successfully registered model 'diabetes-progression'.
Created version '1' of model 'diabetes-progression'.
...
Registered model 'diabetes-progression' already exists. Creating a new version of this model...
Created version '2' of model 'diabetes-progression'.
...
production is version 1

Step 2: Serve the Alias​

Terminal 2
export MLFLOW_TRACKING_URI=http://127.0.0.1:8080
uv run mlflow models serve -m "models:/diabetes-progression@production" -p 5001 --env-manager uv
Output (excerpt)
2026/11/26 04:39:30 INFO mlflow.utils.virtualenv: Environment /Users/you/.mlflow/envs/mlflow-1a8495c475783fb241f6a7a3da8ec77fb2802018 already exists
...
INFO: Uvicorn running on http://127.0.0.1:5001 (Press CTRL+C to quit)

MLflow looked up the alias, found version 1, and loaded it. The environment already existed from an earlier model with the same packages, so the server was up in seconds.

Step 3: Ask for a Prediction​

In another terminal, send the patient:

Terminal 3
curl http://127.0.0.1:5001/invocations -H "Content-Type: application/json" --data @first_patient.json
Output
{"predictions": [182.67335420683418]}

182.67 is version 1's prediction for this patient.

Step 4: Move the Alias​

Point production at version 2, as a release would:

move_alias.py
import mlflow
from mlflow import MlflowClient

mlflow.set_tracking_uri("http://127.0.0.1:8080")
client = MlflowClient()
client.set_registered_model_alias("diabetes-progression", "production", "2")
print("production is version", client.get_model_version_by_alias("diabetes-progression", "production").version)
Terminal 3
uv run python move_alias.py
Output
production is version 2

Send the same patient again:

Output
{"predictions": [182.67335420683418]}

The same 182.67: the server still has version 1, because it read the alias when it started.

Step 5: Restart the Server​

Press Ctrl+C in Terminal 2 and start the same command again. Then send the patient once more:

Output
{"predictions": [204.30296696531178]}

Three prediction responses in a terminal: 182.673 before the alias moved, the same 182.673 after it moved, and 204.303 after the server restarted.

204.30 is version 2's prediction: the restarted server looked up production again and loaded version 2. In PowerShell, the three answers were {182.673354206834}, {182.673354206834} and {204.302966965312}.

Common Mistakes​

MistakeWhat happensDo this instead
Moving the alias and expecting the running server to followIt keeps serving the version it loadedRestart the server after a release
--data @first_patient.json in PowerShellParserError: The splatting operator '@' cannot be used to reference variables in an expressionInvoke-RestMethod ... -InFile first_patient.json

Troubleshooting​

SymptomLikely causeFix
RestException: INVALID_PARAMETER_VALUE: Registered model alias prod not found. when the server startsThe alias isn't set, or is spelled differentlySet it: How to Set an Alias on a Model Version in MLflow with Python
The prediction didn't change after a restartThe alias still points at the old versionCheck it with How to Find Which Version an Alias Points To in MLflow

FAQ​

How do I know which version a server loaded?​

The server doesn't print it, so look the alias up when you start the server, or serve a fixed version, such as models:/diabetes-progression/2, when you need to know exactly.

Is an alias better than a version number here?​

The alias lets a release happen in the registry, with no change to the command that starts the server, only a restart.

Conclusion​

mlflow models serve -m "models:/diabetes-progression@production" served version 1 while the alias pointed at it. Moving production to version 2 left the running server's answer at 182.67; after a restart it answered 204.30, version 2's prediction.

Additional Resources​