Function Call Request

Server-initiated message requesting a function call, to be handled by either client or server

Voice Agent

The FunctionCallRequest message is sent by the Voice Agent server to request a function call. The handling of this call—whether the server executes it or expects the client to—depends on the client_side flag.

Purpose

This message is used to trigger either a built-in server-side function or a custom function defined by the client.

  • When client_side is false, the server will handle the function using built-in logic.
  • When client_side is true, the client must handle the function and respond with a FunctionCallResponse.

Handling the message

The client_side property is set by the server to indicate where the function should be executed.

When your client receives a FunctionCallRequest:

  1. Check the client_side field.
  2. If it’s true, call the appropriate client-defined function.
  3. Return a FunctionCallResponse message with the function result.
  4. If it’s false, no client action is needed; the server will handle it internally.

Example payload

1{
2 "type": "FunctionCallRequest",
3 "functions": [
4 {
5 "id": "fc_12345678-90ab-cdef-1234-567890abcdef",
6 "name": "get_weather",
7 "arguments": "{\"location\": \"Fremont, CA 94539\"}",
8 "client_side": true
9 }
10 ]
11}

In this example, the server is requesting that the client execute a function named get_weather with the given arguments.

Built with