Parallel Function Calls
What you'll learn: How LLMs can request multiple function calls at once and how you handle running them concurrently.
The Core Idea
Until now, you've seen LLMs suggest one function call per response—like asking an assistant to check the weather or set a reminder. But what if the user says "Check the weather in Paris and book me a flight there"? Modern LLMs can detect that these are independent tasks and return multiple function calls in a single response.
This is called parallel function calling. The model identifies functions that don't depend on each other and suggests executing them simultaneously, making your application faster and more efficient.
How It Works
When you send a request with multiple tools defined, the model may return an array of function calls instead of just one:
{
"tool_calls": [
{"id": "call_1", "function": {"name": "get_weather", "arguments": "{\"city\":\"Paris\"}"}},
{"id": "call_2", "function": {"name": "search_flights", "arguments": "{\"destination\":\"Paris\"}"}}
]
}
Your application must:
- Parse all tool calls from the response
- Execute them concurrently (using async patterns or threading)
- Collect all results with their corresponding
ids - Send all results back in one follow-up message
The model uses the IDs to match results with the original requests.
Think of It Like...
Imagine a restaurant where you order soup and salad. A good waiter doesn't prepare one, deliver it, ask what else you want, then prepare the other. They take both orders at once and coordinate the kitchen to prepare them in parallel.
Key Takeaway: Parallel function calls let LLMs request multiple independent tool uses simultaneously, and you must handle concurrent execution and match results by ID when responding.