Truememory supports two types of tools on chat completions requests:
- Client tools — You define them in the
toolsparameter. Truememory returnstool_callsfor your app to execute locally and send results back. - Internal tools —
memory_search,memory_write, andmemory_getrun server-side, invisible to the client. See Memory.
Step 1: Send message with tools
curl -X POST https://your-tie-host/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"model": "anthropic/claude-sonnet-4-5",
"messages": [
{"role": "user", "content": "What tasks do I have today?"}
],
"tools": [
{
"type": "function",
"function": {
"name": "list_tasks",
"description": "List user tasks filtered by status",
"parameters": {
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": ["INBOX", "NEXT_UP", "IN_PROGRESS", "WAITING"]
}
}
}
}
}
]
}'Step 2: Response with tool_calls
When the model wants to call a tool, finish_reason is "tool_calls":
{
"choices": [
{
"message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_xyz789",
"type": "function",
"function": {
"name": "list_tasks",
"arguments": "{\"status\": \"INBOX\"}"
}
}
]
},
"finish_reason": "tool_calls"
}
]
}Step 3: Send tool results
Execute the tool locally, then send the result back:
curl -X POST https://your-tie-host/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"model": "anthropic/claude-sonnet-4-5",
"messages": [
{"role": "user", "content": "What tasks do I have today?"},
{"role": "assistant", "content": null, "tool_calls": [{"id": "call_xyz789", "type": "function", "function": {"name": "list_tasks", "arguments": "{\"status\": \"INBOX\"}"}}]},
{"role": "tool", "tool_call_id": "call_xyz789", "content": "[{\"title\": \"Buy groceries\"}, {\"title\": \"Review PR #42\"}]"}
],
"tools": [{"type": "function", "function": {"name": "list_tasks", "parameters": {"type": "object", "properties": {"status": {"type": "string"}}}}}]
}'The model may request multiple rounds of tool calls. Keep sending results until finish_reason is "stop".