Socket
Socket
Sign inDemoInstall

openai

Package Overview
Dependencies
Maintainers
2
Versions
190
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openai - npm Package Compare versions

Comparing version 1.1.3 to 2.0.0

.openapi-generator-ignore

15

dist/index.d.ts

@@ -1,2 +0,13 @@

export * from './lib.js';
export * from './types.js';
/**
* OpenAI API
* APIs for sampling from and fine-tuning language models
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export * from "./api";
export * from "./configuration";

@@ -1,2 +0,27 @@

export * from './lib.js';
export * from './types.js';
"use strict";
/* tslint:disable */
/* eslint-disable */
/**
* OpenAI API
* APIs for sampling from and fine-tuning language models
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./api"), exports);
__exportStar(require("./configuration"), exports);

70

package.json
{
"name": "openai",
"version": "1.1.3",
"description": "Tiny OpenAI API wrapper",
"type": "module",
"main": "dist/index.js",
"scripts": {
"start": "tsc -d --watch",
"build": "tsc -d",
"clean": "rm -rf dist",
"lint": "eslint . --fix --cache && prettier --write src",
"lint:nofix": "eslint . && prettier --check src",
"postinstall": "node ./postinstall.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ceifa/openai.git"
},
"author": "ceifa",
"license": "MIT",
"keywords": [
"gpt-3",
"gpt",
"ai",
"openai"
],
"bugs": {
"url": "https://github.com/ceifa/openai/issues"
},
"homepage": "https://github.com/ceifa/openai#readme",
"devDependencies": {
"@types/node": "16.11.11",
"@typescript-eslint/eslint-plugin": "5.5.0",
"@typescript-eslint/parser": "5.5.0",
"eslint": "8.3.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-sort-imports-es6-autofix": "0.6.0",
"prettier": "2.5.0",
"typescript": "4.5.2"
},
"dependencies": {
"form-data": "4.0.0",
"node-fetch": "3.1.0",
"openai": "^1.1.2"
}
"name": "openai",
"version": "2.0.0",
"description": "Node.js library for the OpenAI API",
"keywords": [
"openai",
"open",
"ai",
"gpt-3",
"gpt3"
],
"author": "OpenAI",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "tsc --outDir dist/"
},
"dependencies": {
"axios": "^0.25.0",
"form-data": "^4.0.0"
},
"devDependencies": {
"@types/node": "^12.11.5",
"typescript": "^3.6.4"
}
}

@@ -1,7 +0,56 @@

# OpenAI
# OpenAI Node.js Library
> tl;dr: Please consider using [GPT-X](https://www.npmjs.com/package/gpt-x) instead
The OpenAI Node.js library provides convenient access to the OpenAI API from Node.js applications. Most of the code in this library is generated from our [OpenAPI specification](https://github.com/openai/openai-openapi).
This package will be replaced soon by an official one from OpenAI. If you still want to use the unofficial version package, just switch to the new one called [GPT-X](https://www.npmjs.com/package/gpt-x), it will remain the same API for compatibility reasons.
**Important note: this library is meant for server-side usage only, as using it in client-side browser code will expose your secret API key. [See here](https://beta.openai.com/docs/api-reference/authentication) for more details.**
Enter in our community about Natural language generation to share and learn about OpenAI, prompt engineering and other providers: https://discord.gg/8ZwcSt9XkD
## Installation
```bash
$ npm install openai
```
## Usage
The library needs to be configured with your account's secret key, which is available on the [website](https://beta.openai.com/account/api-keys). We recommend setting it as an environment variable. Here's an example of initializing the library with the API key loaded from an environment variable and creating a completion:
```javascript
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const completion = await openai.createCompletion("davinci", {
prompt: "Hello world",
});
console.log(completion.data.choices[0].text);
```
Check out the [full API documentation](https://beta.openai.com/docs/api-reference?lang=javascript) for examples of all the available functions.
### Request options
All of the available API request functions additionally contain an optional final parameter where you can pass custom [axios request options](https://axios-http.com/docs/req_config), for example:
```javascript
const completion = await openai.createCompletion(
"davinci",
{
prompt: "Once upon a time",
max_tokens: 5,
},
{
timeout: 1000,
headers: {
"Example-Header": "example",
},
}
);
```
## Thanks
Thank you to [ceifa](https://github.com/ceifa) for creating and maintaining the original unofficial `openai` npm package before we released this official library!

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc