@ant-design/x-sdk

中文文档
2.10.0发布于 2026/10/29MITTypeScriptESM + CJS近 30 天下载 8.1万

placeholder for @ant-design/x-sdk

原始使用文档
文档目录8 节
  1. Introduction
  2. 📦 Installation
  3. Browser Import
  4. Example
  5. 🌈 Enterprise-level LLM Components Out of the Box
  6. ✨ Markdown Renderer
  7. How to Contribute
  8. Community Support

Ant Design X SDK

Efficiently manage large model data streams

CI status codecov NPM version

NPM downloads antd Follow zhihu

Changelog · Report a Bug · Request a Feature · English · 中文

Introduction

@ant-design/x-sdk provides a set of tool APIs designed to help developers manage AI conversation application data flows out of the box.

📦 Installation

npm install @ant-design/x-sdk
yarn add @ant-design/x-sdk
pnpm add @ant-design/x-sdk
ut install @ant-design/x-sdk

Browser Import

Use script and link tags to directly import files in the browser, and use the global variable XSDK.

We provide x-sdk.js, x-sdk.min.js, and x-sdk.min.js.map in the dist directory of the npm package.

Strongly not recommended to use built files, as this prevents on-demand loading and makes it difficult to get quick bug fixes for underlying dependency modules.

Note: x-sdk.js, x-sdk.min.js, and x-sdk.min.js.map depend on react and react-dom. Please ensure these files are imported in advance.

Example

import React from 'react';
import { XRequest } from '@ant-design/x-sdk';

export default () => {
  const [status, setStatus] = React.useState('');
  const [lines, setLines] = React.useState<Record<string, string>[]>([]);

  React.useEffect(() => {
    setStatus('pending');

    XRequest('https://api.example.com/chat', {
      params: {
        model: 'gpt-3.5-turbo',
        messages: [{ role: 'user', content: 'hello, who are u?' }],
        stream: true,
      },
      callbacks: {
        onSuccess: (messages) => {
          setStatus('success');
          console.log('onSuccess', messages);
        },
        onError: (error) => {
          setStatus('error');
          console.error('onError', error);
        },
        onUpdate: (msg) => {
          setLines((pre) => [...pre, msg]);
          console.log('onUpdate', msg);
        },
      },
    });
  }, []);

  return (
    <div>
      <div>Status: {status}</div>
      <div>Lines: {lines.length}</div>
    </div>
  );
};

🌈 Enterprise-level LLM Components Out of the Box

@ant-design/x provides a rich set of atomic components for different interaction stages based on the RICH interaction paradigm, helping you flexibly build your AI applications. See details here.

✨ Markdown Renderer

@ant-design/x-markdown aims to provide a streaming-friendly, highly extensible, and high-performance Markdown renderer. It supports streaming rendering of formulas, code highlighting, mermaid, and more. See details here.

How to Contribute

Before participating in any form, please read the Contributor Guide. If you wish to contribute, feel free to submit a Pull Request or report a Bug.

We highly recommend reading How To Ask Questions The Smart Way, How to Ask Questions in Open Source Community, How to Report Bugs Effectively, and How to Submit Unanswerable Questions to Open Source Projects. Better questions are more likely to get help.

Community Support

If you encounter problems during use, you can seek help through the following channels. We also encourage experienced users to help newcomers through these channels.

When asking questions on GitHub Discussions, it is recommended to use the Q&A tag.

  1. GitHub Discussions
  2. GitHub Issues
Contribution Leaderboard

版本与发布记录

@ant-design/x-sdk 共发布 41 个版本,首次发布于 2025/08/05;过去 12 个月发布了 27 个版本。

版本发布日期距今
2.10.0latest2026/10/297 天前
2.9.02026/07/283 个月前
2.8.02026/06/084 个月前
2.7.02026/04/306 个月前
2.6.0beta2026/04/176 个月前
2.5.02026/03/317 个月前

其他发布通道:alpha → 2.0.0-alpha.16,beta → 2.6.0。

关于 @ant-design/x-sdk 的常见问题

@ant-design/x-sdk 是什么?

placeholder for @ant-design/x-sdk

如何安装 @ant-design/x-sdk?

在项目目录运行 npm install @ant-design/x-sdk,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=18.0.0)、react-dom(>=18.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@ant-design/x-sdk 支持 TypeScript 吗?

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

@ant-design/x-sdk 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@ant-design/x-sdk 可以商用吗?

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

@ant-design/x-sdk 的下载量有多少?

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

@ant-design/x-sdk 还在维护吗?

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