A simple OpenAI API client wrapper for Node.js, with ESM and TypeScript support.
- 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
npm install @eliware/openaiimport { 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);
})();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 theOPENAI_API_KEYenvironment variable.- Returns: A Promise that resolves to an OpenAI client instance.
- Throws: If no API key is provided.
Type definitions are included:
import { createOpenAI } from '@eliware/openai';
import type OpenAI from 'openai';
const openai: OpenAI = await createOpenAI();For help, questions, or to chat with the author and community, visit:


