1313// limitations under the License.
1414
1515// [START generativeaionvertexai_gemini_all_modalities]
16- const { VertexAI } = require ( '@google-cloud/vertexai ' ) ;
16+ const { GoogleGenAI } = require ( '@google/genai ' ) ;
1717
1818/**
1919 * TODO(developer): Update these variables before running the sample.
2020 */
21- async function analyze_all_modalities ( projectId = 'PROJECT_ID' ) {
22- const vertexAI = new VertexAI ( { project : projectId , location : 'us-central1' } ) ;
23-
24- const generativeModel = vertexAI . getGenerativeModel ( {
25- model : 'gemini-2.0-flash-001' ,
21+ async function analyze_all_modalities (
22+ projectId = 'PROJECT_ID' ,
23+ model = 'gemini-2.5-flash'
24+ ) {
25+ const client = new GoogleGenAI ( {
26+ vertexai : true ,
27+ project : projectId ,
28+ location : 'us-central1' ,
2629 } ) ;
2730
2831 const videoFilePart = {
29- file_data : {
30- file_uri :
32+ fileData : {
33+ fileUri :
3134 'gs://cloud-samples-data/generative-ai/video/behind_the_scenes_pixel.mp4' ,
32- mime_type : 'video/mp4' ,
35+ mimeType : 'video/mp4' ,
3336 } ,
3437 } ;
3538 const imageFilePart = {
36- file_data : {
37- file_uri :
39+ fileData : {
40+ fileUri :
3841 'gs://cloud-samples-data/generative-ai/image/a-man-and-a-dog.png' ,
39- mime_type : 'image/png' ,
42+ mimeType : 'image/png' ,
4043 } ,
4144 } ;
4245
@@ -52,13 +55,12 @@ async function analyze_all_modalities(projectId = 'PROJECT_ID') {
5255 - What is the context of the moment and what does the narrator say about it?` ,
5356 } ;
5457
55- const request = {
56- contents : [ { role : 'user' , parts : [ videoFilePart , imageFilePart , textPart ] } ] ,
57- } ;
58+ const response = await client . models . generateContent ( {
59+ model : model ,
60+ contents : [ videoFilePart , imageFilePart , textPart ] ,
61+ } ) ;
5862
59- const resp = await generativeModel . generateContent ( request ) ;
60- const contentResponse = await resp . response ;
61- console . log ( JSON . stringify ( contentResponse ) ) ;
63+ console . log ( response . text ) ;
6264}
6365// [END generativeaionvertexai_gemini_all_modalities]
6466
0 commit comments