Connector for Vertex AI

Workflows connector that defines the built-in function used to access Vertex AI within a workflow.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample

YAML

# This workflow demonstrates how to use the aiplatform (Vertex AI) connector.
# This workflow creates a Vertex AI custom Job and then deletes the
# job once the long-running operation of creating the job completes.
# Expected successful output: "SUCCESS"
main:
  steps:
    - init:
        assign:
          - location: ${sys.get_env("GOOGLE_CLOUD_LOCATION")}
          - project: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
          # Follow https://cloud.google.com/vertex-ai/docs/training/create-custom-container to build
          # a custom container image for training.
          - container_image_uri: "IMAGE_URI"
    - create_custom_job:
        call: googleapis.aiplatform.v1.projects.locations.customJobs.create
        args:
          parent: ${"projects/" + project + "/locations/" + location}
          region: ${location}
          body:
            displayName: "example-custom-job"
            jobSpec:
              workerPoolSpecs:
                - machineSpec:
                    machineType: "n1-standard-4"
                    acceleratorType: "NVIDIA_TESLA_V100"
                    acceleratorCount: 1
                  replicaCount: 1
                  containerSpec:
                    imageUri: ${container_image_uri}
                    command: []
                    args: []
        result: customJobsResponse
    - delete_custom_job:
        call: googleapis.aiplatform.v1.projects.locations.customJobs.delete
        args:
          name: ${customJobsResponse.name}
          region: ${location}
        result: deleteCustomJobResponse
    - return:
        return: "SUCCESS"

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.