1.0.46 • Published 11 months ago

gpt-simple-api-ts v1.0.46

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

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:

GPTCraft

GPTCraft Chrome Extension

Vue-Gpt-Playground

GPT ProjectInsight

1.0.40

1 year ago

1.0.44

11 months ago

1.0.43

11 months ago

1.0.42

11 months ago

1.0.41

11 months ago

1.0.46

11 months ago

1.0.45

11 months ago

1.0.38

1 year ago

1.0.19

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.29

2 years ago

1.0.28

2 years ago

1.0.27

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago