# openai-api-node

> A NodeJS client for the OpenAI API

Latest version **1.0.0** (published 2020-08-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install openai-api-node
pnpm add openai-api-node
yarn add openai-api-node
bun add openai-api-node
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-08-04 |
| First published | 2020-08-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 20 |
| Author | Vittorio |
| Maintainers | erlapso |
| Keywords | openai, openaiapi, gpt-3, gpt3 |

## Links

- npm: https://www.npmjs.com/package/openai-api-node
- Repository: https://github.com/erlapso/openai-api-node
- Homepage: https://github.com/erlapso/openai-api-node#readme
- Issues: https://github.com/erlapso/openai-api-node/issues
- npm.io page: https://npm.io/package/openai-api-node

## Recent versions

- 1.0.0 (latest) — 2020-08-04

## README

# OpenAI API Node

A simple node wrapper for the OpenAI API.

## Disclaimer

The API itself and this package are meant for development and research use only. Don't use this in production.

If you don't have an API key, you need to request it at (openai.com)[https://beta.openai.com/]

## Install

$ npm install openai-api-node

## Usage

Quick start with a new completion:

const OpenAIAPI = require('../lib/openaiapi');
  var openai = new OpenAIAPI("YOUR API KEY HERE")
  openai.CompletionsCreate("your starting prompt")
  .then(function(data) {
    //Do something with the data.
  })
  .catch(function(err) {
    //The API returned an error
  })
})

You will get an object similar to the following:

{
  id: 'cmpl-yyyyyyyyyyy',
  object: 'text_completion',
  created: 1596217113,
  model: 'davinci:2020-05-03',
  choices: [
    {
      text: '” problem for me',
      index: 0,
      logprobs: null,
      finish_reason: 'length'
    }
  ]
}

### Init

You will need an API key to initialize the object. You can also pass the following parameters:
  
 $ var openai = new OpenAIAPI("YOUR API KEY HERE", apiBase = "api.openai.com", version = "v1")

### CompletionsCreate

CompletionsCreate accepts the following parameters. Only the first parameter is required:

$ CompletionsCreate(prompt, max_tokens=5, engine="davinci", options={})

You can also pass additional options as an object

## Contribute

Make a pull request :)

## Test

We are using mocha to run a basic test. To pass the test, you need to put your api key in `test/completions.js`

## License

[The MIT License](http://opensource.org/licenses/MIT)

---
_Source: https://npm.io/package/openai-api-node · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
