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

# Add tools to the character

Tool calling lets the character use your application’s capabilities. The model requests an operation; your application validates it, executes it, and returns the result.

### 1. Define an available operation

`change_outfit` is an application-defined function. This example offers a pink skirt and a floral dress. Add the definition to `conversation.tools` in the session request.

```json wrap theme={null}
{
  "conversation": {
    "tools": [
      {
        "type": "function",
        "name": "change_outfit",
        "description": "Switch the avatar to a prepared outfit image after an explicit user request.",
        "parameters": {
          "type": "object",
          "properties": {
            "outfit": {
              "type": "string",
              "enum": [
                "pink_skirt",
                "floral_dress"
              ]
            }
          },
          "required": [
            "outfit"
          ],
          "additionalProperties": false
        }
      }
    ]
  }
}
```

### 2. Receive and execute the call

Handle the function\_call in `response.output_item.done`. Parse arguments as a JSON string, validate the tool name and allowed values, then execute your business function. Deduplicate by session ID and call\_id.

```json theme={null}
{
  "type": "response.output_item.done",
  "response_id": "resp_outfit_01",
  "output_index": 0,
  "item": {
    "type": "function_call",
    "name": "change_outfit",
    "call_id": "call_outfit_01",
    "arguments": "{\"outfit\":\"floral_dress\"}"
  }
}
```

For this example, map the outfit to a registered image and call the image-change API. See [Change the image](/streaming-avatar/interaction/outfits-and-scenes) for registration and update steps. Tool calling does not execute the business operation automatically.

### 3. Return the actual result

Return a string result as function\_call\_output using the original call\_id. For image changes, wait for the corresponding session.update.done status; session.updated only confirms acceptance. Return failures, cancellations, and unconfirmed timeouts as such.

```json wrap theme={null}
{
  "event_id": "tool_result_01",
  "type": "conversation.item.create",
  "item": {
    "id": "outfit_result_01",
    "type": "function_call_output",
    "call_id": "call_outfit_01",
    "output": "{\"status\":\"completed\",\"outfit\":\"floral_dress\",\"source_image_id\":\"look_floral_dress\"}"
  }
}
```

### 4. Continue the reply

Wait for the original response.done and the matching conversation.item.created acknowledgement for every tool result in that response, then send response.create once. Track continuation by response\_id rather than continuing after each tool.

```json theme={null}
{
  "event_id": "continue_outfit_01",
  "type": "response.create",
  "response": {
    "scheduling_policy": "after_current_response"
  }
}
```
