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 thefunction_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.
3. Return the actual result
Return a string result asfunction_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 originalresponse.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.