@venturialstd/openai
v0.0.9
Published
OpenAi API Venturial
Keywords
Readme
@venturialstd/openai
A lightweight Package for OpenAI, developed by Venturial, that allows you to interact with OpenAI's Responses API. Designed to be used by directly instantiating a client with dynamic configuration, without requiring a global module. Ideal for projects under the Venturial organization.
Features
- Generate responses using OpenAI's Responses API.
- Persist OpenAI responses in a TypeORM-managed database.
- Dynamically provide API key and model settings via Venturial's
SettingsService. - Fully compatible with NestJS HttpModule, SharedModule, and provider injection.
- Preconfigured with default models like
gpt-3.5-turbo,gpt-4, andgpt-4-turbo.
Installation
npm install @venturialstd/openai
# or
yarn add @venturialstd/openaiBasic Usage
1. Use the OpenAI client in your service
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
OpenAIClient | OpenaiResponseService
| 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. |
Settings
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" |
Available models:
- gpt-3.5-turbo
- gpt-4
- gpt-4-32k
- gpt-4-turbo
- gpt-4-turbo-16k
- gpt-4-turbo-32k
- gpt-4-turbo-8k
- gpt-4.1-nano
Notes
- Requires openai, @nestjs/common, @nestjs/axios, and @venturialstd/core as peer dependencies.
- Works with both dynamic database settings and hardcoded API keys.
- Perfect for projects where AI responses must be stored or audited.
- Developed and maintained by Venturial for their internal and client projects.
License
MIT
