#Assistant API parallel tool calls JSON format

1 messages · Page 1 of 1 (latest)

quaint jacinth
#

I'm having trouble finding the expected JSON format for submitting multiple tool outputs at once (without streaming) with the assistant API.

Here's an example of the format I'm currently sending to the threads endpoint with the run ID. This was working with only one tool output. Would greatly appreciate any help!

{
    "tool_outputs": [
        {
            "tool_call_id": "call_abc",
            "output": {
                "success": "true"
            }
        },
        {
            "tool_call_id": "xyz",
            "output": {
                "success": "true"
            }
        }
    ]
}
lunar wigeon
#

^this link provides full code on how to manage parallel function calling with streaming

#

        # Note: the JSON response may not always be valid; be sure to handle errors
        function_name = tool_call['function']['name']
        if function_name not in available_functions:
            return "Function " + function_name + " does not exist"
    
        # Step 3: call the function with arguments if any
        function_to_call = available_functions[function_name]
        function_args = json.loads(tool_call['function']['arguments'])
        function_response = function_to_call(**function_args)

        # Step 4: send the info for each function call and function response to the model
        messages.append(
            {
                "tool_call_id": tool_call['id'],
                "role": "tool",
                "name": function_name,
                "content": function_response,
            }
        )  # extend conversation with function response```