Access Gemini models from a workflow using Vertex AI

Generative AI on Vertex AI (also known asgenAI orgen AI) gives you access toGoogle's generative AI models for multiple modalities (text, code, images,speech). You can test and tune these large language models (LLM), and thendeploy them for use in your AI-powered applications. For more information, seetheOverview of Generative AI on Vertex AI.

Vertex AI has a variety of generative AI foundation models thatare accessible through an API, including the models used in this guide. For moreinformation about how to choose a model, seeGoogle models.

Each model is exposed through a publisher endpoint that's specific to yourGoogle Cloud project so there's no need to deploy the foundation model unless youneed to tune it for a specific use case. You can send a prompt to the publisherendpoint. A prompt is a natural language request sent to an LLM to elicit aresponse back.

This tutorial demonstrates workflows that generate responses fromVertex AI models by sending text prompts to the publisherendpoints using either a Workflows connector or an HTTPPOSTrequest. For more information, see theVertex AI API connector overviewandMake an HTTP request.

Note that you can deploy and run each workflow independently of each other.

Objectives

In this tutorial, you will do the following:

  1. Enable the Vertex AI and Workflows APIs, andgrant the Vertex AI User (roles/aiplatform.user) role to your serviceaccount. This role allows access to most Vertex AIcapabilities. For more information about setting up Vertex AI,seeSet up a project and a development environment.
  2. Deploy and run a workflow that prompts a Vertex AI model todescribe an image that is publicly available through Cloud Storage. Formore information, seeMake data public.
  3. Deploy and run a workflow that loops through a list of countries in paralleland prompts a Vertex AI model to generate and return thehistories of the countries. Using parallel branches allows you to reduce thetotal execution time by starting the calls to the LLM at the same time andwaiting for all of them to complete before combining the results. For moreinformation, seeExecute workflow steps in parallel.
  4. Deploy a workflow that can summarize a large document. Because there is alimit to the context window which sets how far back the model looks duringtraining (and for forecasts), the workflow divides the document into smallerparts, and then prompts a Vertex AI model to summarize eachpart in parallel. For more information, seeOverview of prompting strategies andForecast horizon, context window, and forecast window.

Costs

In this document, you use the following billable components of Google Cloud:

To generate a cost estimate based on your projected usage, use thepricing calculator.

New Google Cloud users might be eligible for afree trial.

When you finish the tasks that are described in this document, you can avoid continued billing by deleting the resources that you created. For more information, seeClean up.

Before you begin

Before trying out the examples in this tutorial, ensure that you have completedthe following.

Console

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.create permission.Learn how to grant roles.
    Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Vertex AI and Workflows APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enable permission.Learn how to grant roles.

    Enable the APIs

  5. Create a service account:

    1. Ensure that you have the Create Service Accounts IAM role (roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin).Learn how to grant roles.
    2. In the Google Cloud console, go to theCreate service account page.

      Go to Create service account
    3. Select your project.
    4. In theService account name field, enter a name. The Google Cloud console fills in theService account ID field based on this name.

      In theService account description field, enter a description. For example,Service account for quickstart.

    5. ClickCreate and continue.
    6. Grant theVertex AI > Vertex AI User role to the service account.

      To grant the role, find theSelect a role list, then selectVertex AI > Vertex AI User.

      Note: TheRole field affects which resources the service account can access in your project. You can revoke these roles or grant additional roles later.
    7. ClickContinue.
    8. ClickDone to finish creating the service account.

  6. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.

    Go to project selector

  7. Verify that billing is enabled for your Google Cloud project.

  8. Enable the Vertex AI and Workflows APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enable permission.Learn how to grant roles.

    Enable the APIs

  9. Create a service account:

    1. Ensure that you have the Create Service Accounts IAM role (roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin).Learn how to grant roles.
    2. In the Google Cloud console, go to theCreate service account page.

      Go to Create service account
    3. Select your project.
    4. In theService account name field, enter a name. The Google Cloud console fills in theService account ID field based on this name.

      In theService account description field, enter a description. For example,Service account for quickstart.

    5. ClickCreate and continue.
    6. Grant theVertex AI > Vertex AI User role to the service account.

      To grant the role, find theSelect a role list, then selectVertex AI > Vertex AI User.

      Note: TheRole field affects which resources the service account can access in your project. You can revoke these roles or grant additional roles later.
    7. ClickContinue.
    8. ClickDone to finish creating the service account.

gcloud

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.create permission.Learn how to grant roles.
    Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Vertex AI and Workflows APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enable permission.Learn how to grant roles.

    Enable the APIs

  5. Create a service account:

    1. Ensure that you have the Create Service Accounts IAM role (roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin).Learn how to grant roles.
    2. In the Google Cloud console, go to theCreate service account page.

      Go to Create service account
    3. Select your project.
    4. In theService account name field, enter a name. The Google Cloud console fills in theService account ID field based on this name.

      In theService account description field, enter a description. For example,Service account for quickstart.

    5. ClickCreate and continue.
    6. Grant theroles/aiplatform.user role to the service account.

      To grant the role, find theSelect a role list, then selectroles/aiplatform.user.

      Note: TheRole field affects which resources the service account can access in your project. You can revoke these roles or grant additional roles later.
    7. ClickContinue.
    8. ClickDone to finish creating the service account.

  6. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.

    Go to project selector

  7. Verify that billing is enabled for your Google Cloud project.

  8. Enable the Vertex AI and Workflows APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enable permission.Learn how to grant roles.

    Enable the APIs

  9. Create a service account:

    1. Ensure that you have the Create Service Accounts IAM role (roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin).Learn how to grant roles.
    2. In the Google Cloud console, go to theCreate service account page.

      Go to Create service account
    3. Select your project.
    4. In theService account name field, enter a name. The Google Cloud console fills in theService account ID field based on this name.

      In theService account description field, enter a description. For example,Service account for quickstart.

    5. ClickCreate and continue.
    6. Grant theroles/aiplatform.user role to the service account.

      To grant the role, find theSelect a role list, then selectroles/aiplatform.user.

      Note: TheRole field affects which resources the service account can access in your project. You can revoke these roles or grant additional roles later.
    7. ClickContinue.
    8. ClickDone to finish creating the service account.

Deploy a workflow that describes an image

Deploy a workflow that uses a connector method(generateContent) to make a request to a model publisherendpoint. The method provides support for content generation with multimodalinputs.

The workflow provides a text prompt and the URI of an image that is publiclyavailable in a Cloud Storage bucket. You canview the imageand, in the Google Cloud console, you canview the object details.

The workflow returns a description of the image from the model's generatedresponse.

For more information about the HTTP request body parameters used when promptingthe LLM, and the response body elements, see theGemini API reference.

Console

  1. In the Google Cloud console, go to theWorkflowspage.

    Go to Workflows

  2. ClickCreate.

  3. Enter a name for the new workflow:describe-image.

  4. In theRegion list, selectus-central1 (Iowa).

  5. For theService account, select the service account you previouslycreated.

  6. ClickNext.

  7. In the workflow editor, enter the following definition for your workflow:

    main:params:[args]steps:-init:assign:-project:${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}-location:"us-central1"-model:"gemini-2.5-flash"-text_combined:""-ask_llm:call:googleapis.aiplatform.v1.projects.locations.endpoints.generateContentargs:model:${"projects/" + project + "/locations/" + location + "/publishers/google/models/" + model}region:${location}body:contents:role:userparts:-fileData:mimeType:image/jpegfileUri:${args.image_url}-text:Describe this picture in detailgeneration_config:temperature:0.4max_output_tokens:2048top_p:1top_k:32result:llm_response-return_result:return:image_url:${args.image_url}image_description:${llm_response.candidates[0].content.parts[0].text}
  8. ClickDeploy.

gcloud

  1. Create a source code file for your workflow:

    touchdescribe-image.yaml
  2. In a text editor, copy the following workflow to your source code file:

    main:params:[args]steps:-init:assign:-project:${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}-location:"us-central1"-model:"gemini-2.5-flash"-text_combined:""-ask_llm:call:googleapis.aiplatform.v1.projects.locations.endpoints.generateContentargs:model:${"projects/" + project + "/locations/" + location + "/publishers/google/models/" + model}region:${location}body:contents:role:userparts:-fileData:mimeType:image/jpegfileUri:${args.image_url}-text:Describe this picture in detailgeneration_config:temperature:0.4max_output_tokens:2048top_p:1top_k:32result:llm_response-return_result:return:image_url:${args.image_url}image_description:${llm_response.candidates[0].content.parts[0].text}
  3. Deploy the workflow by entering the following command:

    gcloudworkflowsdeploydescribe-image\--source=describe-image.yaml\--location=us-central1\--service-account=SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com

Execute the workflow

Executing a workflow runs the current workflow definition associated with theworkflow.

Console

  1. In the Google Cloud console, go to theWorkflowspage.

    Go to Workflows

  2. On theWorkflows page, select thedescribe-image workflow to go to its details page.

  3. On theWorkflow details page, clickExecute.

  4. For theInput, enter the following:

    {"image_url":"gs://generativeai-downloads/images/scones.jpg"}
  5. ClickExecute again.

  6. View the results of the workflow in theOutput pane.

    The output should be similar to the following:

    {  "image_description": "There are three pink peony flowers on the right side of the picture[]...]There is a white napkin on the table.",  "image_url": "gs://generativeai-downloads/images/scones.jpg"}

gcloud

  1. Open a terminal.

  2. Execute the workflow:

    gcloudworkflowsrundescribe-image\--data='{"image_url":"gs://generativeai-downloads/images/scones.jpg"}'

    The execution results should be similar to the following:

      Waiting for execution [258b530e-a093-46d7-a4ff-cbf5392273c0] to complete...done.  argument: '{"image_url":"gs://generativeai-downloads/images/scones.jpg"}'  createTime: '2024-02-09T13:59:32.166409938Z'  duration: 4.174708484s  endTime: '2024-02-09T13:59:36.341118422Z'  name: projects/1051295516635/locations/us-central1/workflows/describe-image/executions/258b530e-a093-46d7-a4ff-cbf5392273c0  result: "{\"image_description\":\"The picture shows a rustic table with a white surface,\    \ on which there are several scones with blueberries, as well as two cups of coffee\    [...]    \ on the table. The background of the table is a dark blue color.\",\"image_url\"\    :\"gs://generativeai-downloads/images/scones.jpg\"}"  startTime: '2024-02-09T13:59:32.166409938Z'  state: SUCCEEDED

Deploy a workflow that generates country histories

Deploy a workflow that loops through an input list of countries inparallel and uses a connector method(generateContent) to make a request to a model publisherendpoint. The method provides support for content generation with multimodalinputs.

The workflow returns the country histories generated by the model, combiningthem in amap.

For more information about the HTTP request body parameters used when promptingthe LLM, and the response body elements, see theGemini API reference.

Console

  1. In the Google Cloud console, go to theWorkflowspage.

    Go to Workflows

  2. ClickCreate.

  3. Enter a name for the new workflow:gemini-pro-country-histories.

  4. In theRegion list, selectus-central1 (Iowa).

  5. For theService account, select the service account you previouslycreated.

  6. ClickNext.

  7. In the workflow editor, enter the following definition for your workflow:

    main:params:[args]steps:-init:assign:-project:${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}-location:"us-central1"-model:"gemini-2.5-flash"-histories:{}-loop_over_countries:parallel:shared:[histories]for:value:countryin:${args.countries}steps:-ask_llm:call:googleapis.aiplatform.v1.projects.locations.endpoints.generateContentargs:model:${"projects/" + project + "/locations/" + location + "/publishers/google/models/" + model}region:${location}body:contents:role:"USER"parts:text:${"Can you tell me about the history of " + country}generation_config:temperature:0.5max_output_tokens:2048top_p:0.8top_k:40result:llm_response-add_to_histories:assign:-histories[country]:${llm_response.candidates[0].content.parts[0].text}-return_result:return:${histories}
  8. ClickDeploy.

gcloud

  1. Create a source code file for your workflow:

    touchgemini-pro-country-histories.yaml
  2. In a text editor, copy the following workflow to your source code file:

    main:params:[args]steps:-init:assign:-project:${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}-location:"us-central1"-model:"gemini-2.5-flash"-histories:{}-loop_over_countries:parallel:shared:[histories]for:value:countryin:${args.countries}steps:-ask_llm:call:googleapis.aiplatform.v1.projects.locations.endpoints.generateContentargs:model:${"projects/" + project + "/locations/" + location + "/publishers/google/models/" + model}region:${location}body:contents:role:"USER"parts:text:${"Can you tell me about the history of " + country}generation_config:temperature:0.5max_output_tokens:2048top_p:0.8top_k:40result:llm_response-add_to_histories:assign:-histories[country]:${llm_response.candidates[0].content.parts[0].text}-return_result:return:${histories}
  3. Deploy the workflow by entering the following command:

    gcloudworkflowsdeploygemini-pro-country-histories\--source=gemini-pro-country-histories.yaml\--location=us-central1\--service-account=SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com

Execute the workflow

Executing a workflow runs the current workflow definition associated with theworkflow.

Console

  1. In the Google Cloud console, go to theWorkflowspage.

    Go to Workflows

  2. On theWorkflows page, select thegemini-pro-country-histories workflow to go to its details page.

  3. On theWorkflow details page, clickExecute.

  4. For theInput, enter the following:

    {"countries":["Argentina","Bhutan","Cyprus","Denmark","Ethiopia"]}
  5. ClickExecute again.

  6. View the results of the workflow in theOutput pane.

    The output should be similar to the following:

    {  "Argentina": "The history of Argentina is a complex and fascinating one, marked by periods of prosperity and decline, political [...]  "Bhutan": "The history of Bhutan is a rich and fascinating one, dating back to the 7th century AD. Here is a brief overview: [...]  "Cyprus": "The history of Cyprus is a long and complex one, spanning over 10,000 years. The island has been ruled by a succession [...]  "Denmark": "1. **Prehistory and Early History (c. 12,000 BC - 800 AD)**\\n   - The earliest evidence of human habitation in Denmark [...]  "Ethiopia": "The history of Ethiopia is a long and complex one, stretching back to the earliest human civilizations. The country is [...]}

gcloud

  1. Open a terminal.

  2. Execute the workflow:

    gcloudworkflowsrungemini-pro-country-histories\--data='{"countries":["Argentina", "Bhutan", "Cyprus", "Denmark", "Ethiopia"]}'\--location=us-central1

    The execution results should be similar to the following:

      Waiting for execution [7ae1ccf1-29b7-4c2c-99ec-7a12ae289391] to complete...done.  argument: '{"countries":["Argentina","Bhutan","Cyprus","Denmark","Ethiopia"]}'  createTime: '2024-02-09T16:25:16.742349156Z'  duration: 12.075968673s  endTime: '2024-02-09T16:25:28.818317829Z'  name: projects/1051295516635/locations/us-central1/workflows/gemini-pro-country-histories/executions/7ae1ccf1-29b7-4c2c-99ec-7a12ae289391  result: "{\"Argentina\":\"The history of Argentina can be traced back to the arrival\    [...]    n* 2015: Argentina elects Mauricio Macri as president.\",\"Bhutan\":\"The history\    [...]    \ natural beauty, ancient monasteries, and friendly people.\",\"Cyprus\":\"The history\    [...]    ,\"Denmark\":\"The history of Denmark can be traced back to the Stone Age, with\    [...]    \ a high standard of living.\",\"Ethiopia\":\"The history of Ethiopia is long and\    [...]  startTime: '2024-02-09T16:25:16.742349156Z'  state: SUCCEEDED

Deploy a workflow that summarizes a large document

Deploy a workflow that divides a large document into smaller parts, makinghttp.post requests to a model publisher endpoint inparallel so that the model can summarize each part simultaneously. The workflow finally combines all the partial summaries into acomplete one.

For more information about the HTTP request body parameters used when promptingthe LLM, and the response body elements, see theGemini API reference.

The workflow definition assumes that you have created a Cloud Storagebucket to which you can upload a text file. For more informationabout the Workflows connector (googleapis.storage.v1.objects.get)used to retrieve objects from the Cloud Storage bucket, see theConnectors reference.

After deploying the workflow, you can execute it by creating an appropriateEventarc trigger and then by uploading a file to the bucket. Formore information, seeRoute Cloud Storage events to Workflows.Note that additional APIs must be enabled, and additional roles must begranted, including granting to your service account the Storage Object User(roles/storage.objectUser) role that supports using Cloud Storageobjects. For more information, see thePrepare to create a trigger section.

Console

  1. In the Google Cloud console, go to theWorkflowspage.

    Go to Workflows

  2. ClickCreate.

  3. Enter a name for the new workflow:gemini-pro-summaries.

  4. In theRegion list, selectus-central1 (Iowa).

  5. For theService account, select the service account you previouslycreated.

  6. ClickNext.

  7. In the workflow editor, enter the following definition for your workflow:

    main:params:[input]steps:-assign_file_vars:assign:-file_size:${int(input.data.size)}-chunk_size:64000-n_chunks:${int(file_size / chunk_size)}-summaries:[]-all_summaries_concatenated:""-loop_over_chunks:parallel:shared:[summaries]for:value:chunk_idxrange:${[0, n_chunks]}steps:-assign_bounds:assign:-lower_bound:${chunk_idx * chunk_size}-upper_bound:${(chunk_idx + 1) * chunk_size}-summaries:${list.concat(summaries, "")}-dump_file_content:call:http.getargs:url:${"https://storage.googleapis.com/storage/v1/b/" + input.data.bucket + "/o/" + input.data.name + "?alt=media"}auth:type:OAuth2headers:Range:${"bytes=" + lower_bound + "-" + upper_bound}result:file_content-assign_chunk:assign:-chunk:${file_content.body}-generate_chunk_summary:call:ask_gemini_for_summaryargs:textToSummarize:${chunk}result:summary-assign_summary:assign:-summaries[chunk_idx]:${summary}-concat_summaries:for:value:summaryin:${summaries}steps:-append_summaries:assign:-all_summaries_concatenated:${all_summaries_concatenated + "\n" + summary}-reduce_summary:call:ask_gemini_for_summaryargs:textToSummarize:${all_summaries_concatenated}result:final_summary-return_result:return:-summaries:${summaries}-final_summary:${final_summary}ask_gemini_for_summary:params:[textToSummarize]steps:-init:assign:-project:${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}-location:"us-central1"-model:"gemini-2.5-pro"-summary:""-call_gemini:call:http.postargs:url:${"https://" + location + "-aiplatform.googleapis.com" + "/v1/projects/" + project + "/locations/" + location + "/publishers/google/models/" + model + ":generateContent"}auth:type:OAuth2body:contents:role:userparts:-text:'${"Makeasummaryofthefollowingtext:\n\n"+textToSummarize}'generation_config:temperature:0.2maxOutputTokens:2000topK:10topP:0.9result:gemini_response# Sometimes, there's no text, for example, due to safety settings-check_text_exists:switch:-condition:${not("parts" in gemini_response.body.candidates[0].content)}next:return_summary-extract_text:assign:-summary:${gemini_response.body.candidates[0].content.parts[0].text}-return_summary:return:${summary}
  8. ClickDeploy.

gcloud

  1. Create a source code file for your workflow:

    touchgemini-pro-summaries.yaml
  2. In a text editor, copy the following workflow to your source code file:

    main:params:[input]steps:-assign_file_vars:assign:-file_size:${int(input.data.size)}-chunk_size:64000-n_chunks:${int(file_size / chunk_size)}-summaries:[]-all_summaries_concatenated:""-loop_over_chunks:parallel:shared:[summaries]for:value:chunk_idxrange:${[0, n_chunks]}steps:-assign_bounds:assign:-lower_bound:${chunk_idx * chunk_size}-upper_bound:${(chunk_idx + 1) * chunk_size}-summaries:${list.concat(summaries, "")}-dump_file_content:call:http.getargs:url:${"https://storage.googleapis.com/storage/v1/b/" + input.data.bucket + "/o/" + input.data.name + "?alt=media"}auth:type:OAuth2headers:Range:${"bytes=" + lower_bound + "-" + upper_bound}result:file_content-assign_chunk:assign:-chunk:${file_content.body}-generate_chunk_summary:call:ask_gemini_for_summaryargs:textToSummarize:${chunk}result:summary-assign_summary:assign:-summaries[chunk_idx]:${summary}-concat_summaries:for:value:summaryin:${summaries}steps:-append_summaries:assign:-all_summaries_concatenated:${all_summaries_concatenated + "\n" + summary}-reduce_summary:call:ask_gemini_for_summaryargs:textToSummarize:${all_summaries_concatenated}result:final_summary-return_result:return:-summaries:${summaries}-final_summary:${final_summary}ask_gemini_for_summary:params:[textToSummarize]steps:-init:assign:-project:${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}-location:"us-central1"-model:"gemini-2.5-pro"-summary:""-call_gemini:call:http.postargs:url:${"https://" + location + "-aiplatform.googleapis.com" + "/v1/projects/" + project + "/locations/" + location + "/publishers/google/models/" + model + ":generateContent"}auth:type:OAuth2body:contents:role:userparts:-text:'${"Makeasummaryofthefollowingtext:\n\n"+textToSummarize}'generation_config:temperature:0.2maxOutputTokens:2000topK:10topP:0.9result:gemini_response# Sometimes, there's no text, for example, due to safety settings-check_text_exists:switch:-condition:${not("parts" in gemini_response.body.candidates[0].content)}next:return_summary-extract_text:assign:-summary:${gemini_response.body.candidates[0].content.parts[0].text}-return_summary:return:${summary}
  3. Deploy the workflow by entering the following command:

    gcloudworkflowsdeploygemini-pro-summaries\--source=gemini-pro-summaries.yaml\--location=us-central1\--service-account=SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com

Clean up

To avoid incurring charges to your Google Cloud account for the resources used in this tutorial, either delete the project that contains the resources, or keep the project and delete the individual resources.

Delete the project

Console

    Caution: Deleting a project has the following effects:
    • Everything in the project is deleted. If you used an existing project for the tasks in this document, when you delete it, you also delete any other work you've done in the project.
    • Custom project IDs are lost. When you created this project, you might have created a custom project ID that you want to use in the future. To preserve the URLs that use the project ID, such as anappspot.com URL, delete selected resources inside the project instead of deleting the whole project.

    If you plan to explore multiple architectures, tutorials, or quickstarts, reusing projects can help you avoid exceeding project quota limits.

  1. In the Google Cloud console, go to theManage resources page.

    Go to Manage resources

  2. In the project list, select the project that you want to delete, and then clickDelete.
  3. In the dialog, type the project ID, and then clickShut down to delete the project.

gcloud

Caution: Deleting a project has the following effects:
  • Everything in the project is deleted. If you used an existing project for the tasks in this document, when you delete it, you also delete any other work you've done in the project.
  • Custom project IDs are lost. When you created this project, you might have created a custom project ID that you want to use in the future. To preserve the URLs that use the project ID, such as anappspot.com URL, delete selected resources inside the project instead of deleting the whole project.

If you plan to explore multiple architectures, tutorials, or quickstarts, reusing projects can help you avoid exceeding project quota limits.

  • In the Google Cloud console, go to theManage resources page.

    Go to Manage resources

  • In the project list, select the project that you want to delete, and then clickDelete.
  • In the dialog, type the project ID, and then clickShut down to delete the project.
  • Delete individual resources

    Delete the workflows that you created in this tutorial.

    What's next

    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.