用 TypeScript Agent Development Kit(ADK)构建 AI 智能体
来源:dev.to — 2026-07-27
📋 概述
这是一篇面向初学者的 TypeScript ADK 教程,逐步构建一个“Hello World”级智能体。文章从安装 Node.js 20+(推荐 nvm)讲起,介绍 ADK 是面向 Gemini 与 Google 生态优化、但模型无关、部署无关的模块化框架,可发布为 @google/adk npm 包。教程涵盖设置 Gemini API Key、运行 init.sh 初始化、在 Gemini Developer API 与 Vertex AI 两种认证方式间选择,并给出调试权限错误的指引。
🔑 核心要点
- 强类型契合智能体:TypeScript 的静态类型在编译期就校验工具参数、结果与智能体配置,早于模型介入
- 环境要求:需要 Node.js 20+,nvm 是最省事的版本管理方式,使用 ADK 1.4.0
- 框架定位:ADK 对 Gemini 优化但模型无关、部署无关,兼容其他框架
- 两种认证:可用 GOOGLE_API_KEY(Gemini Developer API)或 Vertex AI(设 GOOGLE_GENAI_USE_VERTEXAI=TRUE 并配 ADC)
- 快速起步:git clone 示例仓库后运行 init.sh,自动装依赖并生成 .env,切记勿提交 .env
💡 金句
Tool parameters, tool results, and agent configuration are all checked at compile time, before the model ever sees them.
👍 0
👎 0
← 返回 Dev.to 首页