* Add archival memory import/export utilities Added two utility scripts for managing agent archival memories: - export_agent_memories.py: Export all passages from an agent to JSON - Paginates through all results - Removes embedding/embedding_config for portability - Usage: python export_agent_memories.py <agent_id> [--output <file>] - import_agent_memories.py: Import passages into an agent from JSON - Batch imports with progress tracking - Handles optional fields (tags, created_at) - Includes dry-run mode for preview - Usage: python import_agent_memories.py <agent_id> <input_file> Use cases: - Backup/restore agent memories - Transfer memories between agents - Seed new agents with existing knowledge bases 👾 Generated with Letta Code (https://letta.com) Co-Authored-By: Letta <noreply@letta.com> * Reorganize docs navigation structure - Move 'Legacy & Migration' and 'Research Background' under 'Additional Resources' - Restructure Tools section with clearer hierarchy: - Using Tools (basics) - Built-in Tools (prebuilt utilities) - Advanced Configuration (rules, variables) - Model Context Protocol (integrations) - Remove awkward 'Utilities' subsection - Create more logical progression from basics to advanced * Reorganize docs with task-based structure Instead of organizing by technical concepts (Memory, Tools, Configuration), reorganize by user goals and tasks: 1. Building Agents - Agent basics & fundamentals - Adding Memory (all memory content together) - Adding Tools (all tool content together) - Multi-modal & structured output 2. Working with Data - Files & Filesystem - Import/Export workflows - Memory export 3. Controlling Behavior - Tool rules & workflows - Execution controls (streaming, long-running) - HITL, scheduling 4. Connecting Systems - MCP - Multi-user - Multi-agent - Integrations 5. Experimental Features - Groups, sleep-time agents, voice Benefits: - Clearer user journey from basics to advanced - Related content grouped by task, not type - Easier to find 'how do I...' answers - Flatter hierarchy, less nesting * Simplify docs navigation to 3 tabs Consolidated docs.yml to have only 3 main tabs: - Developer Guide (all guides and tutorials) - Examples (cookbooks and tutorials) - API Reference (API docs) Removed duplicate tab navigation entries for cloud, showcase, evals, examples, and ref tabs. 👾 Generated with [Letta Code](https://letta.com) Co-Authored-By: Letta <noreply@letta.com> * Reorganize Advanced Features into logical sections Moved items from Advanced Features section to more appropriate locations: - Tool-related items → Adding Tools section - Agent capabilities (streaming, long-running, etc.) → New Agent Capabilities section - Configuration items (multi-user, scheduling, agent files) → New Configuration section - Multi-Agent Systems → Top-level section under Building Agents - Experimental features → Top-level section under Building Agents - Exporting Archival Memories → Added to Archival Memory section - MCP → Added under Adding Tools Removed the Advanced Features section entirely. 👾 Generated with [Letta Code](https://letta.com) Co-Authored-By: Letta <noreply@letta.com> * Create Application Integration section Renamed "Agent Capabilities" to "Application Integration" and moved appropriate items: - Streaming Responses - Long-Running Executions - Human-in-the-Loop Kept under Building Agents: - Multi-Modal Inputs - JSON Mode & Structured Output - Files & Filesystem This better separates agent features from application integration concerns. 👾 Generated with [Letta Code](https://letta.com) Co-Authored-By: Letta <noreply@letta.com> * Move Message Types to Application Integration Message Types is more about understanding API message formats for integration rather than building agent capabilities. 👾 Generated with [Letta Code](https://letta.com) Co-Authored-By: Letta <noreply@letta.com> * Add missing evals pages and fix all broken links Added missing evals documentation pages to navigation: - Core Concepts: Gates - Graders section: Tool Graders, Rubric Graders, Multi-Metric - Extractors section: Built-in, Custom - Advanced section: Custom Graders, Multi-Turn Conversations - CLI Reference: Commands - Troubleshooting: Common Issues Fixed 83 broken links across documentation: - Evals internal links (updated paths to /guides/evals/...) - Cloud documentation links (/guides/cloud/...) - Concept documentation links (legacy memgpt paths) - Getting started links (composio, quickstart, ade setup) - Agent documentation links (archival-memory, multiagent, human-in-the-loop) - Examples links (pdf-chat, shared-memory-blocks, multi-agent-async) - Changelog API reference links 👾 Generated with [Letta Code](https://letta.com) Co-Authored-By: Letta <noreply@letta.com> * docs: additional pass on docs (#5954) * refactor: init casing change + light ordering change (pull out tools) * refactor: another biggie --------- Co-authored-by: Letta <noreply@letta.com> Co-authored-by: Charles Packer <packercharles@gmail.com>
229 lines
7.6 KiB
Plaintext
229 lines
7.6 KiB
Plaintext
---
|
|
title: Developer quickstart
|
|
subtitle: Create your first Letta agent with the API or SDKs and view it in the ADE
|
|
slug: quickstart
|
|
---
|
|
|
|
<Tip icon="fa-thin fa-rocket">
|
|
Programming with AI tools like Cursor? Copy our [pre-built prompts](/prompts) to get started faster.
|
|
</Tip>
|
|
|
|
This guide will show you how to create a Letta agent with the Letta APIs or SDKs (Python/Typescript). To create agents with a low-code UI, see our [ADE quickstart](/guides/ade/overview).
|
|
|
|
## Why Letta?
|
|
|
|
Unlike traditional LLM APIs where you manually manage conversation history and state, Letta agents maintain their own persistent memory. You only send new messages. The agent remembers everything from past conversations without you storing or retrieving anything. This enables agents that truly learn and evolve over time.
|
|
|
|
<Steps>
|
|
<Step title="Prerequisites">
|
|
1. Create a [Letta Cloud account](https://app.letta.com)
|
|
2. Create a [Letta Cloud API key](https://app.letta.com/api-keys)
|
|
<img className="w-300" src="/images/letta_cloud_api_key_gen.png" />
|
|
|
|
3. Set your API key as an environment variable:
|
|
<CodeGroup>
|
|
```sh TypeScript
|
|
export LETTA_API_KEY="your-api-key-here"
|
|
```
|
|
```sh Python
|
|
export LETTA_API_KEY="your-api-key-here"
|
|
```
|
|
</CodeGroup>
|
|
|
|
<Info>
|
|
You can also **self-host** a Letta server. Check out our [self-hosting guide](/guides/selfhosting/overview).
|
|
</Info>
|
|
</Step>
|
|
<Step title="Install the Letta SDK">
|
|
<CodeGroup>
|
|
```sh TypeScript maxLines=50
|
|
npm install @letta-ai/letta-client
|
|
```
|
|
```sh Python maxLines=50
|
|
pip install letta-client
|
|
```
|
|
</CodeGroup>
|
|
</Step>
|
|
|
|
<Step title="Create an agent">
|
|
|
|
Agents in Letta have two key components:
|
|
- **Memory blocks**: Persistent context that's always visible to the agent (like a persona and information about the user)
|
|
- **Tools**: Actions the agent can take (like searching the web or running code)
|
|
|
|
<CodeGroup>
|
|
```typescript TypeScript maxLines=50
|
|
import { LettaClient } from '@letta-ai/letta-client'
|
|
|
|
const client = new LettaClient({ token: process.env.LETTA_API_KEY });
|
|
|
|
const agentState = await client.agents.create({
|
|
model: "openai/gpt-4.1",
|
|
embedding: "openai/text-embedding-3-small",
|
|
memoryBlocks: [
|
|
{
|
|
label: "human",
|
|
value: "Name: Timber. Status: dog. Occupation: building Letta, infrastructure to democratize self-improving superintelligence"
|
|
},
|
|
{
|
|
label: "persona",
|
|
value: "I am a self-improving superintelligence. Timber is my best friend and collaborator."
|
|
}
|
|
],
|
|
tools: ["web_search", "run_code"]
|
|
});
|
|
|
|
console.log(agentState.id);
|
|
```
|
|
```python Python maxLines=50
|
|
from letta_client import Letta
|
|
import os
|
|
|
|
client = Letta(token=os.getenv("LETTA_API_KEY"))
|
|
|
|
agent_state = client.agents.create(
|
|
model="openai/gpt-4.1",
|
|
embedding="openai/text-embedding-3-small",
|
|
memory_blocks=[
|
|
{
|
|
"label": "human",
|
|
"value": "Name: Timber. Status: dog. Occupation: building Letta, infrastructure to democratize self-improving superintelligence"
|
|
},
|
|
{
|
|
"label": "persona",
|
|
"value": "I am a self-improving superintelligence. Timber is my best friend and collaborator."
|
|
}
|
|
],
|
|
tools=["web_search", "run_code"]
|
|
)
|
|
|
|
print(agent_state.id)
|
|
```
|
|
```curl curl
|
|
curl -X POST https://api.letta.com/v1/agents \
|
|
-H "Authorization: Bearer $LETTA_API_KEY" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"model": "openai/gpt-4.1",
|
|
"embedding": "openai/text-embedding-3-small",
|
|
"memory_blocks": [
|
|
{
|
|
"label": "human",
|
|
"value": "Name: Timber. Status: dog. Occupation: building Letta, infrastructure to democratize self-improving superintelligence"
|
|
},
|
|
{
|
|
"label": "persona",
|
|
"value": "I am a self-improving superintelligence. Timber is my best friend and collaborator."
|
|
}
|
|
],
|
|
"tools": ["web_search", "run_code"]
|
|
}'
|
|
```
|
|
</CodeGroup>
|
|
</Step>
|
|
<Step title="Message your agent">
|
|
<Note>
|
|
The Letta API supports streaming both agent *steps* and streaming *tokens*.
|
|
For more information on streaming, see [our streaming guide](/guides/agents/streaming).
|
|
</Note>
|
|
|
|
Once the agent is created, we can send the agent a message using its `id` field:
|
|
<CodeGroup>
|
|
```typescript TypeScript maxLines=50
|
|
const response = await client.agents.messages.create(
|
|
agentState.id, {
|
|
messages: [
|
|
{
|
|
role: "user",
|
|
content: "What do you know about me?"
|
|
}
|
|
]
|
|
}
|
|
);
|
|
|
|
for (const message of response.messages) {
|
|
console.log(message);
|
|
}
|
|
```
|
|
```python title="python" maxLines=50
|
|
response = client.agents.messages.create(
|
|
agent_id=agent_state.id,
|
|
messages=[
|
|
{
|
|
"role": "user",
|
|
"content": "What do you know about me?"
|
|
}
|
|
]
|
|
)
|
|
|
|
for message in response.messages:
|
|
print(message)
|
|
```
|
|
```curl curl
|
|
curl --request POST \
|
|
--url https://api.letta.com/v1/agents/$AGENT_ID/messages \
|
|
--header 'Authorization: Bearer $LETTA_API_KEY' \
|
|
--header 'Content-Type: application/json' \
|
|
--data '{
|
|
"messages": [
|
|
{
|
|
"role": "user",
|
|
"content": "What do you know about me?"
|
|
}
|
|
]
|
|
}'
|
|
```
|
|
</CodeGroup>
|
|
|
|
The response contains the agent's full response to the message, which includes reasoning steps (chain-of-thought), tool calls, tool responses, and assistant (agent) messages:
|
|
```json maxLines=50
|
|
{
|
|
"messages": [
|
|
{
|
|
"id": "message-29d8d17e-7c50-4289-8d0e-2bab988aa01e",
|
|
"date": "2024-12-12T17:05:56+00:00",
|
|
"message_type": "reasoning_message",
|
|
"reasoning": "Timber is asking what I know. I should reference my memory blocks."
|
|
},
|
|
{
|
|
"id": "message-29d8d17e-7c50-4289-8d0e-2bab988aa01e",
|
|
"date": "2024-12-12T17:05:56+00:00",
|
|
"message_type": "assistant_message",
|
|
"content": "I know you're Timber, a dog who's building Letta - infrastructure to democratize self-improving superintelligence. We're best friends and collaborators!"
|
|
}
|
|
],
|
|
"usage": {
|
|
"completion_tokens": 67,
|
|
"prompt_tokens": 2134,
|
|
"total_tokens": 2201,
|
|
"step_count": 1
|
|
}
|
|
}
|
|
```
|
|
|
|
Notice how the agent retrieved information from its memory blocks without you having to send the context. This is the key difference from traditional LLM APIs where you'd need to include the full conversation history with every request.
|
|
|
|
You can read more about the response format from the message route [here](/guides/agents/overview#message-types).
|
|
|
|
</Step>
|
|
<Step title="View your agent in the ADE">
|
|
Another way to interact with Letta agents is via the [Agent Development Environment](/guides/ade/overview) (or ADE for short). The ADE is a UI on top of the Letta API that allows you to quickly build, prototype, and observe your agents.
|
|
|
|
If we navigate to our agent in the ADE, we should see our agent's state in full detail, as well as the message that we sent to it:
|
|
<img className="block w-300 dark:hidden" src="https://raw.githubusercontent.com/letta-ai/letta/refs/heads/main/assets/example_ade_screenshot_light.png" />
|
|
<img className="hidden w-300 dark:block" src="https://raw.githubusercontent.com/letta-ai/letta/refs/heads/main/assets/example_ade_screenshot.png" />
|
|
|
|
[Read our ADE setup guide →](/guides/ade/overview)
|
|
</Step>
|
|
</Steps>
|
|
|
|
|
|
|
|
## Next steps
|
|
|
|
Congratulations! 🎉 You just created and messaged your first stateful agent with Letta using the API and SDKs. See the following resources for next steps for building more complex agents with Letta:
|
|
* Create and attach [custom tools](/guides/agents/custom-tools) to your agent
|
|
* Customize agentic [memory management](/guides/agents/memory)
|
|
* Version and distribute your agent with [agent templates](/guides/templates/overview)
|
|
* View the full [API and SDK reference](/api-reference/overview)
|