Skip to content

Latest commit

 

History

History
53 lines (38 loc) · 1.58 KB

vertexai.md

File metadata and controls

53 lines (38 loc) · 1.58 KB
AngularFireDeveloper Guide ❱ Vertex AI

Vertex AI (preview)

The Vertex AI Gemini API gives you access to the latest generative AI models from Google: the Gemini models.

Learn more

Dependency Injection

As a prerequisite, ensure that AngularFire has been added to your project via

ng add @angular/fire

Provide a Vertex AI instance in the application's app.config.ts:

import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
import { provideVertexAI, getVertexAI } from '@angular/fire/vertexai-preview';

export const appConfig: ApplicationConfig = {
  providers: [
    provideFirebaseApp(() => initializeApp({ ... })),
    provideVertexAI(() => getVertexAI()),
    ...
  ],
  ...,
}

Next inject VertexAI into your component:

import { Component, inject } from '@angular/core';
import { VertexAI } from '@angular/fire/vertexai';

@Component({ ... })
export class MyComponent {
    private vertexAI = inject(VertexAI);
    ...
}

Firebase API

AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.

Update the imports from import { ... } from 'firebase/vertexai' to import { ... } from '@angular/fire/vertexai' and follow the official documentation.

Getting Started | API Reference