---
title: "Tool calling"
description: "Define functions the model can call, execute them in your app, and send results back."
---

> Documentation Index
> Fetch the complete documentation index at: https://truememory-docs.mvstg.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Tool calling

Truememory supports two types of tools on [chat completions](/ai-gateway/chat-completions/) requests:

- **Client tools** — You define them in the `tools` parameter. Truememory returns `tool_calls` for your app to execute locally and send results back.
- **Internal tools** — `memory_search`, `memory_write`, and `memory_get` run server-side, invisible to the client. See [Memory](/memory/overview/).

## Step 1: Send message with tools

```bash
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"`:

```json
{
  "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:

```bash
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"`.

Source: https://truememory-docs.mvstg.com/ai-gateway/features/tool-calling/index.mdx
