Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

agentkits

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

agentkits

Agent Model Layer — One-line LLM access with built-in memory. 29 providers, 18 embeddings, zero lock-in.

latest
Source
npmnpm
Version
2.0.3
Version published
Maintainers
1
Created
Source

🧰 AgentKits

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

npm version License TypeScript Tests Node.js

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('解释量子计算');

// withBrain() — 自进化,越用越聪明
const brain = new Brain({ database: './brain.db' });
const agentBrain = new AgentBrain(brain, 'my-agent');
const smartChat = chat.withBrain(agentBrain);
const smartReply = await smartChat.complete('解释量子计算');
// → 自动 recall 相关记忆 → 生成更好的回答 → learn 这次交互

🇨🇳 深度支持中国大模型生态:通义千问、智谱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] });  // 智谱AI
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 直接运行:

文件说明
chat-basic.mjs最简对话(3 行代码)
chat-stream.mjs流式输出,逐字打印
embedding-search.mjs文本向量化 + 余弦相似度搜索
rag-pipeline.mjs完整 RAG 流程(分块 → 向量化 → 检索 → 生成)
multi-provider.mjs同一问题发给多个供应商,对比回答
benchmark.mjs响应速度、TTFT、Token 数基准测试
# 设置环境变量
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

# 基准测试(支持 --providers 指定供应商)
node examples/benchmark.mjs --providers gemini,deepseek,groq

大模型供应商 LLM Providers (29)

供应商 Provider中文名模型 Models流式函数调用视觉
OpenAIGPT-4o, GPT-4o-mini, o1, o3
GeminiGemini 2.0/1.5 Pro/Flash
DeepSeek深度求索DeepSeek-V3, R1
DashScope通义千问Qwen-Max/Plus/Turbo
Zhipu智谱AIGLM-4, GLM-4V
Moonshot月之暗面 (Kimi)moonshot-v1
Yi零一万物Yi-Large
Baichuan百川智能Baichuan-4
SiliconFlow硅基流动多模型聚合
StepFun阶跃星辰Step-2
MiniMaxMiniMaxabab6.5s
Grokgrok-2
CohereCommand R+
FireworksFireFunction, Mixtral
TogetherLlama, Mixtral
GroqLlama, Mixtral
PerplexitySonar
Ollama本地部署任意本地模型
Custom自定义任意 OpenAI 兼容

向量化引擎 Embedding Providers (18)

供应商 Provider中文名模型 Models维度
OpenAItext-embedding-3-small/large, ada-002256–3072
Geminitext-embedding-004768
DashScope通义千问text-embedding-v31024
DeepSeek深度求索(兼容接口)可变
Zhipu智谱AIembedding-32048
SiliconFlow硅基流动多模型可变
Cohereembed-v31024
Jinajina-embeddings-v31024
Voyagevoyage-31024
Mixedbreadmxbai-embed-large1024
Nomicnomic-embed-text768
Fireworksnomic, thenlper可变
Together多模型可变
Ollama本地部署任意本地模型可变
Custom自定义任意兼容接口可变

模块目录 Module Catalog

核心 Core

模块引入路径说明
大模型对话agentkits/llm统一对话补全接口,支持 29 个供应商
向量化agentkits/embedding统一向量化接口,支持 18 个引擎
流式输出agentkits/streamingSSE 解析、流组合、中断控制
结构化输出agentkits/structuredJSON Schema 校验的 LLM 输出
函数调用agentkits/function-calling跨供应商的函数/工具调用格式转换

智能体构建 Agent Building

模块引入路径说明
Agent 循环agentkits/agentReAct 风格智能体,支持工具调用循环
工具调用agentkits/tools定义和执行工具,适配任意大模型
多轮对话agentkits/conversation多轮对话管理,滑动窗口
Agent 记忆agentkits/agent-memory短期/长期记忆,自动摘要
提示词模板agentkits/prompt-templateHandlebars 风格模板引擎
安全护栏agentkits/guardrails输入输出校验、内容过滤、PII 检测

RAG 检索增强生成

模块引入路径说明
RAG 管线agentkits/rag完整的检索-增强-生成管线
重排序agentkits/rerankAPI 重排序(Cohere、Jina 等)
本地重排agentkits/rerankerCross-encoder 本地重排序
网页搜索agentkits/web-searchBrave、Tavily、Serper、SearXNG
PDF 解析agentkits/pdf-parserPDF 文本提取与分块
文本分块agentkits/chunker智能分块(固定、句子、递归、语义)

多模态 Multimodal

模块引入路径说明
视觉理解agentkits/vision跨供应商图像理解
语音合成agentkits/ttsTTS(OpenAI、Azure、ElevenLabs)
语音识别agentkits/sttSTT 语音转文字
图像生成agentkits/imageDALL-E、Stability 等

基础设施 Infrastructure

模块引入路径说明
故障转移agentkits/failover自动供应商切换与健康检测
智能路由agentkits/router按成本、速度、能力路由请求
模型路由agentkits/model-router高级路由:模型画像与规则引擎
限流器agentkits/ratelimitToken bucket 限流
供应商限流agentkits/rate-limiter按供应商限流(内置默认值)
响应缓存agentkits/response-cacheLRU + TTL 缓存
重试agentkits/retry指数退避 + 抖动
成本计算agentkits/cost跨供应商定价对比
Token 计数agentkits/token-counter按模型精确计数
代理服务器agentkits/proxyOpenAI 兼容代理
性能基准agentkits/benchmark供应商延迟与吞吐量基准测试
供应商测试agentkits/test一键检测已配置供应商的连通性
日志agentkits/logger结构化日志
链路追踪agentkits/tracingOpenTelemetry 兼容分布式追踪
代码解释器agentkits/code-interpreter沙箱代码执行(JS、Python、Shell)
模型评估agentkits/evaluation多模型输出对比:延迟、成本、质量

协议与互操作 Protocol & Interop

模块引入路径说明
MCP 客户端agentkits/mcp-client连接 MCP 服务器,自动转换工具定义
工作流引擎agentkits/workflow多步骤工作流:分支、并行、重试
A2A 协议agentkits/a2aGoogle 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]                       # OpenAI 兼容代理
npx agentkits list                                      # 列出所有供应商
npx agentkits mcp connect <url>                         # 连接 MCP 服务器

🔄 双闭环知识系统 (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

✅ = 支持,🔶 = 部分支持/需额外配置,❌ = 不支持

功能 FeatureAgentKitsLiteLLMVercel AI SDKOpenRouterLangChain (LLM 层)
定位Agent Model Layer(一行代码接 LLM + 自带记忆)LLM 统一网关/代理AI 应用 SDK (React)API 聚合市场AI 全栈框架
语言TypeScriptPythonTypeScriptREST APIPython (TS 有限)
LLM Provider 数29100+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 原生❌ PythonREST API❌ Python
许可证Apache-2.0Apache-2.0Apache-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=...                # 智谱AI
MOONSHOT_API_KEY=sk-...          # 月之暗面 (Kimi)
YI_API_KEY=...                   # 零一万物
BAICHUAN_API_KEY=...             # 百川智能
SILICONFLOW_API_KEY=...          # 硅基流动
STEPFUN_API_KEY=...              # 阶跃星辰
MINIMAX_API_KEY=...              # MiniMax

# 更多
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 跃盟科技

Keywords

ai

FAQs

Package last updated on 20 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts