JSPM

openai-nodejs

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 70
  • Score
    100M100P100Q79161F
  • License MIT

A non-official OpenAI API wrapper for node.

Package Exports

  • openai-nodejs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (openai-nodejs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

OpenAI NodeJS

A non-official OpenAI API wrapper for node.

Getting Started

Installation

If you have npm installed, start using openai-nodejs with the following commands.

npm install openai-nodejs

Usage

openai-nodejs follows the latest maintenance LTS version of Node.

Example - Complete the phrase "My name is Bond"

const OpenAI = require('openai-nodejs');
const client = new OpenAI('YOUR_API_KEY');

var prompt = 'My name is Bond';
client.complete(prompt, {stop: ['\n', '"'], temperature: 0})
.then(completion => {
    console.log(`Result: ${prompt}${completion.choices[0].text}`);
})
.catch(console.error);

The likely answer will be ", James Bond!"

If you want to see more examples, please check our documentation.

Documentation

You can check the full API reference here.

Note: Some API parameter descriptions adopted from OpenAI's API Reference. If you use the Official OpenAI's API docs as your primary reference, be aware that this library has some differences compared to it.

License

MIT