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

openai.js

v2.1.3

Published

Simplified wrapper for the OpenAI API

Readme

openai.js

Simplified openAI API wrapper for JavaScript

Installation

npm install openai.js
yarn add openai.js

Initialize

const OpenAI = require("openai.js");
const ai = new OpenAI("OPENAI_API_KEY");

Usage

Functions

Chat

Open ended conversation with the AI.

//Will respond to "Hi how are you"
const response = await ai.Chat("Hi how are you?");
//returns I am fine. How are you?

Sentiment Analysis

Categorize text based on sentiment.

//Categorizes the text "I hate you" into Positive, Negative, Neutral or Mixed sentiment.
const sentiment = await ai.Sentiment("I hate you.");
//returns Negative

Ask

Answers the question you ask.

//Answers the question "Who was the 45th president of the united states?"
const answer = await ai.Ask("Who was the 45th president of the united states?");
//returns Donald Trump was the 45th president of the united states.

Translate

Translates text from one language to another

//Translates the text "I dont speak french" from english to french.
const translation = await ai.Translate("English", "French", "I dont speak french.");
//returns Je ne parle pas français.

Translate Code

Translates code from one programming language to another

//Translates the code "print("Hello World!")" from python to JavaScript
const code = await ai.TranslateCode("python", "javascript", "print("Hello World!")")
//return console.log("Hello World!")

Tutor

Answers questions on the subject given

//Answers "How do i calculate the are of a circle?" based on the subject "Math"
const answer = await ai.Tutor("Math", "How do i calculate the are of a circle?");
returns You can use the formula: A = pi * r^2

AutoComplete

Finishes a sentence

//Finished the sentence "An apple a day"
const complete = await ai.AutoComplete("An apple a day");
//return keeps the doctor away

Semantic Search

Scores array of documents based on relevance to query

//Find the most relevant document in the array ["White House", "hospital", "school"] based on the query "teacher"
const searchResult = await ai.Search(["White House", "hospital", "school"], "teacher"));
//return school

Engines

These are more advanced but more customisable functions.

Complete

Simple but powerful text-in, text-out interface. You input some text as a prompt, and the model will generate a text completion that attempts to match whatever context or pattern you gave it. Visit the OpenAI docs for more info

const completion = await ai.complete("I think therefore", ["."])
//returns i am

Search

The Search endpoint allows you to do a semantic search over a set of documents.

const result = await ai.search(["White House", "hospital", "school"], "teacher"))
// returns school

Instruct

You simply tell the model what you want it to do, and it will do its best to fulfill your instructions.

const response = await ai.instruct("Explain the moon landing to a 6 year old in a few sentences.");
//reutrns People went to the moon, and they took pictures of what they saw, and sent them back to the earth so we could all see them.