Register models

Register a model version from a run and retrieve its files through Studio or the BSQAI API.

Agentic Friendly

The MLflow Model Registry is a central store for versioned models. Register models under Models > Model repository in Studio, with Model Installer, or through the BSQAI API from a dev environment. A model you register is yours and private until you share it. Registering a version from a run needs write on the model and read on the run's experiment. See MLflow permissions.

The MLflow SDK's registry functions (mlflow.register_model(), mlflow.<flavor>.log_model(), models:/ URIs) do not work from a dev environment: MLflow is reachable only through the BSQAI API. Use the bsqai_mlflow client or plain HTTP requests instead.

Register a version with the bsqai_mlflow client

With the client set up as in Track experiments, register the folder a run logged as a version, and give it an alias:

client.create_registered_model("my-classifier")
version = client.create_model_version("my-classifier", run.run_id, artifact_path="model")
client.set_registered_model_alias("my-classifier", "champion", version.version)

To load it in a later session, download its files and load them with the MLflow flavor locally:

import mlflow

champion = client.get_model_version_by_alias("my-classifier", "champion")
model = mlflow.pyfunc.load_model(client.download_artifacts(champion.run_id, "model"))

Register a version from a run through the BSQAI API

Log the model's files to a run under one folder, then register that folder as a version. This continues the example in Track experiments, with the same api, headers and run_id:

for name in ("MLmodel", "model.pkl", "requirements.txt"):
    with open(f"model/{name}", "rb") as file:
        requests.put(
            f"{api}/v1/mlflow/runs/{run_id}/artifacts/content",
            params={"path": f"model/{name}"},
            data=file,
            headers=headers,
        ).raise_for_status()

requests.post(f"{api}/v1/mlflow/models", json={"name": "my-classifier"}, headers=headers)
version = requests.post(
    f"{api}/v1/mlflow/models/my-classifier/versions",
    json={"run_id": run_id, "artifact_path": "model"},
    headers=headers,
)
version.raise_for_status()

Creating the model answers 409 when it already exists and changes nothing, so the script can run again for the next version. The registry numbers versions in order.

Register a model logged with MLflow 3

MLflow 3 keeps a model logged with log_model(), for example from a pipeline, as a logged model with an ID such as m-1a2b…, outside the run's artifact folder. Register it by that ID instead of artifact_path:

version = requests.post(
    f"{api}/v1/mlflow/models/my-classifier/versions",
    json={"run_id": run_id, "model_id": "m-1a2b3c4d5e6f"},
    headers=headers,
)
version.raise_for_status()

GET /v1/mlflow/logged-models?experiment_ids=<id> lists an experiment's logged models with their model_id and the source_run_id that logged them. The logged model must belong to run_id, and you need read access to its experiment: otherwise the request answers 404 and nothing is registered. Give model_id or artifact_path, not both. The version's source is models:/<model_id>, and Model Installer deploys it from the logged model's files like any other version.

Retrieve a version's files

List a version's files with GET /v1/mlflow/models/<name>/versions/<version>/artifacts, and download one with GET /v1/mlflow/models/<name>/versions/<version>/artifacts/content?path=<file>. Paths are relative to the run the version came from, for example model/MLmodel. For a version registered from a model logged with MLflow 3, they are relative to the logged model instead, for example MLmodel. To download all of a version's files in one archive, use GET /v1/mlflow/models/<name>/versions/<version>/artifacts/archive. The model page in Studio shows the same files under Files and versions.

Share a model through the BSQAI API

A model you register is private until you share it, in the Portal or through the BSQAI API. GET /v1/mlflow/models/<name>/grants lists the grants, POST /v1/mlflow/models/<name>/grants grants access, POST /v1/mlflow/models/<name>/grants/revoke removes it, and PUT /v1/mlflow/models/<name>/owner hands the model to another owner. The same routes exist for experiments (/v1/mlflow/experiments/<id>/...) and prompts (/v1/mlflow/prompts/<name>/...). They need the resource-grant or owner-transfer permissions as well as ownership of the resource or the Grant Manager role on it; see MLflow permissions.

Maintain the registry in the Portal

Use registry management in Studio to create an empty registry entry, update model metadata and permitted tags, manage version aliases, or delete an undeployed entry. An empty entry has no weights or version to serve. Registry deletion is not the same as removing downloaded weights through Model Installer.

Deploy from the registry

Open the registered model in Studio > Models > Model repository. For predictive serving, select the model version and a runtime compatible with its MLflow flavor; bsqai-mlserver-mlflow3 serves models logged with the platform's MLflow 3. A model exported to ONNX and logged with mlflow.onnx.log_model can also run on NVIDIA Triton, on CPU (bsqai-triton) or one GPU (bsqai-triton-gpu). Registration alone does not deploy it. A deployed model is called through its serving endpoint. Follow Deploy a predictive model for the deployment boundary and checks.

A model deploys from the registry of the active organization. In a customer organization, it is deployed from the organization's private registry into the organization's own namespace, and needs inference.model.deploy; see Models of a customer organization.

Next steps

On this page