RESTClient
RESTClient
REST client for Letta
Attributes:
base_url
str - Base URL of the REST APIheaders
Dict - Headers for the REST API (includes token)
__init__
Initializes a new instance of Client class.
Arguments:
auto_save
bool - Whether to automatically save changes.user_id
str - The user ID.debug
bool - Whether to print debug information.
agent_exists
Check if an agent exists
Arguments:
agent_id
str - ID of the agentagent_name
str - Name of the agent
Returns:
exists
bool -True
if the agent exists,False
otherwise
create_agent
Create an agent
Arguments:
name
str - Name of the agentembedding_config
EmbeddingConfig - Embedding configurationllm_config
LLMConfig - LLM configurationmemory
Memory - Memory configurationsystem
str - System configurationtools
List[str] - List of toolsinclude_base_tools
bool - Include base toolsmetadata
Dict - Metadatadescription
str - Description
Returns:
agent_state
AgentState - State of the created agent
update_agent
Update an existing agent
Arguments:
agent_id
str - ID of the agentname
str - Name of the agentdescription
str - Description of the agentsystem
str - System configurationtools
List[str] - List of toolsmetadata
Dict - Metadatallm_config
LLMConfig - LLM configurationembedding_config
EmbeddingConfig - Embedding configurationmessage_ids
List[str] - List of message IDsmemory
Memory - Memory configuration
Returns:
agent_state
AgentState - State of the updated agent
rename_agent
Rename an agent
Arguments:
agent_id
str - ID of the agentnew_name
str - New name for the agent
delete_agent
Delete an agent
Arguments:
agent_id
str - ID of the agent to delete
get_agent
Get an agent’s state by it’s ID.
Arguments:
agent_id
str - ID of the agent
Returns:
agent_state
AgentState - State representation of the agent
get_agent_id
Get the ID of an agent by name (names are unique per user)
Arguments:
agent_name
str - Name of the agent
Returns:
agent_id
str - ID of the agent
get_in_context_memory
Get the in-contxt (i.e. core) memory of an agent
Arguments:
agent_id
str - ID of the agent
Returns:
memory
Memory - In-context memory of the agent
update_in_context_memory
Update the in-context memory of an agent
Arguments:
agent_id
str - ID of the agent
Returns:
memory
Memory - The updated in-context memory of the agent
get_archival_memory_summary
Get a summary of the archival memory of an agent
Arguments:
agent_id
str - ID of the agent
Returns:
summary
ArchivalMemorySummary - Summary of the archival memory
get_recall_memory_summary
Get a summary of the recall memory of an agent
Arguments:
agent_id
str - ID of the agent
Returns:
summary
RecallMemorySummary - Summary of the recall memory
get_in_context_messages
Get in-context messages of an agent
Arguments:
agent_id
str - ID of the agent
Returns:
messages
List[Message] - List of in-context messages
user_message
Send a message to an agent as a user
Arguments:
agent_id
str - ID of the agentmessage
str - Message to send
Returns:
response
LettaResponse - Response from the agent
get_archival_memory
Get archival memory from an agent with pagination.
Arguments:
agent_id
str - ID of the agentbefore
str - Get memories before a certain timeafter
str - Get memories after a certain timelimit
int - Limit number of memories
Returns:
passages
List[Passage] - List of passages
insert_archival_memory
Insert archival memory into an agent
Arguments:
agent_id
str - ID of the agentmemory
str - Memory string to insert
Returns:
passages
List[Passage] - List of inserted passages
delete_archival_memory
Delete archival memory from an agent
Arguments:
agent_id
str - ID of the agentmemory_id
str - ID of the memory
get_messages
Get messages from an agent with pagination.
Arguments:
agent_id
str - ID of the agentbefore
str - Get messages before a certain timeafter
str - Get messages after a certain timelimit
int - Limit number of messages
Returns:
messages
List[Message] - List of messages
send_message
Send a message to an agent
Arguments:
message
str - Message to sendrole
str - Role of the messageagent_id
str - ID of the agentname(str)
- Name of the senderstream
bool - Stream the response (default:False
)stream_tokens
bool - Stream tokens (default:False
)
Returns:
response
LettaResponse - Response from the agent
list_humans
List available human block templates
Returns:
humans
List[Human] - List of human blocks
create_human
Create a human block template (saved human string to pre-fill ChatMemory
)
Arguments:
name
str - Name of the human blocktext
str - Text of the human block
Returns:
human
Human - Human block
update_human
Update a human block template
Arguments:
human_id
str - ID of the human blocktext
str - Text of the human block
Returns:
human
Human - Updated human block
list_personas
List available persona block templates
Returns:
personas
List[Persona] - List of persona blocks
create_persona
Create a persona block template (saved persona string to pre-fill ChatMemory
)
Arguments:
name
str - Name of the persona blocktext
str - Text of the persona block
Returns:
persona
Persona - Persona block
update_persona
Update a persona block template
Arguments:
persona_id
str - ID of the persona blocktext
str - Text of the persona block
Returns:
persona
Persona - Updated persona block
get_persona
Get a persona block template
Arguments:
id
str - ID of the persona block
Returns:
persona
Persona - Persona block
get_persona_id
Get the ID of a persona block template
Arguments:
name
str - Name of the persona block
Returns:
id
str - ID of the persona block
delete_persona
Delete a persona block template
Arguments:
id
str - ID of the persona block
get_human
Get a human block template
Arguments:
id
str - ID of the human block
Returns:
human
Human - Human block
get_human_id
Get the ID of a human block template
Arguments:
name
str - Name of the human block
Returns:
id
str - ID of the human block
delete_human
Delete a human block template
Arguments:
id
str - ID of the human block
get_source
Get a source given the ID.
Arguments:
source_id
str - ID of the source
Returns:
source
Source - Source
get_source_id
Get the ID of a source
Arguments:
source_name
str - Name of the source
Returns:
source_id
str - ID of the source
list_sources
List available sources
Returns:
sources
List[Source] - List of sources
delete_source
Delete a source
Arguments:
source_id
str - ID of the source
load_file_into_source
Load a file into a source
Arguments:
filename
str - Name of the filesource_id
str - ID of the sourceblocking
bool - Block until the job is complete
Returns:
job
Job - Data loading job including job status and metadata
create_source
Create a source
Arguments:
name
str - Name of the source
Returns:
source
Source - Created source
list_attached_sources
List sources attached to an agent
Arguments:
agent_id
str - ID of the agent
Returns:
sources
List[Source] - List of sources
update_source
Update a source
Arguments:
source_id
str - ID of the sourcename
str - Name of the source
Returns:
source
Source - Updated source
attach_source_to_agent
Attach a source to an agent
Arguments:
agent_id
str - ID of the agentsource_id
str - ID of the sourcesource_name
str - Name of the source
detach_source
Detach a source from an agent
list_models
List available LLM models
Returns:
models
List[LLMConfig] - List of LLM models
list_embedding_models
List available embedding models
Returns:
models
List[EmbeddingConfig] - List of embedding models
get_tool_id
Get the ID of a tool
Arguments:
name
str - Name of the tool
Returns:
id
str - ID of the tool (None
if not found)
create_tool
Create a tool. This stores the source code of function on the server, so that the server can execute the function and generate an OpenAI JSON schemas for it when using with an agent.
Arguments:
func
callable - The function to create a tool for.name
- (str): Name of the tool (must be unique per-user.)tags
Optional[List[str]], optional - Tags for the tool. Defaults to None.update
bool, optional - Update the tool if it already exists. Defaults to True.
Returns:
tool
Tool - The created tool.
update_tool
Update a tool with provided parameters (name, func, tags)
Arguments:
id
str - ID of the toolname
str - Name of the toolfunc
callable - Function to wrap in a tooltags
List[str] - Tags for the tool
Returns:
tool
Tool - Updated tool
list_tools
List available tools for the user.
Returns:
tools
List[Tool] - List of tools
delete_tool
Delete a tool given the ID.
Arguments:
id
str - ID of the tool
get_tool
Get a tool give its ID.
Arguments:
id
str - ID of the tool
Returns:
tool
Tool - Tool
get_tool_id
Get a tool ID by its name.
Arguments:
id
str - ID of the tool
Returns:
tool
Tool - Tool