@redredgroup/nestjs-genai
v1.0.0
Published
Gemini AI integration to a NestJS application
Readme
Nestjs GenAI

Introduction
NestJS module that wraps the official @google/genai SDK so you can share a configured Gemini client via dependency injection.
Installation
using npm
npm install @redredgroup/nestjs-genaiusing yarn
yarn install @redredgroup/nestjs-genaiusing pnpm
pnpm add @redredgroup/nestjs-genaiImport module
import { Module } from '@nestjs/common';
import { GenAIModule } from '@redredgroup/nestjs-genai';
@Module({
imports: [
GenAIModule.forRoot({
options: {
apiKey: 'GOOGLE_API_KEY',
},
}),
],
})
export class AppModule {}
// Or the forRootAsync module using @nestjs/Config
import { Module } from '@nestjs/common';
import { GenAIModule } from '@redredgroup/nestjs-genai';
import { ConfigModule, ConfigService } from '@nestjs/config';
@Module({
imports: [
GenAIModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (configService: ConfigService) => ({
options: {
apiKey: configService.get('GOOGLE_API_KEY'),
},
}),
}),
],
})
export class AppModule {}Output 4 nicknames similar to the injected nickname
import { Injectable } from '@nestjs/common';
import { GenAIService } from '@redredgroup/nestjs-genai';
import type { GenerateContentResponse } from '@google/genai';
@Injectable()
export class AppService {
constructor(private readonly genAiService: GenAIService) {}
async generateRandomNickname(nickname: string): Promise<GenerateContentResponse> {
const response = await this.genAiService.models.generateContent({
model: 'gemini-1.5-flash',
contents: `You are a helpful assistant that generates nicknames. Provide 4 nicknames similar to "${nickname}".`,
});
return response;
}
}Copyright
© 2025 REDREDGROUP Software. All Right Reserved.
License
Apache-2.0
