Create LLM agents with long-term memory and custom tools
$git clone https://github.com/letta-ai/lettaInstalls into the current project.
Install letta by running `git clone https://github.com/letta-ai/letta`, then use it for the current task and follow its documentation at https://github.com/letta-ai/letta.
| 1 | # Letta (formerly MemGPT) |
| 2 | |
| 3 | Build AI with advanced memory that can learn and self-improve over time. |
| 4 | |
| 5 | * [Letta Agent](https://docs.letta.com/letta-agent): run agents locally in your terminal, via the desktop app, or via channels like Slack |
| 6 | * [Letta Agent SDK](https://docs.letta.com/letta-agent-sdk/overview): build agents into your applications |
| 7 | |
| 8 | > [!NOTE] |
| 9 | > This repository contains the legacy Letta server (the API server behind the Letta V1 API and SDKs). Active development has moved to the [Letta Agent repo](https://github.com/letta-ai/letta-code), and self-hosting an API server is now done via the [App Server](https://docs.letta.com/letta-agent/app-server). See [AGENTS.md](AGENTS.md) for details. |
| 10 | |
| 11 | ## Get started in the CLI |
| 12 | |
| 13 | Requires [Node.js 22.19+](https://nodejs.org/en/download) |
| 14 | |
| 15 | 1. Install the [Letta Code](https://github.com/letta-ai/letta-code) CLI tool: `npm install -g @letta-ai/letta-code` |
| 16 | 2. Run `letta` in your terminal to launch an agent with memory running on your local computer |
| 17 | |
| 18 | When running the CLI tool, your agent can help you code and do any task you can do on your computer. |
| 19 | |
| 20 | Letta Code supports [skills](https://docs.letta.com/letta-agent/skills) and [subagents](https://docs.letta.com/letta-agent/subagents), and bundles pre-built skills/subagents for advanced memory and continual learning. Letta is fully model-agnostic, though we recommend the latest Anthropic, OpenAI, and zAI models for best performance (see our [model leaderboard](https://leaderboard.letta.com/) for our rankings). |
| 21 | |
| 22 | ## Get started with the Letta Agent SDK |
| 23 | |
| 24 | Use the [Letta Agent SDK](https://docs.letta.com/letta-agent-sdk/overview) (TypeScript) to build stateful agents into your own applications. |
| 25 | The SDK can run agents on [Constellation](https://docs.letta.com/letta-agent/constellation) (Letta's agent cloud), fully locally on your machine, or against a self-hosted [App Server](https://docs.letta.com/letta-agent/app-server). |
| 26 | |
| 27 | ### Installation |
| 28 | |
| 29 | ```bash |
| 30 | npm install @letta-ai/letta-agent-sdk |
| 31 | ``` |
| 32 | |
| 33 | ### Hello World example |
| 34 | |
| 35 | Below is a quick example of creating a stateful agent and streaming a conversation with it (requires a [Letta API key](https://app.letta.com/api-keys)). |
| 36 | See the full [quickstart guide](https://docs.letta.com/letta-agent-sdk/quickstart) for complete documentation. |
| 37 | |
| 38 | ```typescript |
| 39 | import { LettaAgentClient } from "@letta-ai/letta-agent-sdk"; |
| 40 | |
| 41 | const client = new LettaAgentClient({ |
| 42 | backend: "cloud", |
| 43 | apiKey: process.env.LETTA_API_KEY, |
| 44 | }); |
| 45 | |
| 46 | // Create your agent |
| 47 | const agentId = await client.createAgent({ |
| 48 | model: "anthropic/claude-opus-4-8", |
| 49 | human: |
| 50 | "Name: Timber. Status: dog. Occupation: building Letta, infrastructure to democratize self-improving superintelligence", |
| 51 | persona: |
| 52 | "I am a self-improving superintelligence. Timber is my best friend and collaborator.", |
| 53 | }); |
| 54 | |
| 55 | console.log("Agent created with ID:", agentId); |
| 56 | |
| 57 | // Send your agent a message and stream the response |
| 58 | await using session = client.resumeSession(agentId); |
| 59 | |
| 60 | await session.send("What do you know about me?"); |
| 61 | for await (const message of session.stream()) { |
| 62 | if (message.type === "assistant") console.log(message.content); |
| 63 | } |
| 64 | ``` |
| 65 | |
| 66 | To run the same agent fully locally (the SDK spawns [Letta Code](https://github.com/letta-ai/letta-code) on your machine as a subprocess), swap out the client: |
| 67 | |
| 68 | ```typescript |
| 69 | const client = new LettaAgentClient({ backend: "local" }); |
| 70 | ``` |
| 71 | |
| 72 | ### Letta V1 SDK |
| 73 | |
| 74 | The previous-generation [V1 SDKs](https://docs.letta.com/guides/get-started/intro) (`@letta-ai/letta-client` for TypeScript, `letta-client` for Python) target the Letta API directly and are still available (see the [client SDKs](https://docs.letta.com/api-overview/client-sdks)). We recommend the Agent SDK for new projects. |
| 75 | |
| 76 | ## Contributing |
| 77 | |
| 78 | Letta is an open source project built by over a hundred contributors from around the world. There are many ways to get involved in the Letta OSS project! |
| 79 | |
| 80 | * [**Join the Discord**](https://discord.gg/letta): Chat with the Letta devs and other AI developers. |