> [!NOTE] > 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。 > [English](./README.en.md) · [原始项目](https://github.com/letta-ai/letta) · [上游 README](https://github.com/letta-ai/letta/blob/HEAD/README.md) > 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。 # Letta(原 MemGPT) 构建具备高级记忆、可随时间学习与自我改进能力的 AI。 * [Letta Agent](https://docs.letta.com/letta-agent): 在终端本地运行智能体,或通过桌面应用,或通过 Slack 等渠道 * [Letta Agent SDK](https://docs.letta.com/letta-agent-sdk/overview): 将智能体构建到你的应用中 > [!NOTE] > 本仓库包含旧版 Letta 服务器(Letta V1 API 与 SDK 背后的 API 服务器)。活跃开发已迁移至 [Letta Agent 仓库](https://github.com/letta-ai/letta-code),,自托管 API 服务器现通过 [App Server](https://docs.letta.com/letta-agent/app-server). 完成。详见 [AGENTS.md](AGENTS.md)。 ## 在 CLI 中入门 需要 [Node.js 22.19+](https://nodejs.org/en/download) 1. 安装 [Letta Code](https://github.com/letta-ai/letta-code) CLI 工具:`npm install -g @letta-ai/letta-code` 2. 在终端运行 `letta`,以在本地计算机上启动具备记忆能力的智能体 运行 CLI 工具时,你的智能体可协助你编写代码,并执行你在计算机上能做的任何任务。 Letta Code 支持 [skills](https://docs.letta.com/letta-agent/skills) 与 [subagents](https://docs.letta.com/letta-agent/subagents),,并内置预置的 skills/subagents,用于高级记忆与持续学习。Letta 完全模型无关(model-agnostic),但我们建议使用最新的 Anthropic、OpenAI 与 zAI 模型以获得最佳性能(排名见 [模型排行榜](https://leaderboard.letta.com/))。 ## 使用 Letta Agent SDK 入门 使用 [Letta Agent SDK](https://docs.letta.com/letta-agent-sdk/overview)(TypeScript)将具备状态的智能体构建到你自己的应用中。 SDK 可在 [Constellation](https://docs.letta.com/letta-agent/constellation)(Letta 的智能体云)上运行智能体,也可在你机器上完全本地运行,或对接自托管的 [App Server](https://docs.letta.com/letta-agent/app-server). ### 安装 ```bash npm install @letta-ai/letta-agent-sdk ``` ### Hello World 示例 下面是一个快速示例:创建具备状态的智能体并与之流式对话(需要 [Letta API key](https://app.letta.com/api-keys)). 完整文档请参阅 [快速入门指南](https://docs.letta.com/letta-agent-sdk/quickstart)。 ```typescript import { LettaAgentClient } from "@letta-ai/letta-agent-sdk"; const client = new LettaAgentClient({ backend: "cloud", apiKey: process.env.LETTA_API_KEY, }); // Create your agent const agentId = await client.createAgent({ model: "anthropic/claude-opus-4-8", human: "Name: Timber. Status: dog. Occupation: building Letta, infrastructure to democratize self-improving superintelligence", persona: "I am a self-improving superintelligence. Timber is my best friend and collaborator.", }); console.log("Agent created with ID:", agentId); // Send your agent a message and stream the response await using session = client.resumeSession(agentId); await session.send("What do you know about me?"); for await (const message of session.stream()) { if (message.type === "assistant") console.log(message.content); } ``` 若要在完全本地运行同一智能体(SDK 会在你的机器上以子进程方式启动 [Letta Code](https://github.com/letta-ai/letta-code)),请更换客户端: ```typescript const client = new LettaAgentClient({ backend: "local" }); ``` ### Letta V1 SDK 上一代 [V1 SDK](https://docs.letta.com/guides/get-started/intro)(TypeScript 使用 `@letta-ai/letta-client`,Python 使用 `letta-client`)直接面向 Letta API,仍可使用(参见 [客户端 SDK](https://docs.letta.com/api-overview/client-sdks)).)。新项目我们建议使用 Agent SDK。 ## 贡献 Letta 是由全球百余位贡献者共同构建的开源项目。参与 Letta 开源项目的方式有很多! * [**加入 Discord**](https://discord.gg/letta): 与 Letta 开发者及其他 AI 开发者交流。 * [**在我们的论坛交流**](https://forum.letta.com/): 如果你不用 Discord,欢迎访问开发者论坛。 * **关注我们的社交媒体**:[Twitter/X](https://twitter.com/Letta_AI), [LinkedIn](https://www.linkedin.com/in/letta), [YouTube](https://www.youtube.com/@letta-ai) --- ***法律声明**:使用 Letta 及相关 Letta 服务(如 Letta 端点或托管服务)即表示你同意我们的 [隐私政策](https://www.letta.com/privacy-policy) 与 [服务条款](https://www.letta.com/terms-of-service).*