Log models to an experiment run Stay organized with collections Save and categorize content based on your preferences.
In order for a model to be tracked, shared, and analyzed, theVertex AI SDK for Python provides an API that serializes a machine learning modelinto anExperimentModel class and logs the model to Vertex AI Experiments.
After selecting the best model to use, you can register that model fromVertex AI Experiments to Vertex AI Model Registry.
Supported frameworks are scikit-learn, XGBoost, and TensorFlow.
Save and log ML model
Save models
The Vertex AI SDK provides thesave_model method to serialize an ML model, upload the model to Cloud Storage, and represent the model as a Vertex ML Metadata artifact.
Python
fromtypingimportOptional,Unionfromgoogle.cloudimportaiplatformdefsave_model_sample(project:str,location:str,model:Union["sklearn.base.BaseEstimator","xgb.Booster","tf.Module"# noqa: F821],artifact_id:Optional[str]=None,uri:Optional[str]=None,input_example:Optional[Union[list,dict,"pd.DataFrame","np.ndarray"]# noqa: F821]=None,display_name:Optional[str]=None,staging_bucket:Optional[str]=None,)->None:aiplatform.init(project=project,location=location)aiplatform.save_model(model=model,artifact_id=artifact_id,uri=uri,input_example=input_example,display_name=display_name,staging_bucket=staging_bucket,)project: . You can find these IDs in the Google Cloud consolewelcome page.location: SeeList of available locationsmodel: (Required). A machine learning model.(Union["sklearn.base.BaseEstimator", "xgb.Booster", "tf.Module"])artifact_id: Optional. The resource ID of the artifact. This ID must be globally unique in a metadataStore. It might be up to 63 characters, and valid characters are[a-z0-9_-]. The first character can't be a number or a hyphen.uri: Optional. A gcs directory in which to save the model file. If a uri isn't provided,gs://default-bucket/timestamp-uuid-frameworkName-modelis used. If a default staging bucket isn't set, it must be passed in thestaging_bucketparameter.input_example: Optional. Each model takes input data and then produces a prediction. Each model accepts one particular format of input (for example, a number, a string, 2d array) and is stored as a yaml file in the gcs uri. Accepts list, dict, pd.DataFrame, and np.ndarray The value inside a list must be a scalar or list. The value inside a dict must be a scalar, list, or np.ndarray.(Union[list, dict, pd.DataFrame, np.ndarray]).display_name: The display name of the artifact.staging_bucket: Optional. The staging bucket used to save the model. If not provided, the staging bucket set inaiplatform.initis used. A staging bucket or uri is required for saving a model.
Log models
The Vertex AI SDK provides alog_model method, which orchestratessave_model and an additional step to log the Vertex ML Metadata artifact to the current experiment run. Thelog_model method to manage and analyze multiple ML models in Vertex AI Experiments.
Python
fromtypingimportOptional,Unionfromgoogle.cloudimportaiplatformdeflog_model_sample(experiment_name:str,run_name:str,project:str,location:str,model:Union["sklearn.base.BaseEstimator","xgb.Booster","tf.Module"# noqa: F821],artifact_id:Optional[str]=None,uri:Optional[str]=None,input_example:Optional[Union[list,dict,"pd.DataFrame","np.ndarray"]# noqa: F821]=None,# noqa: F821display_name:Optional[str]=None,)->None:aiplatform.init(experiment=experiment_name,project=project,location=location)aiplatform.start_run(run=run_name,resume=True)aiplatform.log_model(model=model,artifact_id=artifact_id,uri=uri,input_example=input_example,display_name=display_name,)experiment_name: Provide the name of your experiment. You can find your list of experiments in the Google Cloud console by selecting "Experiments" in the section nav.run_name: Specify a run name.project: . You can find these IDs in the Google Cloud consolewelcome page.location: SeeList of available locations.model: Required. A machine learning model.(Union["sklearn.base.BaseEstimator", "xgb.Booster", "tf.Module"])uri: Optional. A gcs directory in which to save the model file. If a uri is not provided,gs://default-bucket/timestamp-uuid-frameworkName-modelis used. If a default staging bucket is not set, a new bucket is created.input_example: Optional. Each model takes input data and then produces a prediction. Each model accepts one particular format of input (for example, a number, a string, 2d array) and is stored as a yaml file in the gcs uri. Accepts list, dict, pd.DataFrame, and np.ndarray The value inside a list must be a scalar or list. The value inside a dict must be a scalar, list, or np.ndarray.(Union[list, dict, pd.DataFrame, np.ndarray]).display_name: Optional. The display name of the artifact.
TrackExperimentModel
Get experiment model
To useget_experiment_model to return a saved model, pass it the saved model's artifact ID.
Python
fromgoogle.cloudimportaiplatformdefget_experiment_model_sample(project:str,location:str,artifact_id:str,)->"ExperimentModel":# noqa: F821aiplatform.init(project=project,location=location)experiment_model=aiplatform.get_experiment_model(artifact_id=artifact_id)returnexperiment_modelproject: . You can find these IDs in the Google Cloud consolewelcome page.location: SeeList of available locations.artifact_id: Required: The resource ID of the existing model.
Get experiment models
Theget_experiment_models method gets a list of all theExperimentModel's that are logged to a particular experiment run.
Python
fromtypingimportList,Unionfromgoogle.cloudimportaiplatformdefget_experiment_run_models_sample(run_name:str,experiment:Union[str,aiplatform.Experiment],project:str,location:str,)->List["ExperimentModel"]:# noqa: F821experiment_run=aiplatform.ExperimentRun(run_name=run_name,experiment=experiment,project=project,location=location)returnexperiment_run.get_experiment_models()run_name: Specify a run name.experiment: Provide the name of your experiment. You can find your list of experiments in the Google Cloud console by selecting "Experiments" in the section nav.project: . You can find these IDs in the Google Cloud consolewelcome page.location: SeeList of available locations.
Get model information
Theget_model_info method returns the model's metadata of a givenExperimentModel instance, for example, model class, framework type.
Python
fromtypingimportAny,Dictfromgoogle.cloudimportaiplatformdefget_model_info_sample(artifact_id:str,project:str,location:str,)->Dict[str,Any]:experiment_model=aiplatform.get_experiment_model(artifact_id=artifact_id,project=project,location=location)returnexperiment_model.get_model_info()artifact_id: Required The resource ID of the existingExperimentModel.project: . You can find these IDs in the Google Cloud consolewelcome page.location: SeeList of available locations.
LoadExperimentModel
Load model
Theload_experiment_model method helps you deserialize anExperimentModel instance back to the original ML model.
Python
fromtypingimportUnionfromgoogle.cloudimportaiplatformdefload_experiment_model_sample(artifact_id:str,project:str,location:str,)->Union["sklearn.base.BaseEstimator","xgb.Booster","tf.Module"]:# noqa: F821:experiment_model=aiplatform.get_experiment_model(artifact_id=artifact_id,project=project,location=location)returnexperiment_model.load_model()artifact_id: (Required). The resource ID of the existingExperimentModel. Example:artifact_id="my-sklearn-model"project: . You can find these IDs in the Google Cloud consolewelcome page.location: SeeList of available locations.
RegisterExperimentModel
Register saved model
Theregister_experiment_model API enables registering the model that was deemed the best, in Vertex AI Model Registry with a minimum amount of configuration. The API automatically chooses aprebuilt prediction container based on the model's framework and version.
Python
fromgoogle.cloudimportaiplatformdefregister_experiment_model_sample(artifact_id:str,project:str,location:str,display_name:str,)->aiplatform.models.Model:experiment_model=aiplatform.get_experiment_model(artifact_id=artifact_id,project=project,location=location)returnexperiment_model.register_model(display_name=display_name)artifact_id: (Required). The resource ID of the existingExperimentModel.project: . You can find these IDs in the Google Cloud consolewelcome page.location: SeeList of available locations.display_name: Optional. The user-defined name of the registered model.
View experiment runs list in the Google Cloud console
- In the Google Cloud console, go to theExperiments page.
Go to Experiments
A list of experiments appears. - Select the experiment that you want to check.
A list of runs appears.

What's next
Relevant notebook sample
Blog post
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-19 UTC.