How can I see the function that was selected?

I am using the API and I passed the function in JSON format. For my backend, I need a request where I can retrieve which function the assistant selected. Currently, I followed this guide but I can’t manage to retrieve the function. I know how to do it in completions, but not in assistant. Does anyone know which request to make to see this? Thanks :slight_smile:
image


Feel free to ask if you need further assistance!

In your backend, can’t you just add a hook for each function called that then call a “recordFunctionUsed” type of thing?

Welcome to the dev forum, @celia.stelorder.

Once you have defined a function that you want the assistant to consume, you’ll need to create a thread and add messages.

Then, you have to initiate a run.

In the response on the docs, you will see two tool_calls within required_action, which indicates the user query triggered parallel function calling.

How you initiate a run and submit tool_calls will differ depending on whether you are using streaming or not. However, in both cases, all tool_calls need to be submitted at the same time. You can then complete the run by submitting the tool outputs from the functions you called. Pass each tool_call_id referenced in the required_action object to match outputs to each function call.

2 Likes