The official Typescript library for the Chat Nio API
- Authors: Deeptrain Team
- Free software: MIT license
- Documentation: https://docs.chatnio.net
- Chat
- Conversation
- Quota
- Subscription and Package
npm install chatnio
# or using yarn, pnpm
# yarn add chatnio
- Authentication
import { setKey, setEndpoint } from 'chatnio';
setKey("sk-...");
// set custom api endpoint (default: https://api.chatnio.net)
// setEndpoint("https://example.com/api");
- Chat (Currently Browser Only)
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);