Skip to content

<- Back to Overview

Quick reference for Letta APIs. For detailed documentation, see docs.letta.com.

Terminal window
pip install letta # Server
pip install letta-client # Python SDK
Terminal window
letta server # Start on :8283
from letta_client import Letta
client = Letta(base_url="http://localhost:8283")

# Create
agent = client.agents.create(
name="my-agent",
model="openai/gpt-4o-mini",
embedding="openai/text-embedding-3-small",
memory_blocks=[
{"label": "persona", "value": "I am..."},
{"label": "human", "value": "User info..."},
],
)
# List
agents = client.agents.list()
# Get
agent = client.agents.retrieve(agent_id)
# Delete
client.agents.delete(agent_id)
# Synchronous
response = client.agents.messages.create(
agent_id=agent.id,
input="Hello!"
)
# Streaming
with client.agents.messages.stream(
agent_id=agent.id,
input="Hello!",
) as stream:
for chunk in stream:
print(chunk)
# Core memory
blocks = client.agents.core_memory.list(agent_id)
client.agents.core_memory.update(agent_id, block_id, value="...")
# Archival memory
client.agents.archival_memory.insert(agent_id, text="...")
results = client.agents.archival_memory.search(agent_id, query="...")
# Create from function
tool = client.tools.upsert_from_function(func=my_function)
# Attach to agent
client.agents.tools.attach(agent_id, tool_id)

# LLM models
"openai/gpt-4o-mini"
"anthropic/claude-3-5-sonnet"
"ollama/llama2:7b"
# Embedding models
"openai/text-embedding-3-small"
"letta/letta-free"

Terminal window
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
LETTA_BASE_URL=http://localhost:8283

TopicLink
Getting Starteddocs.letta.com/quickstart
Core Conceptsdocs.letta.com/core-concepts
Agent Memorydocs.letta.com/guides/agents/memory
Streamingdocs.letta.com/guides/agents/streaming
Toolsdocs.letta.com/guides/agents/tools
REST APIdocs.letta.com/api-reference

YouLab requires letta>=0.6.0. Current stable: 0.10.x

See GitHub releases for changelog.