Skip to content

Latest commit

 

History

History
57 lines (47 loc) · 2.8 KB

File metadata and controls

57 lines (47 loc) · 2.8 KB

Call the Vertex AI Gemini API with Remote Config and App Check

Introduction

This is a sample callable function that authenticates calling apps with App Check and then sends queries to Gemini using the Vertex AI Gemini API. Vertex AI model parameters are controlled using the Remote Config server functionality provided by the Firebase Admin SDK for Node.js. Use the client provided in client/ to access the function through basic web page.

Important: Vertex AI and Cloud Functions require a billing account. Review Vertex AI pricing and Firebase pricing before running this function. If you're new to Firebase and Google Cloud, check to see if you're eligible for a $300 credit and a Free Trial Cloud Billing account.

Get Started

  1. Follow the instructions in client/README.md to create a Firebase project, enable ReCAPTCHA Enterprise, enable Firebase App Check, and add your Firebase config and ReCAPTCHA Enterprise key to the client config.
  2. Enable recommended Vertex AI APIs.
  3. Configure a Remote Config server template on the Firebase console. Use the template described in Use server side Remote Config with Cloud Functions and Vertex AI, which contains all of the parameters used in the function sample.
  4. Install dependencies: cd functions && npm install
  5. If you haven't already done so, install firebase-tools: npm i firebase-tools@latest
  6. Log into Firebase: firebase login
  7. Deploy the function. We recommend testing in the Firebase emulator.
  8. If testing in the emulator, verify that testMode is set to true in client/main.ts, then start the client: cd public && npm run dev
  9. Open the client app in a browser and enter a prompt. To access the Vertex AI Gemini API, make sure that you have set the is_vertex_enabled boolean parameter in your Remote Config server template to true.

Support

License

© Google, 2024. Licensed under an Apache-2 license.