How to Use Gemini 2.5 Flash in Apps Script with Vertex AI
Key Takeaways
This video demonstrates how to use the Vertex AI advanced service in Apps Script to prompt the Gemini 2.5 Flash model and generate text. It covers setting up a Google Cloud project, enabling the Vertex AI API, and using the advanced service to call the API's generate content method.
Full Transcript
In this video, I'm going to show you how to use our Vertex AI advanced service to prompt the Gemini 2.5 flash model directly from an Appcript project. But first, what is Vertex AI and what makes it interesting to AppScript and Google Workspace developers? Google Cloud's Vertex AI is a machine learning platform that lets you train and deploy ML models and AI applications. There are a few reasons why you might be interested in using Vertex AI as an appcript developer. First, the Vertex AI's model garden provides Appcript developers with enterprisegrade access to Gemini and thirdparty models. The platform also supports advanced agentic features like function calling and fine-tuning while offering enhanced security and access control. These models and features ultimately make Vert.exai the preferred choice for scalable professional Google Workspace solutions that you can share with others in your organization or publicly on the Google Workspace marketplace. To use AppScript's Vertex AI advanced service, you need to have a Google Cloud project. In the cloud project, you must also enable billing and the Vert.ex AI API. Now that we have what we need, let's set up an Appcript project with Vert.Exai. If you'd like to try this out yourself, the instructions and code sample I'll be using are available in the AppScript documentation, which I'll link in the video description. Okay, so here's my Appcript project, which has some sample code. I'll start by enabling the Vertex AI service. From the editor, I click add a service. And then from the drop-own menu, I select Vertex AI API. After I click add, you can see that Vertex AI now appears under my enabled services. Now, let's look at the code. First, we're using the main function as the entry point to trigger the advanced service. This function includes the prompt we'll use and handles any errors if the connection to Vertex AI fails. Our prompt asks what is AppScript in one sentence. The main function triggers the function callver vertex AI which handles the API request by specifying an AI model and the cloud project ID and region. I've set my cloud project ID here as a script property, but you can also just specify the ID as a string. Here's where we specify the Gemini 2.5 flash model. This is the model we'll prompt with our question about AppScript. And here's the payload for the request to Vert.ex AI API, which includes the prompt and some other configurations, including the maximum output tokens for the response. In this line, you can see we're using the Vert.Ex AI advanced service to call the API's generate content method. The advanced service acts as a built-in authenticated wrapper that sends your request directly to the Vert.Ex AI API. To test this code, I go to the top menu and click run to run the main function. A window may pop up asking you to give permissions for the function to run, but otherwise it'll run right away as you see here. And in the execution log, the service has answered our prompt and generated some text explaining what Appcript is. And that's all there is to getting started with Vert.Exai. To try it out yourself, check out our quick start in the Appcript documentation. The quick start shows you how to configure your Google Cloud and Appcript projects and includes the code sample that I demoed for you today. For more advanced examples showing you how to use Vertex AI to build AI agents and add-ons for Google Workspace, check out our samples gallery. Thanks for watching.
Original Description
Learn how to get started with the Vertex AI advanced service in Apps Script. This video shows you how to set up and use the service to prompt the Gemini 2.5 Flash model to generate text.
For more details, visit our documentation: https://developers.google.com/apps-script/quickstart/vertex-ai
Subscribe to our YouTube channel: https://www.youtube.com/@googleworkspacedevs/
Subscribe to our Google Workspace Developer Newsletter: https://developers.google.com/workspace/newsletters
#gemini #googleworkspace #appsscript #vertexai
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Playlist UUUcg6az6etU_gRtZVAhBXaw · Google Workspace Developers · 36 of 48
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
▶
37
38
39
40
41
42
43
44
45
46
47
48
Jump start your Apps Script project with a starter template
Google Workspace Developers
Format and fix code with the Apps Script command palette
Google Workspace Developers
Join the Google Workspace Developer Summit 2025
Google Workspace Developers
Simplify your code using Apps Script libraries and services
Google Workspace Developers
Quote other messages via Chat API, rollout of granular OAuth consent for Editor add ons, and more!
Google Workspace Developers
Developer Spotlight with Taylor Lykins, Product Manager at Lucid Software
Google Workspace Developers
Rollout of granular OAuth consent for Editor add-ons
Google Workspace Developers
Why did Lucid create Google Workspace integrations?
Google Workspace Developers
Use the Apps Script project dashboard
Google Workspace Developers
Generate Apps Script code using Google AI Studio
Google Workspace Developers
Updates to the Gmail API, the Reports API, Chat app capabilities, and more!
Google Workspace Developers
Create Deal Card via the Gmail API
Google Workspace Developers
Check out the interview Taylor from Lucid Software
Google Workspace Developers
Google Workspace Development Crash Course in Paris
Google Workspace Developers
How to use variables in Workspace Flows
Google Workspace Developers
Develop custom steps for Workspace Flows
Google Workspace Developers
Calendar API update for secondary calendars, create Workspace Flows custom steps, and more!
Google Workspace Developers
Google Workspace Developer Summit - Behind the scenes
Google Workspace Developers
From Signal to Success Lucid Software’s Journey as an Early Google Chat Integration Partner
Google Workspace Developers
Beyond the Build: Navigating the Google Workspace Marketplace Review Process
Google Workspace Developers
Prepare for Granular OAuth Consent in Apps Script powered Add-ons and Chat Apps
Google Workspace Developers
Demystifying Service Accounts When, Why, and How to Use Them
Google Workspace Developers
Supercharge collaboration with Meet APIs
Google Workspace Developers
Apps Script in Google Workspace
Google Workspace Developers
Leveraging AI Tools in Workspace Development
Google Workspace Developers
Google Workspace Developer News: Granular OAuth rollout, Drive Events, Meet API, and more!
Google Workspace Developers
Granular OAuth consent for web apps and Workspace add-ons
Google Workspace Developers
Developer Spotlight: The State of AI in Workspace Development
Google Workspace Developers
What's your AI-assisted developer workflow?
Google Workspace Developers
Developer Spotlight: Service Accounts need to know & using AI isn't cheating
Google Workspace Developers
Using AI is not cheating!
Google Workspace Developers
Developer Spotlight: Granular OAuth consent and publishing to the Workspace Marketplace
Google Workspace Developers
Developer Spotlight: Suraj Iyer - Apps Script Product Manager
Google Workspace Developers
Google Workspace Developer News: December 2025 Updates
Google Workspace Developers
Automate Your Tasks in 5 Minutes: Apps Script + Gemini for Beginners
Google Workspace Developers
How to Use Gemini 2.5 Flash in Apps Script with Vertex AI
Google Workspace Developers
Get started with Vertex AI in Apps Script
Google Workspace Developers
Google Workspace Developer News: January 2026 Updates
Google Workspace Developers
Get started with Google Workspace Studio
Google Workspace Developers
Check out how to get started with Google Workspace Studio
Google Workspace Developers
How to use variables in Google Workspace Studio
Google Workspace Developers
Why you sometimes can't add variables in Google Workspace Studio
Google Workspace Developers
Google Workspace Studio: Extract PDF Data to Sheets Automatically
Google Workspace Developers
Let's build an invoice assistant in Workspace Studio
Google Workspace Developers
Google Workspace Developer News: February 2026 Updates
Google Workspace Developers
Google Workspace Studio: Understanding Starters and Steps
Google Workspace Developers
Check out templates in Google Workspace Studio
Google Workspace Developers
Get data from an email attachment with Workspace Studio
Google Workspace Developers
More on: LLM Foundations
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
When AI Asks for More Electricity Than a Country Can Imagine
Medium · AI
You Are Not Behind. The World Is.
Medium · AI
Career choice with the advent of AI - pure Computer Science or learn software with a background of core engineering area
Dev.to AI
The AI Hype Cycle: Calm Before the Next Breakthrough?
Medium · Programming
🎓
Tutor Explanation
DeepCamp AI