Skip to content

Dalufishe/freegptjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Node.js Free GPT 3.5 API Library

This library provides Free access to the OpenAI ChatGPT 3.5 API from JavaScript.

No API key required.

The API is almost the same as openai-node.

npm install freegptjs

Usage

import FreeGPT3 from "freegptjs";

// No API key required.
const openai = new FreeGPT3();

async function main() {
  const chatCompletion = await openai.chat.completions.create({
    messages: [{ role: "user", content: "Hello, Free GPT !" }],
    model: "gpt-3.5-turbo",
  });
  console.log(chatCompletion.choices[0].message.content);
}

main();

Streaming responses

import FreeGPT3 from "freegptjs";

const openai = new FreeGPT3();

async function main() {
  const stream = await openai.chat.completions.create({
    model: "gpt-3.5-turbo",
    messages: [{ role: "user", content: "Hello, Free GPT !" }],
    stream: true,
  });
  for await (const chunk of stream) {
    console.log(chunk.choices[0]?.delta?.content || "");
  }
}

main();

Special Thanks

https://github.com/skzhengkai/free-chatgpt-api https://github.com/missuo/FreeGPT35

About

Free ChatGPT 3.5 API for Javascript.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published