Using Firebase Logic AI
Trying to use the new gemini-3-pro-preview but for some reason it's always point to the vertex api giving me a 403
This my app.config
provideAI(() => getAI(getApp(), { backend: new GoogleAIBackend() })),
In my firebase console i enabled it to use gemini api. Does GoogleAIBackend use the proper endpoint?
here is the js 403 error I get:
https://firebasevertexai.googleapis.com/v1beta/projects/board-games-315b9/models/gemini-3-pro-preview:streamGenerateContent?alt=sse: [403 ] Requests to this API firebasevertexai.googleapis.com method google.firebase.vertexai.v1beta.GenerativeService.StreamGenerateContent are blocked.
I know I have to enable the vertex i don't want to. I want to use the Gemini
Preview models are only available in the global region.
//https://firebase.google.com/docs/ai-logic/models#available-model-names
const vertexAI = getAI(firebaseApp, { backend: new VertexAIBackend('global') });
this.model = getGenerativeModel(vertexAI, {
model: 'gemini-3-flash-preview',
systemInstruction: systemPrompt,
});
This should be fixed already with latest AngularFire version (v21).
Thanks for the report, and thanks @gui-complypro for the note about preview models.
To answer the question in the issue: yes, GoogleAIBackend selects the Gemini Developer API.
- In the Firebase JS SDK both backends send their requests to the
firebasevertexai.googleapis.comhost, and the backend only changes the path. - The Gemini Developer API path is
projects/{project}/models/{model}, which is the path in your error. The Vertex AI path adds alocations/{location}segment. - AngularFire passes your
getAIoptions to the SDK unchanged, so the backend you asked for is the one in effect.
That makes the 403 a project setting rather than a backend mix-up. Firebase's AI Logic error-codes page lists this exact message, "Requests to this API firebasevertexai.googleapis.com ... are blocked", under API key restrictions:
- The API key in your app's Firebase config excludes the Firebase AI Logic API.
- The fix is in the Google Cloud console under APIs & Services, Credentials: add the Firebase AI Logic API to that key's API restrictions. It can take a few minutes to apply.
- The Gemini Developer API does not need Vertex AI and runs on the Spark plan. Preview models such as
gemini-3-pro-previewneed the Blaze plan, whichever provider you use.
AngularFire 21.0.0 ships @angular/fire/ai with provideAI, getAI and both backends, and the AI Logic guide covers the setup: https://github.com/angular/angularfire/blob/21.0.x/docs/ai.md
I'm closing this since there is nothing for AngularFire to change here. If fixing the key restriction does not clear the 403, please open a new issue with the request URL and the key settings, and I'll take another look.