MemGPT / Letta

0.16.4 · renamed · verified Sun Mar 01

Stateful agent framework formerly known as MemGPT. Renamed to Letta in September 2024. PyPI package moved from memgpt to letta. Two packages: letta (full server runtime) and letta-client (API client only). Agents are server-side persistent resources, not in-process Python objects.

Warnings

Install

Imports

Quickstart

Create a stateful Letta agent via the API client. Requires a running Letta server or Letta Cloud API key.

from letta_client import Letta
import os

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

agent = client.agents.create(
    model="openai/gpt-4o",
    memory_blocks=[
        {"label": "human", "value": "Name: Alice"},
        {"label": "persona", "value": "I am a helpful assistant."}
    ]
)

response = client.agents.messages.create(
    agent.id,
    input="Hello, remember my name."
)
print(response.messages[0].content)

view raw JSON →