Skip to content

Latest commit

 

History

History

samples

Google Generative AI Samples for JavaScript

These samples demonstrate how to use state-of-the-art generative AI models (like Gemini) to build AI-powered features and applications.

To try out these samples, you'll need Node.js v18+.

For some samples of how to adapt this to web, see the web/ subdirectory.

Requirements

Follow the instructions on Google AI Studio setup page to obtain an API key.

It’s strongly recommended that you do not check an API key into your version control system. Instead, you should use a secrets store for your API key.

This sample assumes that you're providing an API_KEY environment variable.

Instructions

Each of these sample files can be run in Node.js from the command line, for example:

node function_calling.js

Some of these files run multiple example cases sequentially, and you may want to comment out cases you do not want to run.

Documentation