> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.getraya.app/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.getraya.app/_mcp/server.

# LLM function tools

Voice agents can call **external HTTP APIs** during a conversation. Tools are sent as JSON on create/update:

```json
{
  "tools": {
    "llm_tools": [ /* one or more tool objects */ ]
  }
}
```

On **PATCH**, sending `tools` **replaces the entire** `llm_tools` array. Always **GET** the agent first, edit the list, then PATCH.

## Tool object shape

Each item in `llm_tools` has three parts:

| Part          | Purpose                                                               |
| ------------- | --------------------------------------------------------------------- |
| `type`        | Must be `"function"`                                                  |
| `function`    | What the LLM sees: name, description, JSON Schema parameters          |
| `api_details` | How Raya calls your API: URL, method, headers, optional body template |

### `function` (LLM-facing)

| Field         | Rules                                                                 |
| ------------- | --------------------------------------------------------------------- |
| `name`        | Letters, numbers, underscore only; max 64 chars (e.g. `lookup_order`) |
| `description` | Required; max 1024 chars — tell the model **when** to use the tool    |
| `parameters`  | JSON Schema object: `type` must be `"object"`, `properties` required  |

### Parameter types (`parameters.properties`)

Each parameter is an object with `type` and `description` (description max 1024 chars). Parameter **names** cannot contain spaces (max 128 chars).

| `type`                                   | Notes                                                                                                                             |
| ---------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `string`, `boolean`, `integer`, `number` | Primitives                                                                                                                        |
| `array`                                  | Must include `items: { "type": "<primitive>" }`                                                                                   |
| `object`                                 | May include `properties`, optional `required`, optional `additionalProperties` (boolean). Nested objects: **one level** deep only |

Use `parameters.required` for mandatory argument names (each must exist in `properties`).

### `api_details` (HTTP call)

| Field                | Rules                                                                                                                                                                                                                                                                                                                                                                                                   |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `method`             | `GET`, `POST`, `PUT`, or `DELETE`                                                                                                                                                                                                                                                                                                                                                                       |
| `url`                | Valid URL, max 2048 chars. May use placeholders `{{param_name}}` for each key in `parameters.properties`                                                                                                                                                                                                                                                                                                |
| `header`             | Optional object of string headers                                                                                                                                                                                                                                                                                                                                                                       |
| `payload_template`   | Optional JSON object for **POST/PUT** bodies. Values can be primitives or nested objects; use `"{{param_name}}"` strings to inject arguments. Max 8000 bytes when serialized                                                                                                                                                                                                                            |
| `speak_hold_message` | Optional boolean, default `true`. When `false`, the agent does not say a short hold line (for example "One moment") while this tool runs                                                                                                                                                                                                                                                                |
| `cache_within_call`  | Optional boolean. Default `true` for `GET`, `false` for other methods. When `true`, if the tool is called again in the same call with the same arguments, the agent reuses the earlier result instead of calling your API again. The saved results are cleared whenever a tool runs without reuse. Keep it `false` for tools that change data (create, apply, update) or return something new each time |

Placeholders in the URL must match parameter names. Example: parameter `order_id` → `https://api.example.com/orders/{{order_id}}`.

### Hold message and result reuse

Both settings go in `api_details` and can be left out to use the defaults.

* **`speak_hold_message`** (default `true`): before the tool runs, the agent says a short hold line such as "One moment" so the caller isn't left in silence. Set it to `false` for quick tools, or when the agent already tells the caller what it is doing.
* **`cache_within_call`** (default `true` for `GET`, `false` otherwise): if the tool is called again in the same call with the same arguments, the agent reuses the earlier result instead of calling your API again, which saves the wait. Only successful results are reused, and the saved results are cleared as soon as any tool runs without reuse, so a lookup after a create or update always gets fresh data. Turn it on for read-only tools sent as `POST`; keep it off for tools that change data (create, apply, update) or return something new on every call.

```json
"api_details": {
  "method": "POST",
  "url": "https://your-api.example.com/profile/search",
  "payload_template": { "phone": "{{phone}}" },
  "speak_hold_message": false,
  "cache_within_call": true
}
```

## Example 1 — GET with query placeholder

Look up an order when the caller gives an order ID:

```json
{
  "tools": {
    "llm_tools": [
      {
        "type": "function",
        "function": {
          "name": "lookup_order",
          "description": "Fetch order status when the caller provides their order ID.",
          "parameters": {
            "type": "object",
            "properties": {
              "order_id": {
                "type": "string",
                "description": "Order ID from the caller"
              }
            },
            "required": ["order_id"]
          }
        },
        "api_details": {
          "method": "GET",
          "url": "https://your-api.example.com/orders/{{order_id}}",
          "header": {
            "Accept": "application/json"
          }
        }
      }
    ]
  }
}
```

## Example 2 — POST with payload template

Schedule a callback with two arguments:

```json
{
  "tools": {
    "llm_tools": [
      {
        "type": "function",
        "function": {
          "name": "schedule_callback",
          "description": "Schedule a callback when the caller wants to be contacted later.",
          "parameters": {
            "type": "object",
            "properties": {
              "phone": {
                "type": "string",
                "description": "10-digit mobile number without country code"
              },
              "preferred_time": {
                "type": "string",
                "description": "When the caller wants to be called back"
              }
            },
            "required": ["phone"]
          }
        },
        "api_details": {
          "method": "POST",
          "url": "https://your-api.example.com/callbacks",
          "header": {
            "Content-Type": "application/json"
          },
          "payload_template": {
            "phone": "{{phone}}",
            "preferred_time": "{{preferred_time}}"
          }
        }
      }
    ]
  }
}
```

## Example 3 — Multiple tools on one agent

```json
{
  "name": "Support with tools",
  "instructions": "Help the caller. Use tools when they give an order ID or ask for a callback.",
  "tools": {
    "llm_tools": [
      {
        "type": "function",
        "function": {
          "name": "lookup_order",
          "description": "Look up order status by order ID.",
          "parameters": {
            "type": "object",
            "properties": {
              "order_id": { "type": "string", "description": "Order ID" }
            },
            "required": ["order_id"]
          }
        },
        "api_details": {
          "method": "GET",
          "url": "https://your-api.example.com/orders/{{order_id}}"
        }
      },
      {
        "type": "function",
        "function": {
          "name": "schedule_callback",
          "description": "Book a callback request.",
          "parameters": {
            "type": "object",
            "properties": {
              "phone": { "type": "string", "description": "10-digit mobile" }
            },
            "required": ["phone"]
          }
        },
        "api_details": {
          "method": "POST",
          "url": "https://your-api.example.com/callbacks",
          "payload_template": { "phone": "{{phone}}" },
          "speak_hold_message": false
        }
      }
    ]
  }
}
```

## Common validation errors

| Error                                                  | Fix                                                                                     |
| ------------------------------------------------------ | --------------------------------------------------------------------------------------- |
| `Tool type must be "function"`                         | Set `"type": "function"` on each tool                                                   |
| `Each tool must include a function object`             | Add `function` with `name`, `description`, `parameters`                                 |
| `Tool parameters.properties is required`               | Add `parameters.properties` (can be `{}` only if you have no args — still need the key) |
| `Each tool must include api_details`                   | Add `api_details` with `method` and `url`                                               |
| `URL references unknown parameter(s)`                  | Every `{{name}}` in `url` must match a key in `properties`                              |
| `HTTP method must be GET, POST, PUT, or DELETE`        | Use one of those methods                                                                |
| `api_details.speak_hold_message must be true or false` | Send a JSON boolean, not a string such as `"false"`                                     |
| `api_details.cache_within_call must be true or false`  | Send a JSON boolean, not a string such as `"true"`                                      |

## Testing tools

Use a request inspector such as [https://httpbin.org](https://httpbin.org) while developing: `GET https://httpbin.org/get?order_id={{order_id}}` or `POST https://httpbin.org/post` with a `payload_template`. Replace with your production URL before going live.

## Related docs

* [Language Options](/voice-agents/language-options) · [Voice Options](/voice-agents/voice-options)
* [Core Concepts — Voice and runtime settings](/voice-agents/core-concepts#voice-and-runtime-settings-api)
* [Agents API reference](/api-reference/introduction) — `POST /api/agent`, `PATCH /api/agent/{id}`