@copilotkit/vue

中文文档
1.87.0发布于 2026/11/12MITTypeScriptESM + CJS构建来源已验证近 30 天下载 5.5万

Vue 3 components and composables for CopilotKit

原始使用文档
文档目录5 节
  1. Installation
  2. Quick start
  3. Imports and compatibility
  4. Generative UI
  5. Documentation

@copilotkit/vue

Vue 3 components and composables for connecting an app to CopilotKit Runtime and rendering agent chat UI. The package includes CopilotKitProvider, CopilotChat, CopilotSidebar, CopilotPopup, and composables for agents, tools, context, suggestions, threads, interrupts, and custom rendering.

Installation

npm install @copilotkit/vue

The package requires Vue 3.3 or newer. Your app also needs a Copilot Runtime endpoint, such as /api/copilotkit. If you host the runtime yourself, install @copilotkit/runtime in the server project.

Quick start

<!-- App.vue -->
<script setup lang="ts">
import { CopilotChat, CopilotKitProvider } from "@copilotkit/vue/v2";
import "@copilotkit/vue/styles.css";
</script>

<template>
  <CopilotKitProvider runtime-url="/api/copilotkit">
    <main style="height: 100dvh">
      <CopilotChat />
    </main>
  </CopilotKitProvider>
</template>

Import @copilotkit/vue/styles.css once in your app. CopilotChat uses the provider's default agent when agent-id is omitted. The chat fills its parent, so give that container a height.

Imports and compatibility

Use the /v2 subpath for new code:

import {
  CopilotChat,
  CopilotKitProvider,
  useFrontendTool,
} from "@copilotkit/vue/v2";

The root import, @copilotkit/vue, re-exports the v2 API and keeps compatibility wrappers for CopilotKit, useCopilotAction, useFrontendTool, and useCopilotReadable. The legacy tool wrappers accept Parameter[] definitions. Use /v2 for the current Standard Schema tool APIs, including Zod, Valibot, and ArkType schemas.

In Vue templates, camelCase props become kebab-case attributes. For example, runtimeUrl is written as runtime-url, and boolean or object props use : bindings such as :enable-inspector="false". Vue rendering customization uses named and scoped slots where React uses render props.

Generative UI

A text answer is often the wrong answer. With generative UI, the agent renders cards, tables, forms, and charts in the chat. Give the provider a catalog of components:

<!-- App.vue -->
<script setup lang="ts">
import { CopilotChat, CopilotKitProvider } from "@copilotkit/vue/v2";
import { standardUI } from "@copilotkit/vue/v2/generative-ui";
import "@copilotkit/vue/styles.css";
</script>

<template>
  <CopilotKitProvider
    runtime-url="/api/copilotkit"
    :generativeUI="{ ui: standardUI }"
  >
    <main style="height: 100dvh">
      <CopilotChat />
    </main>
  </CopilotKitProvider>
</template>

Write the binding in camelCase: :generativeUI. Vue reads :generative-ui as a different prop, so the provider does not get the catalog.

standardUI is the standard catalog. To let the agent render your own components, build a catalog with createGenerativeUI.

Charts and maps use optional libraries. Without them, a chart shows a table and a map shows a list of places. To draw charts and maps:

  1. Install the libraries: npm install chart.js maplibre-gl.
  2. Add the plugins in your app entry:
import { createApp } from "vue";
import { GenerativeUIChart } from "@copilotkit/vue/v2/generative-ui/chart";
import { GenerativeUIMap } from "@copilotkit/vue/v2/generative-ui/map";
import App from "./App.vue";

createApp(App).use(GenerativeUIChart).use(GenerativeUIMap).mount("#app");

Now ask the agent to compare three phone plans. It can answer with a table in the chat.

Read the generative UI guide for your own components, page surfaces, and theming.

Documentation

The full Vue docs cover runtime setup, prebuilt chat components, composables, tools, threads, interrupts, attachments, voice, and customization.

版本与发布记录

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

版本发布日期距今
1.87.0latest2026/11/12今天
2.0.0-rc.41next2026/11/11今天
1.86.02026/11/11今天
2.0.0-rc.402026/11/11今天
2.0.0-rc.392026/11/101 天前
2.0.0-rc.382026/11/101 天前

其他发布通道:canary → 1.84.2-canary.openbot-intel-fixes,next → 2.0.0-rc.41。

关于 @copilotkit/vue 的常见问题

@copilotkit/vue 是什么?

Vue 3 components and composables for CopilotKit

如何安装 @copilotkit/vue?

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

@copilotkit/vue 支持 TypeScript 吗?

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

@copilotkit/vue 支持 ESM 还是 CommonJS?

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

@copilotkit/vue 需要什么版本的 Node.js?

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

@copilotkit/vue 可以商用吗?

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

@copilotkit/vue 的下载量有多少?

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

@copilotkit/vue 还在维护吗?

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