VitNode

Artificial Intelligence (AI)

How to use AI in your application.

VitNode allows you to use AI in your application. You can use AI to make your application smarter and more user-friendly.

Installation

Thanks to Vercel AI SDK, you can choose from a variety of AI models to use in your application.

Here is an example of how to install the Google AI model:

Install package

pnpm add @ai-sdk/openai

Add environment variable

.env
AI_MODEL_API_KEY=your-api-key

Import model

apps/backend/src/app.module.ts
import { createGoogleGenerativeAI } from '@ai-sdk/google'; 
import { CacheModule } from '@nestjs/cache-manager';
import { Module } from '@nestjs/common';
import { VitNodeCoreModule } from 'vitnode-backend/app.module';
 
import { DATABASE_ENVS, schemaDatabase } from './database/config';
import { DatabaseModule } from './database/database.module';
import { PluginsModule } from './plugins/plugins.module';
 

const modelAI = createGoogleGenerativeAI({

  apiKey: process.env.AI_MODEL_API_KEY,

});
 
@Module({
  imports: [
    VitNodeCoreModule.register({
      ai: modelAI('gemini-1.5-pro'), 
      database: {
        config: DATABASE_ENVS,
        schemaDatabase,
      },
    }),
    DatabaseModule,
    PluginsModule,
    CacheModule.register({
      isGlobal: true,
    }),
  ],
})
export class AppModule {}

On this page