Hi everyone,
I’m currently using Firebase Functions for my iOS app with the OpenAI API, but I’m considering migrating to the Gemini API. I’ve noticed that the pricing for Gemini 1.5 Flash is much cheaper on Vertex AI compared to Google AI Studio. However, I’m struggling to figure out how to integrate the Vertex AI Gemini API with Firebase Functions.
Is the only option is to use the Google AI Studio’s API key for this integration?
Any guidance or insights on how to achieve this would be greatly appreciated.
Thank you!
Hi welcome to the Google AI forum.
You can integrate Firebase with Vertex AI. To get started, log in to the Google Cloud Dashboard. Once logged in, look for the star-shaped icon for Gemini AI. Gemini AI can help you quickly find answers to any questions related to Google Cloud. It will saves a lot of time.
1 Like
Howdy, and welcome to the forums!
Be careful when reading the pricing pages! Vertex AI and AI Studio bill differently.
- AI Studio bills per token
- Vertex AI bills per character
Although there is no exact conversion, the rule of thumb is that there are 4 characters per token, so you need to multiply the Vertex AI pricing by “about 4” to get roughly equivalent pricing.
(Also note that the pricing pages use different orders of magnitude - AI Studio gives it per 1M tokens, while Vertex AI gives it per 1k characters.)
Is there anything specific about the integration that is causing problems? The more info or specifics you can give, the better our chances are of helping.
Firebase Functions are a great choice for deploying your code that uses Gemini. It will help us help you if we knew which language you were using with Firebase Functions.
A few things to note:
- Auth is easiest if your Firebase Google Cloud project is the same one you’ll be using for Vertex AI.
- You will need to enable the Vertex AI API in the Google Cloud Console.
- Vertex AI and AI Studio use different libraries, although the two are fairly comparable. (This is a little easier if you’re using something like LangChain.js or Genkit, but is pretty straightforward even without them.)
Nope. In fact - you can’t use an API Key to access Vertex AI.
But there is some great news if you’re using Firebase Functions!
Firebase Functions supports Application Default Credentials (ADC) and has a service account that runs all your code. So all you need to do is authorize that service account to use Vertex AI - and you’re all set. You don’t need to set an API Key or set any other credentials.
(I actually love using Vertex AI on Firebase Functions for this alone - auth is completely invisible and “just works”.)
1 Like
@innovatix Thanks for the tips on GCP’s Gemini AI chatbot!
@afirstenberg Thanks for the detailed info on pricing and integration! I was able to implement Vertex AI with Firebase Functions!
Appreciate the help!
3 Likes