Skip to navigation

LLM function tools

How to define tools.llm_tools for voice agents — schema, validation, and examples

View as Markdown

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

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

PartPurpose
typeMust be "function"
functionWhat the LLM sees: name, description, JSON Schema parameters
api_detailsHow Raya calls your API: URL, method, headers, optional body template

function (LLM-facing)

FieldRules
nameLetters, numbers, underscore only; max 64 chars (e.g. lookup_order)
descriptionRequired; max 1024 chars — tell the model when to use the tool
parametersJSON 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).

typeNotes
string, boolean, integer, numberPrimitives
arrayMust include items: { "type": "<primitive>" }
objectMay 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)

FieldRules
methodGET, POST, PUT, or DELETE
urlValid URL, max 2048 chars. May use placeholders {{param_name}} for each key in parameters.properties
headerOptional object of string headers
payload_templateOptional 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_messageOptional boolean, default true. When false, the agent does not say a short hold line (for example “One moment”) while this tool runs
cache_within_callOptional 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.
"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:

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

{
"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

{
"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

ErrorFix
Tool type must be "function"Set "type": "function" on each tool
Each tool must include a function objectAdd function with name, description, parameters
Tool parameters.properties is requiredAdd parameters.properties (can be {} only if you have no args — still need the key)
Each tool must include api_detailsAdd 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 DELETEUse one of those methods
api_details.speak_hold_message must be true or falseSend a JSON boolean, not a string such as "false"
api_details.cache_within_call must be true or falseSend a JSON boolean, not a string such as "true"

Testing tools

Use a request inspector such as 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.