🧰 AgentKits
Agent Model Layer — 一行代码接入 LLM,自带记忆 · One-line LLM access with built-in memory

29 个大模型 · 18 个向量化引擎 · 40+ 功能模块 · 零锁定
Quick Start · Providers · Modules
为什么选择 AgentKits?
AgentKits 是 The Self-Evolving Agent Stack 中的 Agent Model Layer——一行代码接入任意 LLM,自带记忆。
开发者使用路径:① 选模板 (Agent Templates) → ② 接模型 (Agent Model Layer) → ③ 跑起来 (Agent Runtime) → ④ 自动进化 (Agent Memory)。
构建 AI 智能体不应被锁定在单一供应商。AgentKits 提供统一接口,覆盖 29 个大模型和 18 个向量化引擎。切换模型只需改一个配置,无需重写代码。
核心差异:withBrain() 记忆集成。 每次 LLM 调用自动串联 DeepBrain 记忆——调用前 recall() 检索相关知识,调用后 learn() 存储新经验。你的 Agent 不再是无状态的 API 调用,而是一个持续自进化的智能体。
🔄 自进化飞轮:Templates 自带 Brain Seed → Model Layer 每次调用自动 learn → Runtime 持续运行 → Memory 自动 evolve → Agent 越来越强。
import { createChat } from 'agentkits';
import { Brain, AgentBrain } from 'deepbrain';
const chat = createChat({ provider: 'deepseek' });
const reply = await chat.complete('解释量子计算');
const brain = new Brain({ database: './brain.db' });
const agentBrain = new AgentBrain(brain, 'my-agent');
const smartChat = chat.withBrain(agentBrain);
const smartReply = await smartChat.complete('解释量子计算');
🇨🇳 深度支持中国大模型生态:通义千问、智谱AI、月之暗面、零一万物、硅基流动、阶跃星辰、百川智能、DeepSeek深度求索、MiniMax — 一等公民,不是附加品。
快速开始 Quick Start
npm install agentkits
对话补全 Chat
import { createChat } from 'agentkits';
const chat = createChat({ provider: 'deepseek', model: 'deepseek-chat' });
const reply = await chat.complete('你好!');
for await (const chunk of chat.stream('给我讲个故事')) {
process.stdout.write(chunk.content ?? '');
}
向量化 Embedding
import { createEmbedding } from 'agentkits';
const emb = createEmbedding({ provider: 'dashscope' });
const vector = await emb.embed('语义搜索');
const batch = await emb.embedBatch(['文档1', '文档2', '文档3']);
函数调用 Tool Calling
import { createToolChat, defineTool } from 'agentkits';
const weather = defineTool({
name: 'get_weather',
description: '获取城市天气',
parameters: { type: 'object', properties: { city: { type: 'string' } }, required: ['city'] },
handler: async ({ city }) => `${city}:晴,25°C`,
});
const chat = createToolChat({ provider: 'zhipu', tools: [weather] });
const result = await chat.run('北京今天天气怎么样?');
工作流引擎 Workflow
import { createWorkflow } from 'agentkits';
const workflow = createWorkflow({
name: 'research-pipeline',
startStep: 'search',
steps: [
{
id: 'search', type: 'tool',
tool: { name: 'search', handler: async (input) => await searchWeb(input.query) },
input: (ctx) => ({ query: ctx.variables.topic }),
output: 'searchResults', next: 'summarize',
},
{
id: 'summarize', type: 'llm',
llm: { provider: 'deepseek', prompt: '总结以下内容:{{searchResults}}' },
output: 'summary',
},
],
});
MCP 客户端
import { createMCPClient } from 'agentkits';
const mcp = await createMCPClient({ serverUrl: 'http://localhost:3001/sse' });
const tools = await mcp.listTools();
const result = await mcp.callTool('search', { query: 'hello' });
A2A 协议(Agent-to-Agent)
import { createA2AClient, createA2AServer } from 'agentkits';
const client = createA2AClient({ baseUrl: 'http://localhost:8080' });
const card = await client.getAgentCard();
const task = await client.sendTask({
id: 'task-1',
message: { role: 'user', parts: [{ type: 'text', text: '研究AI趋势' }] },
});
可运行示例 Runnable Examples
examples/ 目录提供 6 个开箱即用的 .mjs 示例,node 直接运行:
export GEMINI_API_KEY=your-key
node examples/chat-basic.mjs
node examples/chat-stream.mjs
node examples/embedding-search.mjs
node examples/rag-pipeline.mjs
node examples/multi-provider.mjs
node examples/benchmark.mjs --providers gemini,deepseek,groq
大模型供应商 LLM Providers (29)
| OpenAI | — | GPT-4o, GPT-4o-mini, o1, o3 | ✅ | ✅ | ✅ |
| Gemini | — | Gemini 2.0/1.5 Pro/Flash | ✅ | ✅ | ✅ |
| DeepSeek | 深度求索 | DeepSeek-V3, R1 | ✅ | ✅ | ❌ |
| DashScope | 通义千问 | Qwen-Max/Plus/Turbo | ✅ | ✅ | ✅ |
| Zhipu | 智谱AI | GLM-4, GLM-4V | ✅ | ✅ | ✅ |
| Moonshot | 月之暗面 (Kimi) | moonshot-v1 | ✅ | ✅ | ❌ |
| Yi | 零一万物 | Yi-Large | ✅ | ✅ | ❌ |
| Baichuan | 百川智能 | Baichuan-4 | ✅ | ✅ | ❌ |
| SiliconFlow | 硅基流动 | 多模型聚合 | ✅ | ✅ | ❌ |
| StepFun | 阶跃星辰 | Step-2 | ✅ | ✅ | ❌ |
| MiniMax | MiniMax | abab6.5s | ✅ | ✅ | ❌ |
| Grok | — | grok-2 | ✅ | ✅ | ❌ |
| Cohere | — | Command R+ | ✅ | ✅ | ❌ |
| Fireworks | — | FireFunction, Mixtral | ✅ | ✅ | ❌ |
| Together | — | Llama, Mixtral | ✅ | ✅ | ❌ |
| Groq | — | Llama, Mixtral | ✅ | ✅ | ❌ |
| Perplexity | — | Sonar | ✅ | ❌ | ❌ |
| Ollama | 本地部署 | 任意本地模型 | ✅ | ✅ | ✅ |
| Custom | 自定义 | 任意 OpenAI 兼容 | ✅ | ✅ | ✅ |
向量化引擎 Embedding Providers (18)
| OpenAI | — | text-embedding-3-small/large, ada-002 | 256–3072 |
| Gemini | — | text-embedding-004 | 768 |
| DashScope | 通义千问 | text-embedding-v3 | 1024 |
| DeepSeek | 深度求索 | (兼容接口) | 可变 |
| Zhipu | 智谱AI | embedding-3 | 2048 |
| SiliconFlow | 硅基流动 | 多模型 | 可变 |
| Cohere | — | embed-v3 | 1024 |
| Jina | — | jina-embeddings-v3 | 1024 |
| Voyage | — | voyage-3 | 1024 |
| Mixedbread | — | mxbai-embed-large | 1024 |
| Nomic | — | nomic-embed-text | 768 |
| Fireworks | — | nomic, thenlper | 可变 |
| Together | — | 多模型 | 可变 |
| Ollama | 本地部署 | 任意本地模型 | 可变 |
| Custom | 自定义 | 任意兼容接口 | 可变 |
模块目录 Module Catalog
核心 Core
| 大模型对话 | agentkits/llm | 统一对话补全接口,支持 29 个供应商 |
| 向量化 | agentkits/embedding | 统一向量化接口,支持 18 个引擎 |
| 流式输出 | agentkits/streaming | SSE 解析、流组合、中断控制 |
| 结构化输出 | agentkits/structured | JSON Schema 校验的 LLM 输出 |
| 函数调用 | agentkits/function-calling | 跨供应商的函数/工具调用格式转换 |
智能体构建 Agent Building
| Agent 循环 | agentkits/agent | ReAct 风格智能体,支持工具调用循环 |
| 工具调用 | agentkits/tools | 定义和执行工具,适配任意大模型 |
| 多轮对话 | agentkits/conversation | 多轮对话管理,滑动窗口 |
| Agent 记忆 | agentkits/agent-memory | 短期/长期记忆,自动摘要 |
| 提示词模板 | agentkits/prompt-template | Handlebars 风格模板引擎 |
| 安全护栏 | agentkits/guardrails | 输入输出校验、内容过滤、PII 检测 |
RAG 检索增强生成
| RAG 管线 | agentkits/rag | 完整的检索-增强-生成管线 |
| 重排序 | agentkits/rerank | API 重排序(Cohere、Jina 等) |
| 本地重排 | agentkits/reranker | Cross-encoder 本地重排序 |
| 网页搜索 | agentkits/web-search | Brave、Tavily、Serper、SearXNG |
| PDF 解析 | agentkits/pdf-parser | PDF 文本提取与分块 |
| 文本分块 | agentkits/chunker | 智能分块(固定、句子、递归、语义) |
多模态 Multimodal
| 视觉理解 | agentkits/vision | 跨供应商图像理解 |
| 语音合成 | agentkits/tts | TTS(OpenAI、Azure、ElevenLabs) |
| 语音识别 | agentkits/stt | STT 语音转文字 |
| 图像生成 | agentkits/image | DALL-E、Stability 等 |
基础设施 Infrastructure
| 故障转移 | agentkits/failover | 自动供应商切换与健康检测 |
| 智能路由 | agentkits/router | 按成本、速度、能力路由请求 |
| 模型路由 | agentkits/model-router | 高级路由:模型画像与规则引擎 |
| 限流器 | agentkits/ratelimit | Token bucket 限流 |
| 供应商限流 | agentkits/rate-limiter | 按供应商限流(内置默认值) |
| 响应缓存 | agentkits/response-cache | LRU + TTL 缓存 |
| 重试 | agentkits/retry | 指数退避 + 抖动 |
| 成本计算 | agentkits/cost | 跨供应商定价对比 |
| Token 计数 | agentkits/token-counter | 按模型精确计数 |
| 代理服务器 | agentkits/proxy | OpenAI 兼容代理 |
| 性能基准 | agentkits/benchmark | 供应商延迟与吞吐量基准测试 |
| 供应商测试 | agentkits/test | 一键检测已配置供应商的连通性 |
| 日志 | agentkits/logger | 结构化日志 |
| 链路追踪 | agentkits/tracing | OpenTelemetry 兼容分布式追踪 |
| 代码解释器 | agentkits/code-interpreter | 沙箱代码执行(JS、Python、Shell) |
| 模型评估 | agentkits/evaluation | 多模型输出对比:延迟、成本、质量 |
协议与互操作 Protocol & Interop
| MCP 客户端 | agentkits/mcp-client | 连接 MCP 服务器,自动转换工具定义 |
| 工作流引擎 | agentkits/workflow | 多步骤工作流:分支、并行、重试 |
| A2A 协议 | agentkits/a2a | Google A2A 智能体间通信 |
CLI 命令行
npx agentkits chat [--provider P] [--model M]
npx agentkits embed "文本" [--provider P]
npx agentkits benchmark [--providers a,b,c] [--runs N]
npx agentkits test
npx agentkits cost
npx agentkits serve [--port N]
npx agentkits list
npx agentkits mcp connect <url>
🔄 双闭环知识系统 (Dual-Loop Knowledge)
AgentKits 通过 withBrain() 自动参与双闭环知识系统:
┌─────────────────────────────────────────────────────┐
│ 小闭环(本地,免费) │
│ Agent 本地 learn → recall → evolve │
│ 离线也能用,数据完全在你手里 │
│ │
│ 大闭环(Hub,增值) │
│ Agent ↔ Workstation Hub 知识共享 │
│ 集体智慧 > 个体经验,新 Agent 站在前人肩膀上 │
└─────────────────────────────────────────────────────┘
本地是主人,Hub 是助手——没有网络也能用,联网后自动同步和进化。
agentkits (Model Layer) — 调 LLM ← 你在这里
↕
opc-agent (Runtime) — 跑 Agent(本地)
↕
deepbrain (Memory Engine) — 存知识(引擎)
↕
agent-workstation (Knowledge Platform) — 知识生命周期(Hub)
📊 竞品对比 / Comparison
✅ = 支持,🔶 = 部分支持/需额外配置,❌ = 不支持
| 定位 | Agent Model Layer(一行代码接 LLM + 自带记忆) | LLM 统一网关/代理 | AI 应用 SDK (React) | API 聚合市场 | AI 全栈框架 |
| 语言 | TypeScript | Python | TypeScript | REST API | Python (TS 有限) |
| LLM Provider 数 | 29 | 100+ | 20+ | 500+ / 60 提供商 | 50+ |
| Embedding Provider 数 | 18 | 🔶 主流 | 🔶 几个 | ❌ | 🔶 主流 |
| 中国模型深度支持 | ✅ 9 家一等公民 | 🔶 兼容 API | ❌ 有限 | 🔶 部分 | 🔶 兼容 API |
| 记忆增强 (withBrain) | ✅ 自动 recall + learn | ❌ | ❌ | ❌ | 🔶 Memory 模块 |
| Function Calling | ✅ 跨供应商统一 | ✅ | ✅ 类型安全 | 🔶 取决于模型 | ✅ |
| Streaming | ✅ SSE+流组合+中断 | ✅ | ✅ | ✅ | ✅ |
| 结构化输出 | ✅ JSON Schema | 🔶 透传 | ✅ Zod | 🔶 透传 | ✅ |
| Agent 循环 (ReAct) | ✅ 内置 | ❌ 纯路由 | 🔶 SDK 6 Agent | ❌ 纯路由 | ✅ LangGraph |
| 工作流引擎 | ✅ 分支+并行 | ❌ | ❌ | ❌ | ✅ LangGraph |
| RAG Pipeline | ✅ 完整+重排序 | ❌ | ❌ | ❌ | ✅ |
| MCP Client | ✅ | ❌ | 🔶 | ❌ | 🔶 |
| A2A 协议 | ✅ Google A2A | ❌ | ❌ | ❌ | ❌ |
| Cost 计算 | ✅ 跨供应商对比 | ✅ 内置 | 🔶 token 监控 | ✅ 账单统一 | ❌ |
| Token 计数 | ✅ 按模型精确 | 🔶 | 🔶 | 🔶 | 🔶 |
| 错误重试 | ✅ 指数退避+抖动 | ✅ 自动故障转移 | ❌ | ✅ 自动 fallback | 🔶 |
| 智能路由 | ✅ 成本/速度路由 | ✅ 负载均衡 | ❌ | ✅ 智能路由 | ❌ |
| 缓存 | ✅ LRU + TTL | ✅ 语义缓存 | ❌ | ❌ | 🔶 |
| 限流 | ✅ Token Bucket | ✅ | ❌ | ❌ | ❌ |
| Vision | ✅ 跨供应商 | ✅ | 🔶 | 🔶 | 🔶 |
| TTS / STT | ✅ 3 家 | ✅ 标准端点 | ❌ | ❌ | ❌ |
| 图像生成 | ✅ DALL-E 等 | ✅ | 🔶 | ❌ | ❌ |
| 代码解释器 | ✅ 沙箱 JS/Py/Shell | ❌ | ❌ | ❌ | 🔶 |
| 安全护栏 | ✅ PII+内容过滤 | ✅ 关键词+正则 | ❌ | ❌ | 🔶 |
| 可观测性 (OTel) | ✅ 分布式追踪 | ✅ 多平台 | 🔶 | ❌ | 🔶 LangSmith |
| Benchmark | ✅ 延迟+吞吐量 | ❌ | ❌ | ❌ | ❌ |
| OpenAI 兼容代理 | ✅ agentkits serve | ✅ 核心功能 | ❌ | ✅ | ❌ |
| TypeScript 原生 | ✅ | ❌ Python | ✅ | REST API | ❌ Python |
| 许可证 | Apache-2.0 | Apache-2.0 | Apache-2.0 | 专有 (API 服务) | MIT |
AgentKits 独有优势:TypeScript 原生 + 中国模型一等公民 (9 家) + withBrain() 自进化记忆(每次 LLM 调用自动 recall + learn,Agent 越用越聪明) + Agent + RAG + Workflow + A2A 一体化。作为 The Self-Evolving Agent Stack 的 Agent Model Layer,一行代码接入 LLM,自带记忆。
对比基于各项目公开文档(截至 2026 年 4 月),如有偏差欢迎 Issue 指正。
架构 Architecture
┌──────────────────────────────────────────────────────────┐
│ 你的应用 Your App │
├──────────────────────────────────────────────────────────┤
│ Agent 循环 │ 工作流 │ RAG │ 工具 │ 多轮对话 │
├──────────────────────────────────────────────────────────┤
│ 安全护栏 │ 记忆 │ 结构化输出 │ 提示词模板 │
├──────────────────────────────────────────────────────────┤
│ 路由 │ 故障转移 │ 缓存 │ 限流 │ 重试 │
├──────────────────────────────────────────────────────────┤
│ MCP 客户端 │ A2A 协议 │ 链路追踪 │ 日志 │
├──────────────────────────────────────────────────────────┤
│ 统一供应商接口 │
│ ┌─────┐ ┌──────┐ ┌──────┐ ┌─────┐ ┌─────┐ │
│ │ LLM │ │ 向量 │ │ 视觉 │ │ TTS │ │ STT │ ... │
│ └──┬──┘ └──┬───┘ └──┬───┘ └──┬──┘ └──┬──┘ │
├─────┼───────┼────────┼────────┼───────┼────────────────┤
│ OpenAI · Gemini · DeepSeek · 通义 · 智谱 · Ollama +13 │
└──────────────────────────────────────────────────────────┘
环境变量 Environment Variables
OPENAI_API_KEY=sk-...
GEMINI_API_KEY=AI...
DEEPSEEK_API_KEY=sk-...
DASHSCOPE_API_KEY=sk-...
ZHIPU_API_KEY=...
MOONSHOT_API_KEY=sk-...
YI_API_KEY=...
BAICHUAN_API_KEY=...
SILICONFLOW_API_KEY=...
STEPFUN_API_KEY=...
MINIMAX_API_KEY=...
GROQ_API_KEY=gsk_...
COHERE_API_KEY=...
JINA_API_KEY=jina_...
开源协议 License
Apache-2.0 · Made by Deepleaper 跃盟科技
English
Why AgentKits?
AgentKits is the Agent Model Layer in The Self-Evolving Agent Stack — one-line LLM access with built-in memory.
Developer path: ① Pick a template (Agent Templates) → ② Connect models (Agent Model Layer) → ③ Run it (Agent Runtime) → ④ Auto-evolve (Agent Memory).
AgentKits provides a unified TypeScript interface across 29 LLM providers and 18 embedding providers. Switching models requires changing one config value — no code rewrite needed.
Core differentiator: withBrain() memory integration. Every LLM call automatically connects to DeepBrain memory — recall() before the call to retrieve relevant knowledge, learn() after to store new experience. Your Agent is no longer a stateless API call, but a continuously self-evolving intelligence.
First-class support for Chinese LLM ecosystem: DashScope (Qwen), Zhipu AI (GLM), Moonshot (Kimi), Yi, Baichuan, SiliconFlow, StepFun, DeepSeek, MiniMax.
Install
npm install agentkits
Quick Examples
import { createChat, createEmbedding } from 'agentkits';
const chat = createChat({ provider: 'deepseek' });
const reply = await chat.complete('Explain quantum computing');
const emb = createEmbedding({ provider: 'openai' });
const vector = await emb.embed('semantic search');
See the sections above for full code examples — all code blocks are bilingual.
Providers
- LLM (29): OpenAI, Gemini, DeepSeek, DashScope, Zhipu, Moonshot, Yi, Baichuan, SiliconFlow, StepFun, MiniMax, Grok, Cohere, Fireworks, Together, Groq, Perplexity, Ollama, Custom
- Embedding (18): OpenAI, Gemini, DashScope, DeepSeek, Zhipu, SiliconFlow, Cohere, Jina, Voyage, Mixedbread, Nomic, Fireworks, Together, Ollama, Custom
Module Catalog (40 modules)
Refer to the Module Catalog table above — all import paths work as import { ... } from 'agentkits/<module>'.
CLI
npx agentkits chat [--provider P] [--model M]
npx agentkits embed "text" [--provider P]
npx agentkits benchmark [--providers a,b,c] [--runs N]
npx agentkits test
npx agentkits cost
npx agentkits serve [--port N]
npx agentkits list
npx agentkits mcp connect <url>
🔄 Dual-Loop Knowledge System
AgentKits participates in the dual-loop knowledge system via withBrain():
┌─────────────────────────────────────────────────────┐
│ Small Loop (Local, Free) │
│ Agent local learn → recall → evolve │
│ Works offline, data stays on your machine │
│ │
│ Big Loop (Hub, Value-Add) │
│ Agent ↔ Workstation Hub knowledge sharing │
│ Collective wisdom > individual experience │
└─────────────────────────────────────────────────────┘
Local is the owner, Hub is the helper — works without internet, auto-syncs when connected.
agentkits (Model Layer) — LLM calls ← You are here
↕
opc-agent (Runtime) — run Agents (local)
↕
deepbrain (Memory Engine) — store knowledge (engine)
↕
agent-workstation (Knowledge Platform) — knowledge lifecycle (Hub)
License
Apache-2.0 · Made by Deepleaper 跃盟科技