Chapter 1: Getting Started with Letta
April 13, 2026 · View on GitHub
Welcome to Chapter 1: Getting Started with Letta. In this part of Letta Tutorial: Stateful LLM Agents, you will build an intuitive mental model first, then move into concrete implementation details and practical production tradeoffs.
Install Letta, create your first agent, and start a conversation with persistent memory.
Architecture Overview
flowchart TD
A[Install: pip install letta] --> B[Configure LLM Provider]
B --> C[Start Letta Server]
C --> D[Create Agent via SDK or CLI]
D --> E[Agent with Core Memory]
E --> F[Send Messages]
F --> G[Agent Processes + Stores Facts]
G --> H[Persistent Memory Across Sessions]
classDef install fill:#e1f5fe,stroke:#01579b
classDef config fill:#f3e5f5,stroke:#4a148c
classDef agent fill:#fff3e0,stroke:#ef6c00
classDef output fill:#e8f5e9,stroke:#1b5e20
class A,B install
class C,D config
class E,F,G agent
class H output
Overview
Letta (formerly MemGPT) enables AI agents with persistent memory. This chapter covers installation, basic setup, and your first conversation with an agent that remembers.
Prerequisites
- Python 3.9+
- OpenAI API key or compatible LLM provider
- Basic command line knowledge
Installation
Install Letta via pip:
pip install letta
Or for development:
git clone https://github.com/letta-ai/letta.git
cd letta
pip install -e .
Quick Start
Create your first agent with one command:
letta create --name sam --persona "You are Sam, a helpful AI assistant."
This creates an agent with default settings and starts a chat session.
Configuration
Set up your API keys and configuration:
# Set OpenAI API key
export OPENAI_API_KEY="sk-your-key-here"
# Or configure via letta config
letta configure
Choose your LLM provider and model:
letta config set default_model gpt-4o-mini
letta config set default_embedding_model text-embedding-ada-002
Your First Conversation
Start chatting with your agent:
letta chat --name sam
In the chat interface:
Human: Hi, I'm John and I work as a software developer.
Assistant: Hello John! I'm Sam, your helpful AI assistant. I see you're a software developer. I'll remember that for our future conversations.
Human: What's my name and profession?
Assistant: Your name is John and you're a software developer. I remember that from our conversation just now!
The agent remembers your introduction across the session!
Understanding Agent State
Check what your agent knows:
letta get-agent --name sam
This shows the agent's core memory, including facts about you.
Creating Multiple Agents
Create agents with different personalities:
# A creative writing assistant
letta create --name writer --persona "You are a creative writing coach who helps with stories and characters."
# A coding assistant
letta create --name coder --persona "You are an expert software engineer who writes clean, efficient code."
Switching Between Agents
Chat with different agents:
letta chat --name writer
letta chat --name coder
Each agent maintains its own memory and personality.
Basic Memory Inspection
View an agent's memory:
# See all agents
letta list-agents
# Get detailed info about an agent
letta get-agent --name sam --json
Troubleshooting
Common issues:
- API Key Not Set: Make sure
OPENAI_API_KEYis exported - Model Not Available: Check if your API key has access to the specified model
- Memory Issues: Ensure you have enough disk space for the local database
Next Steps
Now that you have agents running, let's explore how their memory actually works in the next chapter.
Example Session
$ letta create --name sam --persona "You are Sam, a helpful AI assistant."
Created agent 'sam' with ID: agent_123
$ letta chat --name sam
Starting chat with agent 'sam'...
Human: Hello! I'm Alex, a data scientist from New York.
Assistant: Hi Alex! I'm Sam. It's great to meet you. I'll remember you're a data scientist from New York for our future conversations.
Human: What do you know about me?
Assistant: I know that your name is Alex, you're a data scientist, and you're from New York. Is there anything else you'd like me to know or any questions you have?
The agent automatically stored and retrieved your personal information! This is the foundation of Letta's persistent memory system.
What Problem Does This Solve?
Most teams struggle here because the hard part is not writing more code, but deciding clear boundaries for letta, name, assistant so behavior stays predictable as complexity grows.
In practical terms, this chapter helps you avoid three common failures:
- coupling core logic too tightly to one implementation path
- missing the handoff boundaries between setup, execution, and validation
- shipping changes without clear rollback or observability strategy
After working through this chapter, you should be able to reason about Chapter 1: Getting Started with Letta as an operating subsystem inside Letta Tutorial: Stateful LLM Agents, with explicit contracts for inputs, state transitions, and outputs.
Use the implementation notes around chat, agent, create as your checklist when adapting these patterns to your own repository.
How it Works Under the Hood
Under the hood, Chapter 1: Getting Started with Letta usually follows a repeatable control path:
- Context bootstrap: initialize runtime config and prerequisites for
letta. - Input normalization: shape incoming data so
namereceives stable contracts. - Core execution: run the main logic branch and propagate intermediate state through
assistant. - Policy and safety checks: enforce limits, auth scopes, and failure boundaries.
- Output composition: return canonical result payloads for downstream consumers.
- Operational telemetry: emit logs/metrics needed for debugging and performance tuning.
When debugging, walk this sequence in order and confirm each stage has explicit success/failure conditions.
Source Walkthrough
Key source files in letta-ai/letta:
letta/client/client.py--LocalClientandRESTClient:create_agent(),send_message(),get_agent()entry pointsletta/server/server.py--SyncServer: orchestrates agent creation, message processing, and memory persistenceletta/agent.py--Agentclass:step()method drives the core LLM call + memory update loop
Suggested trace: client.send_message() → SyncServer.user_message() → Agent.step() to follow a message from user input to persisted memory update.