Skip to main content
This shows the two-step flow used by the current Cookbook: the model returns a function call first, you execute it locally, then send back a function_call_result for the final answer.

1) Initial request (expose your functions)

The response will include a type: "function_call" item with a function_call_id and the arguments for add_numbers.

2) Send back the function result

Execute add_numbers(a, b) locally, then include both the function call item and a function_call_result in a follow-up request:
The assistant will return the final natural-language answer using the function result.
View source on GitHub → 5_function_calling.py