letta-client-1.7.8
1.7.8
1.7.7
1.7.6
1.7.5
1.7.4
1.7.3
1.7.2
1.7.1
1.7.0
1.6.5
1.6.4
1.6.3
1.6.2
1.6.1
1.6.0
1.5.0
1.4.0
1.3.3
1.3.2
1.3.1
1.3.0
1.2.0
1.1.2
1.1.1
1.1.0
1.0.0a9
1.0.0a8
1.0.0a7
1.0.0a6
1.0.0a5
1.0.0a4
1.0.0a3
1.0.0a22
1.0.0a21
1.0.0a20
1.0.0a2
1.0.0a19
1.0.0a18
1.0.0a17
1.0.0a16
1.0.0a15
1.0.0a14
1.0.0a13
1.0.0a12
1.0.0a11
1.0.0a10
1.0.0a1
1.0.0
0.1.99
0.1.98
0.1.97
0.1.96
0.1.95
0.1.94
0.1.93
0.1.92
0.1.91
0.1.90
0.1.9
0.1.89
0.1.87
0.1.86
0.1.85
0.1.84
0.1.83
0.1.82
0.1.81
0.1.80
0.1.79
0.1.78
0.1.77
0.1.76
0.1.75
0.1.74
0.1.73
0.1.72
0.1.71
0.1.70
0.1.69
0.1.68
0.1.67
0.1.66
0.1.65
0.1.64
0.1.63
0.1.62
0.1.61
0.1.60
0.1.6
0.1.59
0.1.58
0.1.57
0.1.56
0.1.55
0.1.54
0.1.53
0.1.52
0.1.51
0.1.50
0.1.49
0.1.48
0.1.47
0.1.46
0.1.45
0.1.44
0.1.43
0.1.42
0.1.41
0.1.40
0.1.4
0.1.39
0.1.38
0.1.37
0.1.36
0.1.35
0.1.34
0.1.33
0.1.324
0.1.323
0.1.322
0.1.321
0.1.320
0.1.32
0.1.319
0.1.318
0.1.317
0.1.316
0.1.315
0.1.314
0.1.312
0.1.311
0.1.310
0.1.31
0.1.309
0.1.308
0.1.307
0.1.306
0.1.305
0.1.304
0.1.303
0.1.302
0.1.301
0.1.300
0.1.30
0.1.299
0.1.295
0.1.294
0.1.293
0.1.292
0.1.291
0.1.290
0.1.29
0.1.289
0.1.288
0.1.287
0.1.286
0.1.285
0.1.284
0.1.283
0.1.282
0.1.281
0.1.280
0.1.28
0.1.279
0.1.277
0.1.276
0.1.275
0.1.274
0.1.273
0.1.272
0.1.271
0.1.270
0.1.27
0.1.269
0.1.268
0.1.267
0.1.266
0.1.265
0.1.264
0.1.263
0.1.262
0.1.261
0.1.260
0.1.26
0.1.259
0.1.258
0.1.257
0.1.256
0.1.255
0.1.254
0.1.253
0.1.252
0.1.251
0.1.250
0.1.25
0.1.249
0.1.248
0.1.247
0.1.246
0.1.245
0.1.244
0.1.243
0.1.242
0.1.241
0.1.240
0.1.24
0.1.239
0.1.238
0.1.237
0.1.236
0.1.235
0.1.234
0.1.233
0.1.232
0.1.231
0.1.230
0.1.23
0.1.229
0.1.228
0.1.227
0.1.226
0.1.225
0.1.224
0.1.223
0.1.222
0.1.221
0.1.220
0.1.22
0.1.219
0.1.218
0.1.217
0.1.216
0.1.215
0.1.214
0.1.213
0.1.212
0.1.211
0.1.210
0.1.21
0.1.209
0.1.208
0.1.207
0.1.206
0.1.205
0.1.204
0.1.203
0.1.202
0.1.201
0.1.200
0.1.2
0.1.199
0.1.198
0.1.197
0.1.196
0.1.195
0.1.194
0.1.193
0.1.192
0.1.191
0.1.190
0.1.19
0.1.189
0.1.188
0.1.187
0.1.186
0.1.185
0.1.184
0.1.183
0.1.182
0.1.181
0.1.180
0.1.179
0.1.178
0.1.177
0.1.176
0.1.175
0.1.174
0.1.173
0.1.172
0.1.171
0.1.170
0.1.17
0.1.169
0.1.168
0.1.167
0.1.166
0.1.165
0.1.164
0.1.163
0.1.162
0.1.161
0.1.160
0.1.16
0.1.159
0.1.158
0.1.157
0.1.156
0.1.155
0.1.154
0.1.153
0.1.151
0.1.150
0.1.15
0.1.149
0.1.148
0.1.147
0.1.146
0.1.145
0.1.144
0.1.143
0.1.142
0.1.141
0.1.140
0.1.14
0.1.139
0.1.138
0.1.137
0.1.136
0.1.135
0.1.134
0.1.133
0.1.132
0.1.131
0.1.130
0.1.13
0.1.129
0.1.128
0.1.127
0.1.126
0.1.125
0.1.124
0.1.123
0.1.122
0.1.121
0.1.120
0.1.119
0.1.118
0.1.117
0.1.116
0.1.115
0.1.114
0.1.113
0.1.112
0.1.111
0.1.110
0.1.11
0.1.109
0.1.108
0.1.107
0.1.106
0.1.105
0.1.104
0.1.103
0.1.102
0.1.101
0.1.100
0.1.10
0.1.0
0.0.1285
1.7.8
1.7.7
1.7.6
1.7.5
1.7.4
1.7.3
1.7.2
1.7.1
1.7.0
1.6.5
1.6.4
1.6.3
1.6.2
1.6.1
1.6.0
1.5.0
1.4.0
1.3.3
1.3.2
1.3.1
1.3.0
1.2.0
1.1.2
1.1.1
1.1.0
1.0.0a9
1.0.0a8
1.0.0a7
1.0.0a6
1.0.0a5
1.0.0a4
1.0.0a3
1.0.0a22
1.0.0a21
1.0.0a20
1.0.0a2
1.0.0a19
1.0.0a18
1.0.0a17
1.0.0a16
1.0.0a15
1.0.0a14
1.0.0a13
1.0.0a12
1.0.0a11
1.0.0a10
1.0.0a1
1.0.0
0.1.99
0.1.98
0.1.97
0.1.96
0.1.95
0.1.94
0.1.93
0.1.92
0.1.91
0.1.90
0.1.9
0.1.89
0.1.87
0.1.86
0.1.85
0.1.84
0.1.83
0.1.82
0.1.81
0.1.80
0.1.79
0.1.78
0.1.77
0.1.76
0.1.75
0.1.74
0.1.73
0.1.72
0.1.71
0.1.70
0.1.69
0.1.68
0.1.67
0.1.66
0.1.65
0.1.64
0.1.63
0.1.62
0.1.61
0.1.60
0.1.6
0.1.59
0.1.58
0.1.57
0.1.56
0.1.55
0.1.54
0.1.53
0.1.52
0.1.51
0.1.50
0.1.49
0.1.48
0.1.47
0.1.46
0.1.45
0.1.44
0.1.43
0.1.42
0.1.41
0.1.40
0.1.4
0.1.39
0.1.38
0.1.37
0.1.36
0.1.35
0.1.34
0.1.33
0.1.324
0.1.323
0.1.322
0.1.321
0.1.320
0.1.32
0.1.319
0.1.318
0.1.317
0.1.316
0.1.315
0.1.314
0.1.312
0.1.311
0.1.310
0.1.31
0.1.309
0.1.308
0.1.307
0.1.306
0.1.305
0.1.304
0.1.303
0.1.302
0.1.301
0.1.300
0.1.30
0.1.299
0.1.295
0.1.294
0.1.293
0.1.292
0.1.291
0.1.290
0.1.29
0.1.289
0.1.288
0.1.287
0.1.286
0.1.285
0.1.284
0.1.283
0.1.282
0.1.281
0.1.280
0.1.28
0.1.279
0.1.277
0.1.276
0.1.275
0.1.274
0.1.273
0.1.272
0.1.271
0.1.270
0.1.27
0.1.269
0.1.268
0.1.267
0.1.266
0.1.265
0.1.264
0.1.263
0.1.262
0.1.261
0.1.260
0.1.26
0.1.259
0.1.258
0.1.257
0.1.256
0.1.255
0.1.254
0.1.253
0.1.252
0.1.251
0.1.250
0.1.25
0.1.249
0.1.248
0.1.247
0.1.246
0.1.245
0.1.244
0.1.243
0.1.242
0.1.241
0.1.240
0.1.24
0.1.239
0.1.238
0.1.237
0.1.236
0.1.235
0.1.234
0.1.233
0.1.232
0.1.231
0.1.230
0.1.23
0.1.229
0.1.228
0.1.227
0.1.226
0.1.225
0.1.224
0.1.223
0.1.222
0.1.221
0.1.220
0.1.22
0.1.219
0.1.218
0.1.217
0.1.216
0.1.215
0.1.214
0.1.213
0.1.212
0.1.211
0.1.210
0.1.21
0.1.209
0.1.208
0.1.207
0.1.206
0.1.205
0.1.204
0.1.203
0.1.202
0.1.201
0.1.200
0.1.2
0.1.199
0.1.198
0.1.197
0.1.196
0.1.195
0.1.194
0.1.193
0.1.192
0.1.191
0.1.190
0.1.19
0.1.189
0.1.188
0.1.187
0.1.186
0.1.185
0.1.184
0.1.183
0.1.182
0.1.181
0.1.180
0.1.179
0.1.178
0.1.177
0.1.176
0.1.175
0.1.174
0.1.173
0.1.172
0.1.171
0.1.170
0.1.17
0.1.169
0.1.168
0.1.167
0.1.166
0.1.165
0.1.164
0.1.163
0.1.162
0.1.161
0.1.160
0.1.16
0.1.159
0.1.158
0.1.157
0.1.156
0.1.155
0.1.154
0.1.153
0.1.151
0.1.150
0.1.15
0.1.149
0.1.148
0.1.147
0.1.146
0.1.145
0.1.144
0.1.143
0.1.142
0.1.141
0.1.140
0.1.14
0.1.139
0.1.138
0.1.137
0.1.136
0.1.135
0.1.134
0.1.133
0.1.132
0.1.131
0.1.130
0.1.13
0.1.129
0.1.128
0.1.127
0.1.126
0.1.125
0.1.124
0.1.123
0.1.122
0.1.121
0.1.120
0.1.119
0.1.118
0.1.117
0.1.116
0.1.115
0.1.114
0.1.113
0.1.112
0.1.111
0.1.110
0.1.11
0.1.109
0.1.108
0.1.107
0.1.106
0.1.105
0.1.104
0.1.103
0.1.102
0.1.101
0.1.100
0.1.10
0.1.0
0.0.1285
توضیحات
The official Python library for the letta API
| ویژگی | مقدار |
|---|---|
| سیستم عامل | POSIX :: Linux |
| نام فایل | letta-client-1.7.8 |
| نام | letta-client |
| نسخه کتابخانه | 1.7.8 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Letta |
| ایمیل نویسنده | - |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/letta-client/ |
| مجوز | Apache-2.0 |
# Letta Python SDK
[](https://pypi.python.org/pypi/letta-client)
Letta is the platform for building stateful agents: open AI with advanced memory that can learn and self-improve over time.
* [Letta Code](https://docs.letta.com/letta-code): run agents locally in your terminal
* [Letta API](https://docs.letta.com/quickstart/): build agents into your applications
## Get started
Install the Letta Python SDK:
```bash
pip install letta-client
```
## Simple Hello World example
Below is a quick example of creating a stateful agent and sending it a message (requires a [Letta API key](https://app.letta.com), or setting `base_url=...` to point at a [Docker server](https://docs.letta.com/guides/docker)).
See the full [quickstart guide](https://docs.letta.com/quickstart) for complete documentation.
```python
from letta_client import Letta
client = Letta(api_key="LETTA_API_KEY")
agent_state = client.agents.create(
model="openai/gpt-4o-mini",
embedding="openai/text-embedding-3-small",
memory_blocks=[
{
"label": "human",
"value": "The human's name is Chad. They like vibe coding."
},
{
"label": "persona",
"value": "My name is Sam, a helpful assistant."
}
],
tools=["web_search", "run_code"]
)
print(agent_state.id)
# agent-d9be...0846
response = client.agents.messages.create(
agent_id=agent_state.id,
messages=[
{
"role": "user",
"content": "Hey, nice to meet you, my name is Brad."
}
]
)
# the agent will think, then edit its memory using a tool
for message in response.messages:
print(message)
# The content of this memory block will be something like
# "The human's name is Brad. They like vibe coding."
# Fetch this block's content with:
human_block = client.agents.blocks.retrieve(agent_id=agent_state.id, block_label="human")
print(human_block.value)
```
## Core concepts in Letta:
Letta is built on the [MemGPT](https://arxiv.org/abs/2310.08560) research paper, which introduced the concept of the "LLM Operating System" for memory management:
1. [**Memory Hierarchy**](https://docs.letta.com/guides/agents/memory): Agents have self-editing memory split between in-context and out-of-context memory
2. [**Memory Blocks**](https://docs.letta.com/guides/agents/memory-blocks): In-context memory is composed of persistent editable blocks
3. [**Agentic Context Engineering**](https://docs.letta.com/guides/agents/context-engineering): Agents control their context window using tools to edit, delete, or search memory
4. [**Perpetual Self-Improving Agents**](https://docs.letta.com/guides/agents/overview): Every agent has a perpetual (infinite) message history
## Key Features
### Memory Management ([full guide](https://docs.letta.com/guides/agents/memory-blocks))
Memory blocks are persistent, editable sections of an agent's context window:
```python
# Create agent with memory blocks
agent = client.agents.create(
memory_blocks=[
{"label": "persona", "value": "I'm a helpful assistant."},
{"label": "human", "value": "User preferences and info."}
]
)
# Update blocks manually
client.agents.blocks.update(
agent_id=agent.id,
block_label="human",
value="Updated user information"
)
# Retrieve a block
block = client.agents.blocks.retrieve(agent_id=agent.id, block_label="human")
```
### Multi-agent Shared Memory ([full guide](https://docs.letta.com/guides/agents/multi-agent-shared-memory))
Memory blocks can be attached to multiple agents. All agents will have an up-to-date view on the contents of the memory block -- if one agent modifies it, the other will see it immediately.
Here is how to attach a single memory block to multiple agents:
```python
# Create shared block
shared_block = client.blocks.create(
label="organization",
value="Shared team context"
)
# Attach to multiple agents
agent1 = client.agents.create(
memory_blocks=[{"label": "persona", "value": "I am a supervisor"}],
block_ids=[shared_block.id]
)
agent2 = client.agents.create(
memory_blocks=[{"label": "persona", "value": "I am a worker"}],
block_ids=[shared_block.id]
)
```
### Sleep-time Agents ([full guide](https://docs.letta.com/guides/agents/architectures/sleeptime))
Background agents that share memory with your primary agent:
```python
agent = client.agents.create(
model="openai/gpt-4o-mini",
enable_sleeptime=True # creates a sleep-time agent
)
```
### Agent File Import/Export ([full guide](https://docs.letta.com/guides/agents/agent-file))
Save and share agents with the `.af` file format:
```python
# Import agent
with open('/path/to/agent.af', 'rb') as f:
agent = client.agents.import_file(file=f)
# Export agent
schema = client.agents.export_file(agent_id=agent.id)
```
### MCP Tools ([full guide](https://docs.letta.com/guides/mcp/overview))
Connect to Model Context Protocol servers:
```python
# First, create an MCP server (example: weather server)
weather_server = client.mcp_servers.create(
server_name="weather-server",
config={
"mcp_server_type": "streamable_http",
"server_url": "https://weather-mcp.example.com/mcp",
}
)
# List tools available from the MCP server
tools = client.mcp_servers.tools.list(weather_server.id)
# Create agent with MCP tool
agent = client.agents.create(
model="openai/gpt-4o-mini",
tool_ids=[tool.id]
)
```
### Filesystem ([full guide](https://docs.letta.com/guides/agents/filesystem))
Give agents access to files:
```python
# Create folder and upload file
folder = client.folders.create(
name="my_folder",
)
with open("file.txt", "rb") as f:
client.folders.files.upload(file=f, folder_id=folder.id)
# Attach to agent
client.agents.folders.attach(agent_id=agent.id, folder_id=folder.id)
```
### Long-running Agents ([full guide](https://docs.letta.com/guides/agents/long-running))
Background execution with resumable streaming:
```python
stream = client.agents.messages.create(
agent_id=agent.id,
messages=[{"role": "user", "content": "Analyze this dataset"}],
background=True
)
run_id = None
last_seq_id = None
for chunk in stream:
run_id = chunk.run_id
last_seq_id = chunk.seq_id
# Resume if disconnected
for chunk in client.runs.stream(run_id=run_id, starting_after=last_seq_id):
print(chunk)
```
### Streaming ([full guide](https://docs.letta.com/guides/agents/streaming))
Stream responses in real-time:
```python
stream = client.agents.messages.stream(
agent_id=agent.id,
messages=[{"role": "user", "content": "Hello!"}]
)
for chunk in stream:
print(chunk)
```
These methods return an [`APIResponse`](https://github.com/letta-ai/letta-python/tree/main/src/letta_client/_response.py) object.
The async client returns an [`AsyncAPIResponse`](https://github.com/letta-ai/letta-python/tree/main/src/letta_client/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
### Message Types ([full guide](https://docs.letta.com/guides/agents/message-types))
Agent responses contain different message types. Handle them with the `message_type` discriminator:
```python
messages = client.agents.messages.list(agent_id=agent.id)
for message in messages:
if message.message_type == "user_message":
print(f"User: {message.content}")
elif message.message_type == "assistant_message":
print(f"Agent: {message.content}")
elif message.message_type == "reasoning_message":
print(f"Reasoning: {message.reasoning}")
elif message.message_type == "tool_call_message":
print(f"Tool: {message.tool_call.name}")
elif message.message_type == "tool_return_message":
print(f"Result: {message.tool_return}")
```
## Python Support
Full type hints and async support:
```python
from letta_client import Letta
from letta_client.types import CreateAgentRequest
# Sync client
client = Letta(api_key="LETTA_API_KEY")
# Async client
from letta_client import AsyncLetta
async_client = AsyncLetta(api_key="LETTA_API_KEY")
agent = await async_client.agents.create(
model="openai/gpt-4o-mini",
memory_blocks=[...]
)
```
## Error Handling
```python
from letta_client.core.api_error import ApiError
try:
client.agents.messages.create(agent_id=agent_id, messages=[...])
except ApiError as e:
print(e.status_code)
print(e.message)
print(e.body)
```
## Advanced Configuration
### Retries
```python
response = client.agents.create(
{...},
request_options={"max_retries": 3} # Default: 2
)
```
### Timeouts
```python
response = client.agents.create(
{...},
request_options={"timeout_in_seconds": 30} # Default: 60
)
```
### Custom Headers
```python
response = client.agents.create(
{...},
request_options={
"additional_headers": {
"X-Custom-Header": "value"
}
}
)
```
### Raw Response Access
```python
response = client.agents.with_raw_response.create({...})
print(response.headers["X-My-Header"])
print(response.data) # access the underlying object
```
### Custom HTTP Client
```python
import httpx
from letta_client import Letta
client = Letta(
httpx_client=httpx.Client(
proxies="http://my.test.proxy.example.com",
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
)
)
```
## Runtime Compatibility
Works with:
- Python 3.8+
- Supports async/await
- Compatible with type checkers (mypy, pyright)
## Contributing
Letta is an open source project built by over a hundred contributors. There are many ways to get involved in the Letta OSS project!
* [**Join the Discord**](https://discord.gg/letta): Chat with the Letta devs and other AI developers.
* [**Chat on our forum**](https://forum.letta.com/): If you're not into Discord, check out our developer forum.
* **Follow our socials**: [Twitter/X](https://twitter.com/Letta_AI), [LinkedIn](https://www.linkedin.com/company/letta-ai/), [YouTube](https://www.youtube.com/@letta-ai)
This SDK is generated programmatically. For SDK changes, please [open an issue](https://github.com/letta-ai/letta-python/issues).
README contributions are always welcome!
## Resources
- [Documentation](https://docs.letta.com)
- [Python API Reference](https://github.com/letta-ai/letta-python/tree/main/./reference.md)
- [Example Applications](https://github.com/letta-ai/letta-chatbot-example)
## License
MIT
---
***Legal notices**: By using Letta and related Letta services (such as the Letta endpoint or hosted service), you are agreeing to our [privacy policy](https://www.letta.com/privacy-policy) and [terms of service](https://www.letta.com/terms-of-service).*
نیازمندی
| مقدار | نام |
|---|---|
| - | anyio<5,>=3.5.0 |
| - | distro<2,>=1.7.0 |
| - | httpx<1,>=0.23.0 |
| - | pydantic<3,>=1.9.0 |
| - | sniffio |
| - | typing-extensions<5,>=4.10 |
| xtr | aiohttp; |
| xtr | httpx-aiohttp>=0.1.9; |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.9 | Python |
نحوه نصب
نصب پکیج whl letta-client-1.7.8:
pip install letta-client-1.7.8.whl
نصب پکیج tar.gz letta-client-1.7.8:
pip install letta-client-1.7.8.tar.gz