@blazingagents/sdk

中文文档
0.47.0发布于 2026/11/08MITTypeScriptES Module构建来源已验证近 30 天下载 4673

TypeScript SDK for the Blazing Agents API

原始使用文档
文档目录7 节
  1. Features
  2. Installation
  3. Quick start
  4. Examples
  5. Documentation
  6. Development
  7. License
Blazing Agents logo

Blazing Agents TypeScript SDK

Build production agents with a typed TypeScript client for the Blazing Agents API.

Documentation · npm

The official TypeScript SDK is a client for the Blazing Agents /v1 API that your backend uses to manage Agents and run them for your users. It requires Node.js 24 or newer.

Features

  • A typed method for every /v1 operation an API key can call: Agents, Skills, Sessions, Memories, Prompts, Tasks, Workspaces, Artifacts, Providers, MCP Connections, Chat Connections, usage, spending limits, Tenant settings, and merchant monetization.
  • Chat streams in the AI SDK UI message stream format, with steering, Tool approvals, and backend functions that run in your process.
  • Text and structured-object generation.
  • End-user scoped clients through forUser.
  • Cursor pagination, uploads, and downloads.
  • Request IDs and typed errors.
  • BlazingAgentsChatTransport and createChatRelay connect AI SDK useChat to your backend.

Installation

npm install @blazingagents/sdk ai@^7.0.84 zod@^4.5.4

ai and zod are required peer dependencies. The SDK re-exports AI SDK message types and Zod schemas, so your app and the SDK share one copy of each.

Quick start

Create a Full API key in the Blazing Agents dashboard and set BLAZING_AGENTS_API_KEY in your server environment. The key acts for your whole Tenant, so keep it on your backend and never send it to a browser.

import { BlazingAgents } from "@blazingagents/sdk";

const client = new BlazingAgents({
  apiKey: process.env.BLAZING_AGENTS_API_KEY!,
});

const result = await client.completion({
  agentId: "ag_...",
  prompt: "Write a friendly welcome message.",
});

console.log(await result.text);

Replace ag_... with an Agent ID from the dashboard.

For requests from your users, scope the client to the user ID that your backend verified at sign-in, never to an ID from the request body. A scoped client reaches only that End-user's Agents, Sessions, and Workspace. An unscoped Agent shares one Workspace across all your users, so give each user an Agent of their own:

export async function createAgentForUser(userId: string): Promise<string> {
  const agent = await client.forUser(userId).agents.create({
    name: "Assistant",
    providerId: "prv_...",
    model: "openai/gpt-6-luna",
  });
  return agent.id;
}

export async function chatAsUser(
  userId: string,
  agentId: string,
  text: string
): Promise<Response> {
  const chat = await client.forUser(userId).chat({
    agentId,
    message: {
      id: crypto.randomUUID(),
      role: "user",
      parts: [{ type: "text", text }],
    },
  });
  return chat.toResponse();
}

Call createAgentForUser once per user and store the Agent ID with the user. A scoped chat with an Agent created without the scope fails with 404. chatAsUser returns the chat as a streaming Response. To chat from the browser with useChat, serve createChatRelay from your backend and use BlazingAgentsChatTransport. The relay scopes each request to the user that your resolveContext returns.

Examples

The examples repository has complete TypeScript and Python apps built on the Blazing Agents SDKs.

Documentation

Read the TypeScript SDK documentation for client setup, End-user scoping, chat and generation, a guide to each resource, and error handling.

Development

npm ci
npm run check
npm run test:consumer

See CONTRIBUTING.md for the changelog convention and how to release.

License

MIT

版本与发布记录

@blazingagents/sdk 共发布 56 个版本,首次发布于 2026/09/01;过去 12 个月发布了 56 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.47.0latest2026/11/08今天
0.46.02026/10/309 天前
0.45.02026/10/2712 天前
0.44.02026/10/2514 天前
0.43.12026/10/2316 天前
0.43.02026/10/2216 天前

关于 @blazingagents/sdk 的常见问题

@blazingagents/sdk 是什么?

TypeScript SDK for the Blazing Agents API

如何安装 @blazingagents/sdk?

在项目目录运行 npm install @blazingagents/sdk,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:ai(^7.0.84)、zod(^4.5.4)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@blazingagents/sdk 支持 TypeScript 吗?

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

@blazingagents/sdk 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@blazingagents/sdk 需要什么版本的 Node.js?

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

@blazingagents/sdk 可以商用吗?

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

@blazingagents/sdk 的下载量有多少?

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

@blazingagents/sdk 还在维护吗?

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