Skip to content
Letta Platform Letta Platform Letta Docs
Sign up

Send Message to Environment

environments.send_message(strconnection_id, EnvironmentSendMessageParams**kwargs) -> EnvironmentSendMessageResponse
post/v1/environments/{connectionId}/messages

Send a message to a specific environment connection

ParametersExpand Collapse
connection_id: str
messages: Iterable[Message]
Accepts one of the following:
class MessageUnionMember0:
client_message_id: str
content: Union[str, Iterable[MessageUnionMember0ContentUnionMember1]]
Accepts one of the following:
str
Iterable[MessageUnionMember0ContentUnionMember1]
text: str
type: Literal["text"]
role: Literal["user"]
otid: Optional[str]
class MessageUnionMember1:
approvals: Iterable[MessageUnionMember1Approval]
Accepts one of the following:
class MessageUnionMember1ApprovalUnionMember0:
status: Literal["success", "error"]
Accepts one of the following:
"success"
"error"
tool_call_id: str
tool_return: Union[str, Iterable[MessageUnionMember1ApprovalUnionMember0ToolReturnUnionMember1]]
Accepts one of the following:
str
Iterable[MessageUnionMember1ApprovalUnionMember0ToolReturnUnionMember1]
text: str
type: Literal["text"]
stderr: Optional[SequenceNotStr[str]]
stdout: Optional[SequenceNotStr[str]]
type: Optional[Literal["tool"]]
class MessageUnionMember1ApprovalUnionMember1:
approve: bool
tool_call_id: str
reason: Optional[str]
type: Optional[Literal["approval"]]
updated_input: Optional[Dict[str, object]]
type: Literal["approval"]
agent_id: Optional[str]
conversation_id: Optional[str]
ReturnsExpand Collapse
class EnvironmentSendMessageResponse:
message: str
success: bool
Send Message to Environment
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
)
response = client.environments.send_message(
    connection_id="connectionId",
    messages=[{
        "client_message_id": "client_message_id",
        "content": "string",
        "role": "user",
    }],
)
print(response.message)
{
  "message": "message",
  "success": true
}
Returns Examples
{
  "message": "message",
  "success": true
}