npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

easier-openai

v1.1.27

Published

A package that makes it easier to use the NPM OpenAI package.

Readme

Easier-OpenAI

A package that makes it easier to use the NPM OpenAI package.

Features

Chat Capabilities

  • Command Line Chat (cmdChat) Start an interactive chat session with OpenAI models.

    • Parameters:
      • obj: Configuration object for the chat session.
      • saveToFile: Boolean to save the conversation to a file.
      • name: Name of the file to save the conversation.
    • Usage: Allows users to interact with OpenAI models in a loop until the user exits by typing e-.
  • Get Chat (getChat) Retrieve a saved chat conversation by name.

    • Parameters:
      • chatName: Name of the chat file to retrieve.
    • Usage: Returns the chat messages in JSON format.
  • Delete Chat (deleteChat) Delete a saved chat conversation by name.

    • Parameters:
      • chatName: Name of the chat file to delete.
    • Usage: Removes the specified chat file from the system.
  • List Chats (listChats) List all saved chat conversations.

    • Usage: Returns an array of chat names.
  • Update System Instructions (updateSystemInstructions) Update the system instructions for a specific chat.

    • Parameters:
      • chatName: Name of the chat file to update.
      • newInstructions: New system instructions to apply.
    • Usage: Modifies the system message in the chat history.

Audio Capabilities

  • Generate Audio (generateAudio) Generate audio from text using OpenAI models.
    • Parameters:
      • tts_text: Text to convert to speech.
      • speechFilePath: Path to save the generated audio file.
      • systemContent: System instructions for the audio generation.
    • Usage: Converts text to audio and saves it as an MP3 file.

Image Capabilities

  • Generate Image (generateImage) Generate images using OpenAI models.
    • Parameters:
      • config: Configuration object for image generation (e.g., model, prompt, size).
      • other: Additional options (e.g., save to file, file path, file name).
    • Usage: Creates an image based on the provided prompt and optionally saves it to a file.

Utility Functions

  • Log Usage (logUsage) Log API usage details to a file.

    • Parameters:
      • endpoint: API endpoint used.
      • model: Model name.
      • tokens: Number of tokens used.
    • Usage: Appends usage details to a usage.log file.
  • Improve Prompt (improvePrompt) Enhance a given prompt using prompt engineering techniques.

    • Parameters:
      • prompt: The original prompt to improve.
      • tokens: Maximum tokens for the response.
      • reasoning: Boolean to include reasoning in the improvement process.
    • Usage: Returns an improved version of the provided prompt with detailed suggestions.

Persistent Data Management

  • Automatically saves persistent data (e.g., chat creation count) to a persistentData.json file.
  • Ensures directories for conversations, audio, images, and responses are created if they do not exist.

Warning System

  • Displays warnings for potentially expensive API calls unless disabled in the .env file.

Installation

npm install easier-openai

Usage

Importing the Library

For ES Modules:

import { chat, audio, image, utils } from 'easier-openai';

For CommonJS:

const { chat, audio, image, utils } = require('easier-openai');

Example: Chat Interaction

const chatConfig = {
  type: 'chat',
  model: 'gpt-4',
  prompt: 'Hello!',
  maxTokens: 100,
};

chat.cmd(chatConfig, true, 'example-chat');

Example: Generate Audio

audio.generate('Hello, world!', './output.mp3', 'Generate a friendly greeting.');

Example: Generate Image

const imageConfig = {
  model: 'dall-e-3',
  prompt: 'A futuristic cityscape at sunset',
  size: '1024x1024',
};

image.generate(imageConfig, { file: true, path: './images', fileName: 'cityscape.png' });

Example: Improve Prompt

const improvedPrompt = await utils.improvePrompt('Write a story about a hero.', 500, true);
console.log(improvedPrompt);

Environment Variables

  • OPENAI_API_KEY: Your OpenAI API key.
  • DISABLE_WARNING: Set to true to disable warnings for expensive API calls.

Directories

  • ./conversations: Stores saved chat conversations.
  • ./gen-audio: Stores generated audio files.
  • ./gen-imgs: Stores generated images.
  • ./responses: Stores saved API responses.

License

MIT License