Skip to main content
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.

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.
For this example, map the outfit to a registered image and call the image-change API. See Change the image 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.

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.