1.0.38 • Published 3 months ago
gpt-simple-api-ts v1.0.38
gpt-simple-api
A simple client OpenAI API written in Typescript.
Install
npm i gpt-simple-api-ts
Example:
// import SimpleAPI from 'gpt-simple-api-ts'
const SimpleAPI = require('gpt-simple-api-ts')
const api = new SimpleAPI({key: process.env.OPENAI_API_KEY})
async function main () {
const res = await api.getFirst("Give me a reason")
console.log("main", res)
}
main()
Methods:
setApiKey(key: string)
Sets the key To get an API KEY you need to register new OPEN API account and then visit https://platform.openai.com/account/api-keys
Models
async getModels(): Promise<null | string[]>
Streams:
async getStream(promt: string, fData, fEnd, opts): Promise<any>
abortStream
Text generation
Get text response from GPT:
async getFirst(promt: string, opts?: CreateCompletionRequest): Promise<string | undefined>
Get several text completions:
async get(promt: string, opts?: CreateCompletionRequest): Promise<null | string[]>
Completions:
async getCompletions(prompt: string, opts?: Partial<CreateCompletionRequest>): Promise<null | string[]>
Transcribe audio
async transcribe(formData): Promise<string | undefined>
Code
Get code completions:
async getCode(promt: string, opts?: CreateCompletionRequest): Promise<null | string[]>
Get one code complettion:
async getCodeFirst(promt: string, opts?: CreateCompletionRequest): Promise<string | undefined>
Projects that use it:
1.0.38
3 months ago
1.0.19
11 months ago
1.0.22
11 months ago
1.0.21
11 months ago
1.0.20
11 months ago
1.0.26
11 months ago
1.0.25
11 months ago
1.0.24
11 months ago
1.0.23
11 months ago
1.0.29
11 months ago
1.0.28
11 months ago
1.0.27
11 months ago
1.0.33
11 months ago
1.0.32
11 months ago
1.0.31
11 months ago
1.0.30
11 months ago
1.0.37
10 months ago
1.0.36
10 months ago
1.0.35
11 months ago
1.0.34
11 months ago
1.0.18
12 months ago
1.0.17
1 year ago
1.0.16
1 year ago
1.0.9
1 year ago
1.0.8
1 year ago
1.0.11
1 year ago
1.0.10
1 year ago
1.0.15
1 year ago
1.0.14
1 year ago
1.0.13
1 year ago
1.0.12
1 year ago
1.0.7
1 year ago
1.0.6
1 year ago
1.0.5
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago