Create Message Async
agents.messages.create_async(stragent_id, MessageCreateAsyncParams**kwargs) -> Run
/v1/agents/{agent_id}/messages/async
Asynchronously process a user message and return a run object. The actual processing happens in the background, and the status can be checked using the run ID.
This is "asynchronous" in the sense that it's a background run and explicitly must be fetched by the run ID.
Note: Sending multiple concurrent requests to the same agent can lead to undefined behavior. Each agent processes messages sequentially, and concurrent requests may interleave in unexpected ways. Wait for each request to complete before sending the next one. Use separate agents or conversations for parallel processing.
Parameters
Returns
Create Message Async
import os
from letta_client import Letta
client = Letta(
api_key=os.environ.get("LETTA_API_KEY"), # This is the default and can be omitted
)
run = client.agents.messages.create_async(
agent_id="agent-123e4567-e89b-42d3-8456-426614174000",
)
print(run.id)
{
"id": "run-123e4567-e89b-12d3-a456-426614174000",
"agent_id": "agent_id",
"background": true,
"base_template_id": "base_template_id",
"callback_error": "callback_error",
"callback_sent_at": "2019-12-27T18:11:19.117Z",
"callback_status_code": 0,
"callback_url": "callback_url",
"completed_at": "2019-12-27T18:11:19.117Z",
"conversation_id": "conversation_id",
"created_at": "2019-12-27T18:11:19.117Z",
"metadata": {
"foo": "bar"
},
"request_config": {
"assistant_message_tool_kwarg": "assistant_message_tool_kwarg",
"assistant_message_tool_name": "assistant_message_tool_name",
"include_return_message_types": [
"system_message"
],
"use_assistant_message": true
},
"status": "created",
"stop_reason": "end_turn",
"total_duration_ns": 0,
"ttft_ns": 0
}
Returns Examples
{
"id": "run-123e4567-e89b-12d3-a456-426614174000",
"agent_id": "agent_id",
"background": true,
"base_template_id": "base_template_id",
"callback_error": "callback_error",
"callback_sent_at": "2019-12-27T18:11:19.117Z",
"callback_status_code": 0,
"callback_url": "callback_url",
"completed_at": "2019-12-27T18:11:19.117Z",
"conversation_id": "conversation_id",
"created_at": "2019-12-27T18:11:19.117Z",
"metadata": {
"foo": "bar"
},
"request_config": {
"assistant_message_tool_kwarg": "assistant_message_tool_kwarg",
"assistant_message_tool_name": "assistant_message_tool_name",
"include_return_message_types": [
"system_message"
],
"use_assistant_message": true
},
"status": "created",
"stop_reason": "end_turn",
"total_duration_ns": 0,
"ttft_ns": 0
}