Firebase AI Logic gives you access to the latest generative AI models from Google: the Gemini models and Imagen models.
Firebase AI Logic was previously called Vertex AI in Firebase. If you are upgrading from AngularFire 20, the module moved from
@angular/fire/vertexaito@angular/fire/aiand most symbols were renamed (provideVertexAItoprovideAI,VertexAItoAI). One is not a rename: plaingetAI()uses the Gemini Developer API backend, so the oldgetVertexAI()maps togetAI(app, { backend: new VertexAIBackend() }). Runningng update @angular/firerewrites all of this for you and keeps your app on the Vertex AI backend. See the AngularFire 20 to 21 upgrade guide.
As a prerequisite, ensure that AngularFire has been added to your project via
ng add @angular/fireProvide an AI instance in the application's app.config.ts:
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
import { provideAI, getAI } from '@angular/fire/ai';
export const appConfig: ApplicationConfig = {
providers: [
provideFirebaseApp(() => initializeApp({ ... })),
provideAI(() => getAI()),
...
],
...,
}Next inject AI into your component:
import { Component, inject } from '@angular/core';
import { AI } from '@angular/fire/ai';
@Component({ ... })
export class MyComponent {
private ai = inject(AI);
...
}AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.
Update the imports from import { ... } from 'firebase/ai' to import { ... } from '@angular/fire/ai' and follow the official documentation.