Vertex AI API . projects . locations . publishers . models

Instance Methods

close()

Close httplib2 connections.

countTokens(endpoint, body=None, x__xgafv=None)

Perform a token counting.

predict(endpoint, body=None, x__xgafv=None)

Perform an online prediction.

rawPredict(endpoint, body=None, x__xgafv=None)

Perform an online prediction with an arbitrary HTTP payload. The response includes the following HTTP headers: * `X-Vertex-AI-Endpoint-Id`: ID of the Endpoint that served this prediction. * `X-Vertex-AI-Deployed-Model-Id`: ID of the Endpoint's DeployedModel that served this prediction.

serverStreamingPredict(endpoint, body=None, x__xgafv=None)

Perform a server-side streaming online prediction request for Vertex LLM streaming.

Method Details

close()
Close httplib2 connections.
countTokens(endpoint, body=None, x__xgafv=None)
Perform a token counting.

Args:
  endpoint: string, Required. The name of the Endpoint requested to perform token counting. Format: `projects/{project}/locations/{location}/endpoints/{endpoint}` (required)
  body: object, The request body.
    The object takes the form of:

{ # Request message for PredictionService.CountTokens.
  "instances": [ # Required. The instances that are the input to token counting call. Schema is identical to the prediction schema of the underlying model.
    "",
  ],
}

  x__xgafv: string, V1 error format.
    Allowed values
      1 - v1 error format
      2 - v2 error format

Returns:
  An object of the form:

    { # Response message for PredictionService.CountTokens.
  "totalBillableCharacters": 42, # The total number of billable characters counted across all instances from the request.
  "totalTokens": 42, # The total number of tokens counted across all instances from the request.
}
predict(endpoint, body=None, x__xgafv=None)
Perform an online prediction.

Args:
  endpoint: string, Required. The name of the Endpoint requested to serve the prediction. Format: `projects/{project}/locations/{location}/endpoints/{endpoint}` (required)
  body: object, The request body.
    The object takes the form of:

{ # Request message for PredictionService.Predict.
  "instances": [ # Required. The instances that are the input to the prediction call. A DeployedModel may have an upper limit on the number of instances it supports per request, and when it is exceeded the prediction call errors in case of AutoML Models, or, in case of customer created Models, the behaviour is as documented by that Model. The schema of any single instance may be specified via Endpoint's DeployedModels' Model's PredictSchemata's instance_schema_uri.
    "",
  ],
  "parameters": "", # The parameters that govern the prediction. The schema of the parameters may be specified via Endpoint's DeployedModels' Model's PredictSchemata's parameters_schema_uri.
}

  x__xgafv: string, V1 error format.
    Allowed values
      1 - v1 error format
      2 - v2 error format

Returns:
  An object of the form:

    { # Response message for PredictionService.Predict.
  "deployedModelId": "A String", # ID of the Endpoint's DeployedModel that served this prediction.
  "metadata": "", # Output only. Request-level metadata returned by the model. The metadata type will be dependent upon the model implementation.
  "model": "A String", # Output only. The resource name of the Model which is deployed as the DeployedModel that this prediction hits.
  "modelDisplayName": "A String", # Output only. The display name of the Model which is deployed as the DeployedModel that this prediction hits.
  "modelVersionId": "A String", # Output only. The version ID of the Model which is deployed as the DeployedModel that this prediction hits.
  "predictions": [ # The predictions that are the output of the predictions call. The schema of any single prediction may be specified via Endpoint's DeployedModels' Model's PredictSchemata's prediction_schema_uri.
    "",
  ],
}
rawPredict(endpoint, body=None, x__xgafv=None)
Perform an online prediction with an arbitrary HTTP payload. The response includes the following HTTP headers: * `X-Vertex-AI-Endpoint-Id`: ID of the Endpoint that served this prediction. * `X-Vertex-AI-Deployed-Model-Id`: ID of the Endpoint's DeployedModel that served this prediction.

Args:
  endpoint: string, Required. The name of the Endpoint requested to serve the prediction. Format: `projects/{project}/locations/{location}/endpoints/{endpoint}` (required)
  body: object, The request body.
    The object takes the form of:

{ # Request message for PredictionService.RawPredict.
  "httpBody": { # Message that represents an arbitrary HTTP body. It should only be used for payload formats that can't be represented as JSON, such as raw binary or an HTML page. This message can be used both in streaming and non-streaming API methods in the request as well as the response. It can be used as a top-level request field, which is convenient if one wants to extract parameters from either the URL or HTTP template into the request fields and also want access to the raw HTTP body. Example: message GetResourceRequest { // A unique request id. string request_id = 1; // The raw HTTP body is bound to this field. google.api.HttpBody http_body = 2; } service ResourceService { rpc GetResource(GetResourceRequest) returns (google.api.HttpBody); rpc UpdateResource(google.api.HttpBody) returns (google.protobuf.Empty); } Example with streaming methods: service CaldavService { rpc GetCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); rpc UpdateCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); } Use of this type only changes how the request and response bodies are handled, all other features will continue to work unchanged. # The prediction input. Supports HTTP headers and arbitrary data payload. A DeployedModel may have an upper limit on the number of instances it supports per request. When this limit it is exceeded for an AutoML model, the RawPredict method returns an error. When this limit is exceeded for a custom-trained model, the behavior varies depending on the model. You can specify the schema for each instance in the predict_schemata.instance_schema_uri field when you create a Model. This schema applies when you deploy the `Model` as a `DeployedModel` to an Endpoint and use the `RawPredict` method.
    "contentType": "A String", # The HTTP Content-Type header value specifying the content type of the body.
    "data": "A String", # The HTTP request/response body as raw binary.
    "extensions": [ # Application specific response metadata. Must be set in the first response for streaming APIs.
      {
        "a_key": "", # Properties of the object. Contains field @type with type URL.
      },
    ],
  },
}

  x__xgafv: string, V1 error format.
    Allowed values
      1 - v1 error format
      2 - v2 error format

Returns:
  An object of the form:

    { # Message that represents an arbitrary HTTP body. It should only be used for payload formats that can't be represented as JSON, such as raw binary or an HTML page. This message can be used both in streaming and non-streaming API methods in the request as well as the response. It can be used as a top-level request field, which is convenient if one wants to extract parameters from either the URL or HTTP template into the request fields and also want access to the raw HTTP body. Example: message GetResourceRequest { // A unique request id. string request_id = 1; // The raw HTTP body is bound to this field. google.api.HttpBody http_body = 2; } service ResourceService { rpc GetResource(GetResourceRequest) returns (google.api.HttpBody); rpc UpdateResource(google.api.HttpBody) returns (google.protobuf.Empty); } Example with streaming methods: service CaldavService { rpc GetCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); rpc UpdateCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); } Use of this type only changes how the request and response bodies are handled, all other features will continue to work unchanged.
  "contentType": "A String", # The HTTP Content-Type header value specifying the content type of the body.
  "data": "A String", # The HTTP request/response body as raw binary.
  "extensions": [ # Application specific response metadata. Must be set in the first response for streaming APIs.
    {
      "a_key": "", # Properties of the object. Contains field @type with type URL.
    },
  ],
}
serverStreamingPredict(endpoint, body=None, x__xgafv=None)
Perform a server-side streaming online prediction request for Vertex LLM streaming.

Args:
  endpoint: string, Required. The name of the Endpoint requested to serve the prediction. Format: `projects/{project}/locations/{location}/endpoints/{endpoint}` (required)
  body: object, The request body.
    The object takes the form of:

{ # Request message for PredictionService.StreamingPredict. The first message must contain endpoint field and optionally input. The subsequent messages must contain input.
  "inputs": [ # The prediction input.
    { # A tensor value type.
      "boolVal": [ # Type specific representations that make it easy to create tensor protos in all languages. Only the representation corresponding to "dtype" can be set. The values hold the flattened representation of the tensor in row major order. BOOL
        True or False,
      ],
      "bytesVal": [ # STRING
        "A String",
      ],
      "doubleVal": [ # DOUBLE
        3.14,
      ],
      "dtype": "A String", # The data type of tensor.
      "floatVal": [ # FLOAT
        3.14,
      ],
      "int64Val": [ # INT64
        "A String",
      ],
      "intVal": [ # INT_8 INT_16 INT_32
        42,
      ],
      "listVal": [ # A list of tensor values.
        # Object with schema name: GoogleCloudAiplatformV1beta1Tensor
      ],
      "shape": [ # Shape of the tensor.
        "A String",
      ],
      "stringVal": [ # STRING
        "A String",
      ],
      "structVal": { # A map of string to tensor.
        "a_key": # Object with schema name: GoogleCloudAiplatformV1beta1Tensor
      },
      "tensorVal": "A String", # Serialized raw tensor content.
      "uint64Val": [ # UINT64
        "A String",
      ],
      "uintVal": [ # UINT8 UINT16 UINT32
        42,
      ],
    },
  ],
  "parameters": { # A tensor value type. # The parameters that govern the prediction.
    "boolVal": [ # Type specific representations that make it easy to create tensor protos in all languages. Only the representation corresponding to "dtype" can be set. The values hold the flattened representation of the tensor in row major order. BOOL
      True or False,
    ],
    "bytesVal": [ # STRING
      "A String",
    ],
    "doubleVal": [ # DOUBLE
      3.14,
    ],
    "dtype": "A String", # The data type of tensor.
    "floatVal": [ # FLOAT
      3.14,
    ],
    "int64Val": [ # INT64
      "A String",
    ],
    "intVal": [ # INT_8 INT_16 INT_32
      42,
    ],
    "listVal": [ # A list of tensor values.
      # Object with schema name: GoogleCloudAiplatformV1beta1Tensor
    ],
    "shape": [ # Shape of the tensor.
      "A String",
    ],
    "stringVal": [ # STRING
      "A String",
    ],
    "structVal": { # A map of string to tensor.
      "a_key": # Object with schema name: GoogleCloudAiplatformV1beta1Tensor
    },
    "tensorVal": "A String", # Serialized raw tensor content.
    "uint64Val": [ # UINT64
      "A String",
    ],
    "uintVal": [ # UINT8 UINT16 UINT32
      42,
    ],
  },
}

  x__xgafv: string, V1 error format.
    Allowed values
      1 - v1 error format
      2 - v2 error format

Returns:
  An object of the form:

    { # Response message for PredictionService.StreamingPredict.
  "outputs": [ # The prediction output.
    { # A tensor value type.
      "boolVal": [ # Type specific representations that make it easy to create tensor protos in all languages. Only the representation corresponding to "dtype" can be set. The values hold the flattened representation of the tensor in row major order. BOOL
        True or False,
      ],
      "bytesVal": [ # STRING
        "A String",
      ],
      "doubleVal": [ # DOUBLE
        3.14,
      ],
      "dtype": "A String", # The data type of tensor.
      "floatVal": [ # FLOAT
        3.14,
      ],
      "int64Val": [ # INT64
        "A String",
      ],
      "intVal": [ # INT_8 INT_16 INT_32
        42,
      ],
      "listVal": [ # A list of tensor values.
        # Object with schema name: GoogleCloudAiplatformV1beta1Tensor
      ],
      "shape": [ # Shape of the tensor.
        "A String",
      ],
      "stringVal": [ # STRING
        "A String",
      ],
      "structVal": { # A map of string to tensor.
        "a_key": # Object with schema name: GoogleCloudAiplatformV1beta1Tensor
      },
      "tensorVal": "A String", # Serialized raw tensor content.
      "uint64Val": [ # UINT64
        "A String",
      ],
      "uintVal": [ # UINT8 UINT16 UINT32
        42,
      ],
    },
  ],
  "parameters": { # A tensor value type. # The parameters that govern the prediction.
    "boolVal": [ # Type specific representations that make it easy to create tensor protos in all languages. Only the representation corresponding to "dtype" can be set. The values hold the flattened representation of the tensor in row major order. BOOL
      True or False,
    ],
    "bytesVal": [ # STRING
      "A String",
    ],
    "doubleVal": [ # DOUBLE
      3.14,
    ],
    "dtype": "A String", # The data type of tensor.
    "floatVal": [ # FLOAT
      3.14,
    ],
    "int64Val": [ # INT64
      "A String",
    ],
    "intVal": [ # INT_8 INT_16 INT_32
      42,
    ],
    "listVal": [ # A list of tensor values.
      # Object with schema name: GoogleCloudAiplatformV1beta1Tensor
    ],
    "shape": [ # Shape of the tensor.
      "A String",
    ],
    "stringVal": [ # STRING
      "A String",
    ],
    "structVal": { # A map of string to tensor.
      "a_key": # Object with schema name: GoogleCloudAiplatformV1beta1Tensor
    },
    "tensorVal": "A String", # Serialized raw tensor content.
    "uint64Val": [ # UINT64
      "A String",
    ],
    "uintVal": [ # UINT8 UINT16 UINT32
      42,
    ],
  },
}