openai-api
Advanced tools
Comparing version 1.0.17 to 1.0.18
{ | ||
"name": "openai-api", | ||
"version": "1.0.17", | ||
"version": "1.0.18", | ||
"description": "A tiny client module for the openAI API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -19,7 +19,15 @@ # openai-api | ||
### Initializing | ||
```js | ||
const OpenAI = require('openai-api'); | ||
const OPEN_AI_API_KEY = #################### | ||
const openai = new OpenAI(OPEN_AI_API_KEY); | ||
// Load your key from an environment variable or secret management service | ||
// (do not include your key directly in your code) | ||
const OPENAI_API_KEY = process.env.OPENAI_API_KEY; | ||
const openai = new OpenAI(OPENAI_API_KEY); | ||
``` | ||
### Completion API call | ||
```js | ||
(async () => { | ||
@@ -42,3 +50,24 @@ const gptResponse = await openai.complete({ | ||
})(); | ||
``` | ||
#### Example of a successful completion response: | ||
```json | ||
{ | ||
id: 'some-long-id', | ||
object: 'text_completion', | ||
created: 1616791508, | ||
model: 'davinci:2020-05-03', | ||
choices: [ | ||
{ | ||
text: " predicted text...", | ||
index: 0, | ||
logprobs: null, | ||
finish_reason: 'length' | ||
} | ||
] | ||
} | ||
``` | ||
### Search API call | ||
```js | ||
(async () => { | ||
@@ -54,1 +83,3 @@ const gptResponse = await openai.search({ | ||
``` | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6144
83