# Letta

> Build stateful AI agents with long-term memory that persists across sessions

- Category: Agents & Automation / Agent Memory
- Language: Python
- Repository: https://github.com/letta-ai/letta
- Website: https://www.letta.com/
- Canonical page: https://ai-tldr.dev/tools/letta/

## In short

Letta, formerly known as MemGPT, is an open-source framework for building AI agents that keep memory over time. It sits in the Agent Memory category of the Agents & Automation tools and is open-source, written in Python. To get started: run an agent in your terminal.

## Overview

Letta, formerly known as MemGPT, is an open-source framework for building AI agents that keep memory over time. Instead of starting fresh on every request, a Letta agent stores what it learns in memory blocks that persist across sessions and conversations, so it can recall earlier context and improve as it is used.

It is aimed at developers building agentic applications who need state to outlive a single chat. You can run agents locally from your terminal with the Letta Code CLI, or integrate them into your own apps through the Letta API, which ships Python and TypeScript SDKs.

As an app framework in the LLM orchestration space, Letta is model-agnostic and focuses on the memory and agent-state layer rather than a single model. It supports skills and subagents and connects to common tools like web search and webpage fetching.

## What it does

- Stateful agents with long-term memory that persists across sessions and conversations
- Editable memory blocks (such as human and persona) that shape what an agent knows and how it behaves
- Letta Code CLI to run an agent with memory locally in your terminal
- Full agents API with official Python and TypeScript SDKs
- Model-agnostic design that works across different LLM providers
- Built-in tools including web_search and fetch_webpage, plus support for skills and subagents

## Getting started

You can try Letta from the terminal with the Letta Code CLI, or integrate it into an app using the SDK. The API examples require a Letta API key.

1. Run an agent in your terminal

   Install the Letta Code CLI (requires Node.js 18+), then run letta to launch a local agent with memory.

```bash
npm install -g @letta-ai/letta-code
letta
```

2. Install the SDK

   To build agents into your own application, install the client for your language.

```bash
# TypeScript / Node.js
npm install @letta-ai/letta-client

# Python
pip install letta-client
```

3. Create an agent and send a message (Python)

   Set LETTA_API_KEY, create a stateful agent with memory blocks, then send it a message.

```python
from letta_client import Letta
import os

client = Letta(api_key=os.getenv("LETTA_API_KEY"))

agent_state = client.agents.create(
    model="openai/gpt-5.2",
    memory_blocks=[
        {"label": "human", "value": "Name: Timber. Status: dog."},
        {"label": "persona", "value": "I am a self-improving superintelligence."}
    ],
    tools=["web_search", "fetch_webpage"]
)

print(f"Agent created with ID: {agent_state.id}")

response = client.agents.messages.create(
    agent_id=agent_state.id,
    input="What do you know about me?"
)

for message in response.messages:
    print(message)
```

## When to use it

- Building a chat assistant that remembers a user's details and preferences across separate sessions
- Adding a memory and agent-state layer to an existing app through the Python or TypeScript SDK
- Running a local terminal agent that can help with coding and computer tasks while retaining context
- Creating agents that learn and refine their behavior over time using persistent memory blocks
