Skip to content

eliware/openai

Repository files navigation

eliware.org

@eliware/openai npm versionlicensebuild status

A simple OpenAI API client wrapper for Node.js, with ESM and TypeScript support.


Table of Contents

Features

  • Minimal wrapper for the official OpenAI Node.js SDK
  • ESM-first and TypeScript-ready
  • Simple API key management (env or parameter)
  • Example usage and tests included

Installation

npm install @eliware/openai

Usage

import { createOpenAI } from '@eliware/openai';

(async () => {
  // Optionally pass your API key, or set OPENAI_API_KEY in your environment
  const openai = await createOpenAI();
  // Example: list models
  // const models = await openai.models.list();
  // console.log(models);
})();

API

createOpenAI(apiKey?: string): Promise<OpenAI>

Creates and returns a new OpenAI client instance. If apiKey is not provided, it will use process.env.OPENAI_API_KEY.

  • apiKey (optional): Your OpenAI API key. If omitted, the function will use the OPENAI_API_KEY environment variable.
  • Returns: A Promise that resolves to an OpenAI client instance.
  • Throws: If no API key is provided.

TypeScript

Type definitions are included:

import { createOpenAI } from '@eliware/openai';
import type OpenAI from 'openai';
const openai: OpenAI = await createOpenAI();

Support

For help, questions, or to chat with the author and community, visit:

Discordeliware.org

eliware.org on Discord

License

MIT © 2025 Eli Sterling, eliware.org

Links

About

A simple OpenAI API client wrapper for Node.js, with ESM and TypeScript support.

Topics

Resources

License

Stars

Watchers

Forks