1.1.8 • Published 1 year ago

chatnio v1.1.8

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

ChatNio Javascript Library

The official Typescript library for the Chat Nio API

Features

  • Chat
  • Conversation
  • Quota
  • Subscription and Package

Browser Compatibility

Installation

npm install chatnio
# or using yarn, pnpm
# yarn add chatnio

Usage

  • Authentication
import { setKey, setEndpoint } from 'chatnio';

setKey("sk-...");

// set custom api endpoint (default: https://api.chatnio.net)
// setEndpoint("https://example.com/api");
  • Chat
import { Chat } from 'chatnio';

const chat = new Chat(-1); // id -1 (default): create new conversation

// using stream
chat.askStream({ message: "hello world", model: "gpt-3.5-turbo-0613", web: true }, (res) => {
  console.log(res);
});

// don't use stream
chat.ask({ message: "hi" })
  .then(res => {
    console.log(res);
  })
  .catch(err => {
    console.log(err);
  });
  • Conversation
import { getConversations, getConversation, deleteConversation } from 'chatnio';

// get all conversations of current user
const conversations = await getConversations();

// load conversation by id
const conversation = await getConversation(1);

// delete conversation by id
const state = await deleteConversation(1);
  • Quota
import { getQuota, buyQuota } from 'chatnio';

// get quota
const quota = await getQuota();

// buy quota
const state = await buyQuota(100);
  • Subscription and Package
import { getPackage, getSubscription, buySubscription } from 'chatnio';

// get package
const pkg = await getPackage();

// get subscription
const subscription = await getSubscription();

// buy subscription
const state = await buySubscription(1, 1);
1.1.8

1 year ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago