Class Model (0.7.1) Stay organized with collections Save and categorize content based on your preferences.
- 1.122.0 (latest)
- 1.121.0
- 1.120.0
- 1.119.0
- 1.118.0
- 1.117.0
- 1.116.0
- 1.115.0
- 1.114.0
- 1.113.0
- 1.112.0
- 1.111.0
- 1.110.0
- 1.109.0
- 1.108.0
- 1.107.0
- 1.106.0
- 1.105.0
- 1.104.0
- 1.103.0
- 1.102.0
- 1.101.0
- 1.100.0
- 1.99.0
- 1.98.0
- 1.97.0
- 1.96.0
- 1.95.1
- 1.94.0
- 1.93.1
- 1.92.0
- 1.91.0
- 1.90.0
- 1.89.0
- 1.88.0
- 1.87.0
- 1.86.0
- 1.85.0
- 1.84.0
- 1.83.0
- 1.82.0
- 1.81.0
- 1.80.0
- 1.79.0
- 1.78.0
- 1.77.0
- 1.76.0
- 1.75.0
- 1.74.0
- 1.73.0
- 1.72.0
- 1.71.1
- 1.70.0
- 1.69.0
- 1.68.0
- 1.67.1
- 1.66.0
- 1.65.0
- 1.63.0
- 1.62.0
- 1.60.0
- 1.59.0
- 1.58.0
- 1.57.0
- 1.56.0
- 1.55.0
- 1.54.1
- 1.53.0
- 1.52.0
- 1.51.0
- 1.50.0
- 1.49.0
- 1.48.0
- 1.47.0
- 1.46.0
- 1.45.0
- 1.44.0
- 1.43.0
- 1.39.0
- 1.38.1
- 1.37.0
- 1.36.4
- 1.35.0
- 1.34.0
- 1.33.1
- 1.32.0
- 1.31.1
- 1.30.1
- 1.29.0
- 1.28.1
- 1.27.1
- 1.26.1
- 1.25.0
- 1.24.1
- 1.23.0
- 1.22.1
- 1.21.0
- 1.20.0
- 1.19.1
- 1.18.3
- 1.17.1
- 1.16.1
- 1.15.1
- 1.14.0
- 1.13.1
- 1.12.1
- 1.11.0
- 1.10.0
- 1.9.0
- 1.8.1
- 1.7.1
- 1.6.2
- 1.5.0
- 1.4.3
- 1.3.0
- 1.2.0
- 1.1.1
- 1.0.1
- 0.9.0
- 0.8.0
- 0.7.1
- 0.6.0
- 0.5.1
- 0.4.0
- 0.3.1
Model(model_name:str,project:Optional[str]=None,location:Optional[str]=None,credentials:Optional[google.auth.credentials.Credentials]=None,)Retrieves the model resource and instantiates its representation.
Parameters
| Name | Description |
| model_name | strRequired. A fully-qualified model resource name or model ID. Example: "projects/123/locations/us-central1/models/456" or "456" when project and location are initialized or passed. |
| project | strOptional project to retrieve model from. If not set, project set in aiplatform.init will be used. |
| location | strOptional location to retrieve model from. If not set, location set in aiplatform.init will be used. |
Inheritance
builtins.object >google.cloud.aiplatform.base.AiPlatformResourceNoun >builtins.object >google.cloud.aiplatform.base.FutureManager >google.cloud.aiplatform.base.AiPlatformResourceNounWithFutureManager >ModelProperties
description
Description of the model.
uri
Uri of the model.
Methods
batch_predict
batch_predict(job_display_name:str,gcs_source:Optional[Union[str,Sequence[str]]]=None,bigquery_source:Optional[str]=None,instances_format:str="jsonl",gcs_destination_prefix:Optional[str]=None,bigquery_destination_prefix:Optional[str]=None,predictions_format:str="jsonl",model_parameters:Optional[Dict]=None,machine_type:Optional[str]=None,accelerator_type:Optional[str]=None,accelerator_count:Optional[int]=None,starting_replica_count:Optional[int]=None,max_replica_count:Optional[int]=None,generate_explanation:Optional[bool]=False,explanation_metadata:Optional[google.cloud.aiplatform_v1beta1.types.explanation_metadata.ExplanationMetadata]=None,explanation_parameters:Optional[google.cloud.aiplatform_v1beta1.types.explanation.ExplanationParameters]=None,labels:Optional[dict]=None,credentials:Optional[google.auth.credentials.Credentials]=None,encryption_spec_key_name:Optional[str]=None,sync:bool=True,)Creates a batch prediction job using this Model and outputs predictionresults to the provided destination prefix in the specifiedpredictions_format. One source and one destination prefix are required.
Example usage:
my_model.batch_predict( job_display_name="prediction-123", gcs_source="gs://example-bucket/instances.csv", instances_format="csv", bigquery_destination_prefix="projectId.bqDatasetId.bqTableId")
| Name | Description |
| job_display_name | strRequired. The user-defined name of the BatchPredictionJob. The name can be up to 128 characters long and can be consist of any UTF-8 characters. |
| generate_explanation | boolOptional. Generate explanation along with the batch prediction results. This will cause the batch prediction output to include explanations based on the |
| explanation_metadata | explain.ExplanationMetadataOptional. Explanation metadata configuration for this BatchPredictionJob. Can be specified only if |
| explanation_parameters | explain.ExplanationParametersOptional. Parameters to configure explaining for Model's predictions. Can be specified only if |
| encryption_spec_key_name | Optional[str]Optional. The Cloud KMS resource identifier of the customer managed encryption key used to protect the model. Has the form: |
| Type | Description |
| (jobs.BatchPredictionJob) | Instantiated representation of the created batch prediction job. |
deploy
deploy(endpoint:Optional[google.cloud.aiplatform.models.Endpoint]=None,deployed_model_display_name:Optional[str]=None,traffic_percentage:Optional[int]=0,traffic_split:Optional[Dict[str,int]]=None,machine_type:Optional[str]=None,min_replica_count:Optional[int]=1,max_replica_count:Optional[int]=1,accelerator_type:Optional[str]=None,accelerator_count:Optional[int]=None,explanation_metadata:Optional[google.cloud.aiplatform_v1beta1.types.explanation_metadata.ExplanationMetadata]=None,explanation_parameters:Optional[google.cloud.aiplatform_v1beta1.types.explanation.ExplanationParameters]=None,metadata:Optional[Sequence[Tuple[str,str]]]=(),encryption_spec_key_name:Optional[str]=None,sync=True,)Deploys model to endpoint. Endpoint will be created if unspecified.
| Name | Description |
| endpoint | "Endpoint"Optional. Endpoint to deploy model to. If not specified, endpoint display name will be model display name+'_endpoint'. |
| deployed_model_display_name | strOptional. The display name of the DeployedModel. If not provided upon creation, the Model's display_name is used. |
| traffic_percentage | intOptional. Desired traffic to newly deployed model. Defaults to 0 if there are pre-existing deployed models. Defaults to 100 if there are no pre-existing deployed models. Negative values should not be provided. Traffic of previously deployed models at the endpoint will be scaled down to accommodate new deployed model's traffic. Should not be provided if traffic_split is provided. |
| traffic_split | Dict[str, int]Optional. A map from a DeployedModel's ID to the percentage of this Endpoint's traffic that should be forwarded to that DeployedModel. If a DeployedModel's ID is not listed in this map, then it receives no traffic. The traffic percentage values must add up to 100, or map must be empty if the Endpoint is to not accept any traffic at the moment. Key for model being deployed is "0". Should not be provided if traffic_percentage is provided. |
| machine_type | strOptional. The type of machine. Not specifying machine type will result in model to be deployed with automatic resources. |
| min_replica_count | intOptional. The minimum number of machine replicas this deployed model will be always deployed on. If traffic against it increases, it may dynamically be deployed onto more replicas, and as traffic decreases, some of these extra replicas may be freed. |
| max_replica_count | intOptional. The maximum number of replicas this deployed model may be deployed on when the traffic against it increases. If requested value is too large, the deployment will error, but if deployment succeeds then the ability to scale the model to that many replicas is guaranteed (barring service outages). If traffic against the deployed model increases beyond what its replicas at maximum may handle, a portion of the traffic will be dropped. If this value is not provided, the smaller value of min_replica_count or 1 will be used. |
| accelerator_type | strOptional. Hardware accelerator type. Must also set accelerator_count if used. One of ACCELERATOR_TYPE_UNSPECIFIED, NVIDIA_TESLA_K80, NVIDIA_TESLA_P100, NVIDIA_TESLA_V100, NVIDIA_TESLA_P4, NVIDIA_TESLA_T4, TPU_V2, TPU_V3 |
| accelerator_count | intOptional. The number of accelerators to attach to a worker replica. |
| explanation_metadata | explain.ExplanationMetadataOptional. Metadata describing the Model's input and output for explanation. Both |
| explanation_parameters | explain.ExplanationParametersOptional. Parameters to configure explaining for Model's predictions. For more details, see |
| metadata | Sequence[Tuple[str, str]]Optional. Strings which should be sent along with the request as metadata. |
| encryption_spec_key_name | Optional[str]Optional. The Cloud KMS resource identifier of the customer managed encryption key used to protect the model. Has the form: |
| sync | boolWhether to execute this method synchronously. If False, this method will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed. |
| Type | Description |
| endpoint ("Endpoint") | Endpoint with the deployed model. |
list
list(filter:Optional[str]=None,order_by:Optional[str]=None,project:Optional[str]=None,location:Optional[str]=None,credentials:Optional[google.auth.credentials.Credentials]=None,)List all Model resource instances.
Example Usage:
aiplatform.Model.list( filter='labels.my_label="my_label_value" AND display_name="my_model"',)
| Name | Description |
| filter | strOptional. An expression for filtering the results of the request. For field names both snake_case and camelCase are supported. |
| order_by | strOptional. A comma-separated list of fields to order by, sorted in ascending order. Use "desc" after a field name for descending. Supported fields: |
| project | strOptional. Project to retrieve list from. If not set, project set in aiplatform.init will be used. |
| location | strOptional. Location to retrieve list from. If not set, location set in aiplatform.init will be used. |
| credentials | auth_credentials.CredentialsOptional. Custom credentials to use to retrieve list. Overrides credentials set in aiplatform.init. |
upload
upload(display_name:str,serving_container_image_uri:str,*,artifact_uri:Optional[str]=None,serving_container_predict_route:Optional[str]=None,serving_container_health_route:Optional[str]=None,description:Optional[str]=None,serving_container_command:Optional[Sequence[str]]=None,serving_container_args:Optional[Sequence[str]]=None,serving_container_environment_variables:Optional[Dict[str,str]]=None,serving_container_ports:Optional[Sequence[int]]=None,instance_schema_uri:Optional[str]=None,parameters_schema_uri:Optional[str]=None,prediction_schema_uri:Optional[str]=None,explanation_metadata:Optional[google.cloud.aiplatform_v1beta1.types.explanation_metadata.ExplanationMetadata]=None,explanation_parameters:Optional[google.cloud.aiplatform_v1beta1.types.explanation.ExplanationParameters]=None,project:Optional[str]=None,location:Optional[str]=None,credentials:Optional[google.auth.credentials.Credentials]=None,encryption_spec_key_name:Optional[str]=None,sync=True)Uploads a model and returns a Model representing the uploaded Model resource.
Example usage:
my_model = Model.upload( display_name='my-model', artifact_uri='gs://my-model/saved-model' serving_container_image_uri='tensorflow/serving')
| Name | Description |
| display_name | strRequired. The display name of the Model. The name can be up to 128 characters long and can be consist of any UTF-8 characters. |
| serving_container_image_uri | strRequired. The URI of the Model serving container. |
| artifact_uri | strOptional. The path to the directory containing the Model artifact and any of its supporting files. Leave blank for custom container prediction. Not present for AutoML Models. |
| serving_container_predict_route | strOptional. An HTTP path to send prediction requests to the container, and which must be supported by it. If not specified a default HTTP path will be used by AI Platform. |
| serving_container_health_route | strOptional. An HTTP path to send health check requests to the container, and which must be supported by it. If not specified a standard HTTP path will be used by AI Platform. |
| description | strThe description of the model. |
| instance_schema_uri | strOptional. Points to a YAML file stored on Google Cloud Storage describing the format of a single instance, which are used in |
| parameters_schema_uri | strOptional. Points to a YAML file stored on Google Cloud Storage describing the parameters of prediction and explanation via |
| prediction_schema_uri | strOptional. Points to a YAML file stored on Google Cloud Storage describing the format of a single prediction produced by this Model, which are returned via |
| explanation_metadata | explain.ExplanationMetadataOptional. Metadata describing the Model's input and output for explanation. Both |
| explanation_parameters | explain.ExplanationParametersOptional. Parameters to configure explaining for Model's predictions. For more details, see |
| encryption_spec_key_name | Optional[str]Optional. The Cloud KMS resource identifier of the customer managed encryption key used to protect the model. Has the form: |
| Type | Description |
| ValueErro | if only `explanation_metadata` or `explanation_parameters`: is specified. |
| Type | Description |
| model | Instantiated representation of the uploaded model resource. |
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 2025-10-30 UTC.