Skip to content
Color theme

OpenAI Module

Installation

Terminal window
npm install @loopstack/openai

Register the module in your app module:

import { Module } from '@nestjs/common';
import { OpenAiModule } from '@loopstack/openai';
@Module({
imports: [OpenAiModule],
})
export class AppModule {}

OpenAiModule registers the openai provider into the LLM provider registry on startup, so import it alongside LlmProviderModule (from @loopstack/llm-provider).

The module reads the OpenAI API key from the OPENAI_API_KEY environment variable:

OPENAI_API_KEY=sk-...