@convokit/server

中文文档
0.1.1发布于 2026/02/26MITTypeScriptCommonJS零依赖近 30 天下载 2479

ConvoKit server SDK — secure server-to-server chat using your secret API key

原始使用文档
文档目录9 节
  1. Installation
  2. Usage
  3. TypeScript
  4. Conversation history
  5. Options
  6. Response
  7. Security
  8. Early access
  9. License

@convokit/server

ConvoKit is currently in early access. The waitlist is live — join at convokit.dev to get early access.

Server SDK for ConvoKit — send AI chat messages from your server using your secret API key. The key never leaves your backend, making this more secure than using a public key in the browser.

Website: convokit.dev


Installation

npm install @convokit/server

Usage

const { createClient } = require('@convokit/server');

const client = createClient(process.env.CONVOKIT_SECRET_KEY); // sk_live_...

// New conversation
const { reply, conversation_id } = await client.chat({
  message: 'What are your support hours?',
});
console.log(reply);

// Follow-up in the same thread
const { reply: reply2 } = await client.chat({
  message: 'And on weekends?',
  conversationId: conversation_id,
});
console.log(reply2);

TypeScript

import { createClient, type ChatOptions, type ChatResponse } from '@convokit/server';

const client = createClient({ apiKey: process.env.CONVOKIT_SECRET_KEY! });

const res: ChatResponse = await client.chat({
  message: 'Hello',
  instanceId: 'my-bot',
  chatHistory: [],
});

Conversation history

Pass previous messages so the AI has context:

const { reply } = await client.chat({
  message: 'What did I just ask?',
  chatHistory: [
    { role: 'user', content: 'What are your support hours?' },
    { role: 'assistant', content: 'We are open 9am–5pm Monday to Friday.' },
  ],
});

Format: { role: 'user' | 'assistant' | 'system', content: string }.

When you have a conversationId, you can omit chatHistory — the backend already has the thread.


Options

OptionRequiredDescription
messageYesThe user message to send
conversationIdNoUse for follow-up messages in the same thread
widgetIdNoIdentifier for grouping (e.g. bot name, channel)
chatHistoryNoPrevious messages for context

Response

FieldDescription
replyAI reply text
conversation_idPass this in the next message to continue the thread
usageToken usage — prompt_tokens, completion_tokens, total_tokens

Security

  • Use a secret key (sk_live_...) on your server only. Never expose it in browser or client-side code.
  • For browser / widget use, use a public key (pk_live_...) with the @convokit/widget package.

Early access

ConvoKit is in early access. Get your API keys and configure your AI at convokit.dev.

The waitlist is live — join now to get early access.


License

MIT

版本与发布记录

@convokit/server 共发布 2 个版本,首次发布于 2026/02/26;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.1.1latest2026/02/268 个月前
0.1.02026/02/268 个月前

关于 @convokit/server 的常见问题

@convokit/server 是什么?

ConvoKit server SDK — secure server-to-server chat using your secret API key

如何安装 @convokit/server?

在项目目录运行 npm install @convokit/server,或使用 pnpm add / yarn add / bun add。

@convokit/server 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@convokit/server 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@convokit/server 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@convokit/server 可以商用吗?

@convokit/server 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@convokit/server 的下载量有多少?

根据 npm 官方下载统计,@convokit/server 在 2026/10/11 – 2026/11/09 这 30 天内被下载 2,479 次,日均约 83 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@convokit/server 还在维护吗?

最新版本 0.1.1 发布于 2026/02/26(8 个月前);至今共发布 2 个版本,其中过去 12 个月发布了 2 个;首次发布于 2026/02/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。