OpenAi API Venturial
npm install @venturialstd/openaiSettingsService.
gpt-3.5-turbo, gpt-4, and gpt-4-turbo.
bash
npm install @venturialstd/openai
or
yarn add @venturialstd/openai
`
---
Basic Usage
$3
`ts
import { Injectable } from "@nestjs/common";
import { OpenaiResponseService } from "@venturialstd/openai";
@Injectable()
export class HarveyAIService {
constructor(private readonly openaiService: OpenaiResponseService) {}
async askQuestion(input: string, instructions: string, model: string) {
const response = await this.openaiService.createResponse(
input,
instructions,
model
);
return response.output_text;
}
}
`
---
API
$3
| Method | Parameters | Description |
| ---------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- | ------------------------------------------------------------------------- |
| getClient() | none | Returns a configured OpenAI client and default model from settings. |
| createResponse(input: string \| Responses.ResponseInput, instructions: string, model: string, store?: boolean) | input, instructions, model, optional store (default true) | Creates a new OpenAI response and optionally persists it in the database. |
---
$3
The module supports dynamic configuration via Venturial's SettingsService. Default settings:
| Key | Type | Description | Default |
| ------------------------------- | ------- | ------------------------------- | --------------- |
| GLOBAL:OPENAI:GENERAL:ENABLED | Boolean | Enable or disable OpenAI module | false |
| GLOBAL:OPENAI:GENERAL:API_KEY | Secret | OpenAI API Key | "" |
| GLOBAL:OPENAI:GENERAL:MODEL` | Select | Default OpenAI Model | "gpt-3.5-turbo" |