New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

tbox-nodejs-sdk

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tbox-nodejs-sdk

## Installation

latest
Source
npmnpm
Version
0.0.19
Version published
Weekly downloads
934
-39.47%
Maintainers
1
Weekly downloads
 
Created
Source

Tbox Node.js SDK

Installation

npm install tbox-nodejs-sdk

Usage

Initialize client

import { TboxClient } from "tbox-nodejs-sdk";

const client = new TboxClient({
  httpClientConfig: {
    authorization: "TBox-your-token-xxx",
  },
});

Stream chat

const emitter = client.chat({
  appId: "your-app-id",
  query: "今天杭州天气怎么样?",
  userId: "user123",
});

emitter.on("data", (data) => {
  console.log("Received data:", data);
});

emitter.on("end", () => {
  console.log("Stream ended");
});

emitter.on("error", (error) => {
  console.error("Stream error:", error);
});

emitter.on("abort", () => {
  console.log("Stream aborted");
});

// To abort the stream
emitter.abort();

Note: After calling emitter.abort(), the stream will be immediately terminated and no further data events will be emitted. An abort event will be triggered to notify that the stream has been aborted.

Sync chat

const response = await client.chatSync({
  appId: "your_app_id",
  query: "今天杭州天气怎么样?",
  userId: "user123",
});

Completion

const emitter = client.completion({
  appId: "your-app-id",
  inputs: { text: "苹果" },
  userId: "user123",
});

emitter.on("data", (response) => {
  console.log("Received completion data:", response);
});

emitter.on("end", () => {
  console.log("Completion stream ended");
});

emitter.on("error", (error) => {
  console.error("Error in completion:", error);
});

emitter.on("abort", () => {
  console.log("Completion aborted");
});

// To abort the completion
emitter.abort();

Note: After calling emitter.abort(), the completion stream will be immediately terminated and no further data events will be emitted. An abort event will be triggered to notify that the stream has been aborted.

FAQs

Package last updated on 19 Dec 2025

Did you know?

Socket

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.

Install

Related posts