> ## Documentation Index
> Fetch the complete documentation index at: https://docs.60db.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Function Tools

> Let the Realtime model call your functions mid-conversation and speak the result

Function tools let the model ask your app for data or actions during a conversation. Your app runs the function and returns the result. The model then speaks the answer.

## Define tools

Add `tools` to `session`. Each tool uses the OpenAI GA shape.

```json theme={null}
{
  "type": "session.update",
  "session": {
    "type": "realtime",
    "tools": [
      {
        "type": "function",
        "name": "get_order_status",
        "description": "Look up the status of a customer's order by order ID",
        "parameters": {
          "type": "object",
          "properties": {
            "order_id": { "type": "string", "description": "Order ID, for example ORD-1042" }
          },
          "required": ["order_id"]
        }
      }
    ],
    "tool_choice": "auto"
  }
}
```

| `tool_choice` | Behavior |
| - | - |
| `auto` (default) | The model decides whether to call a tool |
| `none` | The model never calls a tool |
| `required` | The model must call a tool on this turn |

## Handle a call

The loop has four steps:

**1. Collect the arguments**

The model streams arguments as `response.function_call_arguments.delta`. Wait for `response.function_call_arguments.done`, which has the full JSON string and `call_id`.

```json theme={null}
{
  "type": "response.function_call_arguments.done",
  "call_id": "call_abc123",
  "name": "get_order_status",
  "arguments": "{\"order_id\":\"ORD-1042\"}"
}
```

**2. Run your function**

Parse `arguments` and run your code. Keep this on your server or in a trusted backend.

**3. Return the output**

Send the result as a `function_call_output` item that uses the same `call_id`:

```json theme={null}
{
  "type": "conversation.item.create",
  "item": {
    "type": "function_call_output",
    "call_id": "call_abc123",
    "output": "{\"status\":\"shipped\",\"eta\":\"2026-10-24\"}"
  }
}
```

**4. Ask for the reply**

Send `response.create`. The model speaks the answer using the output.

```json theme={null}
{ "type": "response.create" }
```

## Example event flow

```
client  → session.update            (tools defined)
client  → input_audio_buffer.append (user asks "Where is order 1042?")
server  → response.function_call_arguments.done
client  → conversation.item.create  (function_call_output, same call_id)
client  → response.create
server  → response.output_audio.delta … response.done
```

## Notes

* `output` must be a string. Return JSON as a string.
* Return an error message in `output` when your function fails, so the model can apologize.
* Keep tool results short. Long results make the reply slower.

> [!WARNING]
>
> MCP tools inside a Realtime session are not supported yet. Define function tools that call your own backend.

## Related

* [Client events](https://docs.60db.ai/realtime/api-reference/client-events.md) for `conversation.item.create` and `response.create`
* [Server events](https://docs.60db.ai/realtime/api-reference/server-events.md) for function call events


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.