
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
chatnio-node
Advanced tools
A forked Javascript/Typescript library for the Chat Nio API on Node.
English
·
简体中文
Quick Start
·
Report Bug
·
Propose Feature
Official Web APP
·
Documentation
Check official documentation website
npm install chatnio-node
# or using yarn, pnpm
yarn add chatnio-node
chatnio-node and write the source file test.js// test.mjs
import {setKey, Chat} from "chatnio-node"
// Place your API Key here. Don't do this in code that will be published to public
setKey("{{ API Key }}")
const chat = new Chat()
const res = await chat.ask({
message: "hello! What's your name?"
})
console.log(res)
process.exit(0)
:warning: For security, you should not place your API Key directly in your source code, but use envrionment variables or .env file in your app.
node test.mjs
{
message: "Hello! I am OpenAI's language model, known as GPT-3. I don't have a specific name, but you can call me GPT-3 or AI. How can I assist you today?",
keyword: '',
quota: 0.000255
}
import { Chat } from 'chatnio-node';
// or
const { Chat } = require("chatnio-node")
[↑ 回到顶部]
import { setKey, setEndpoint } from 'chatnio-node';
// set your API Key
setKey("sk-...");
// set custom api endpoint (default: https://api.chatnio.net)
// setEndpoint("https://example.com/api");
import { Chat } from 'chatnio-node';
const chat = new Chat(-1); // id -1 (default): create new conversation
// using stream
chat.askStream({
message: "hello world",
model: "gpt-3.5-turbo-0613", // default gpt-3
web: false
}, (res) => {
console.log(res);
});
// don't use stream
chat.ask({ message: "hi" })
.then(res => {
console.log(res);
})
.catch(err => {
console.log(err);
});
import { getConversations, getConversation, deleteConversation } from 'chatnio-node';
// 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);
import { getQuota, buyQuota } from 'chatnio-node';
// get quota
const quota = await getQuota();
// buy quota
const state = await buyQuota(100);
import { getPackage, getSubscription, buySubscription } from 'chatnio-node';
// get package
const pkg = await getPackage();
// get subscription
const subscription = await getSubscription();
// buy subscription
const state = await buySubscription(1, 1);
Get Conversation Content
:bulb: For each new conversation, the first message received will be used as the conversation's name.
:warning:Although the getConversations() interface returns a data type of Conversation[], the message field of each Conversation is null . To obtain the complete history of a conversation, load the conversation by getConversation(id) interface.
import {Chat, getConversation, getConversations, setKey} from 'chatnio-node'
setKey("")
const msg1 = "Hello! My name is chat-nio."
const msg2 = "What's my name?"
// Create a new conversation. The first message received will be used as the conversation's name.
const chat = new Chat(-1)
let res = await chat.ask({
message: msg1
})
console.log(res);
res = await chat.ask({
message: msg2
})
console.log(res);
// Get the list of recent conversations, use the name to filter out conversation, and find the ID
const conversations = await getConversations();
const id = conversations.find(conv => conv.name === msg1).id
// Retrieve detailed conversation information by id
const conversation = await getConversation(id)
console.log(conversation);
// exit the program
process.exit(0)
Output may look like:
{
message: 'Hello chat-nio! How can I assist you today?',
keyword: '',
quota: 0.00156
}
{ message: 'Your name is chat-nio.', keyword: '', quota: 0.002385 }
{
auth: false,
user_id: 4470,
id: 45,
name: 'Hello! My name is chat-nio.',
message: [
{ srole: 'user', content: 'Hello! My name is chat-nio.' },
{ role: 'assistant', content: 'Hello chat-nio! How can I assist you today?' },
{ role: 'user', content: "What's my name?" },
{ role: 'assistant', content: 'Your name is chat-nio.' }
],
model: 'gpt-3.5-turbo',
enable_web: false,
shared: false,
context: 0
}
Use tsc to build
npm run build
# or
yarn run build
Check API 快速入门 - Chat Nio for detailed
Default is gpt-3.5-turbo if you don’t specified.
Check api.chatnio.net/v1/models for all available models.
Official repository:Deeptrain-Community/chatnio
Other SDK:
FAQs
A forked Javascript/Typescript library for the Chat Nio API on Node.
The npm package chatnio-node receives a total of 1 weekly downloads. As such, chatnio-node popularity was classified as not popular.
We found that chatnio-node demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.