Claude Function Calling: Parallel Tools Example
Claude can call more than one tool in a single response turn. Instead of asking for a weather lookup, waiting for your result, then asking for a currency conversion, Claude can request both at once — and you execute them concurrently instead of serially. This is what "parallel tool use" means in Claude's function calling, and it's the pattern behind most production agents that need to hit several APIs per user request.
This article shows a working example: how to define multiple tools, how Claude returns multiple tool_use blocks in one response, and how to execute them in parallel and send the results back correctly.
How parallel tool calls work in Claude's API
When you give Claude a tools array with more than one tool definition, and the user's message plausibly requires multiple independent lookups, Claude's response can contain several tool_use content blocks inside a single assistant message — not several separate API calls. Your job is to:
- Parse all
tool_useblocks from the response. - Execute the corresponding functions, ideally concurrently.
- Send back one
usermessage containing atool_resultblock for eachtool_useblock, matched bytool_use_id. - Let Claude produce the final answer using all results.
The key detail developers get wrong: Claude expects all tool results in the next message before it continues. You can't reply with just one result and expect a sane follow-up — if two tools were called, send two results.
Defining multiple tools
{
"model": "claude-opus-4-5",
"max_tokens": 1024,
"tools": [
{
"name": "get_weather",
"description": "Get current weather for a city",
"input_schema": {
"type": "object",
"properties": {
"city": { "type": "string" }
},
"required": ["city"]
}
},
{
"name": "convert_currency",
"description": "Convert an amount from one currency to another",
"input_schema": {
"type": "object",
"properties": {
"amount": { "type": "number" },
"from": { "type": "string" },
"to": { "type": "string" }
},
"required": ["amount", "from", "to"]
}
}
],
"messages": [
{
"role": "user",
"content": "What's the weather in Tokyo, and how much is 100 USD in JPY?"
}
]
}
A prompt like this is intentionally designed to trigger two unrelated lookups, so Claude is likely to emit both tool_use blocks in the same assistant turn.
Parsing and executing in parallel
Claude's response looks like this (trimmed):
{
"role": "assistant",
"content": [
{ "type": "text", "text": "I'll look both of those up." },
{ "type": "tool_use", "id": "toolu_01A", "name": "get_weather", "input": { "city": "Tokyo" } },
{ "type": "tool_use", "id": "toolu_01B", "name": "convert_currency", "input": { "amount": 100, "from": "USD", "to": "JPY" } }
]
}
In JavaScript, extract every tool_use block and run the functions concurrently with Promise.all:
const toolUses = response.content.filter(b => b.type === "tool_use");
const results = await Promise.all(
toolUses.map(async (block) => {
const output = await callLocalFunction(block.name, block.input);
return {
type: "tool_result",
tool_use_id: block.id,
content: JSON.stringify(output)
};
})
);
callLocalFunction is just a dispatcher:
async function callLocalFunction(name, input) {
if (name === "get_weather") return getWeather(input.city);
if (name === "convert_currency") return convertCurrency(input);
throw new Error(`Unknown tool: ${name}`);
}
Because the lookups are independent, running them with Promise.all instead of await-ing them one by one is what actually makes this "parallel" — the model only emits the requests together, your code decides whether they run concurrently or sequentially.
Sending results back
Append the original assistant message and a new user message containing all tool_result blocks, in the same order Claude expects (matching by tool_use_id, not array position, though keeping order consistent is good practice):
messages.push(response.content ? { role: "assistant", content: response.content } : null);
messages.push({ role: "user", content: results });
Then call the API again with the full messages array, same tools definition. Claude will read both results and compose one final answer referencing the weather and the conversion.
Why this matters for cost and latency
Parallel tool calls reduce round trips. Without it, a two-lookup question costs you two full model turns (model → tool → model → tool → model). With parallel calls, it's one model turn to request both tools, one batch of concurrent function execution, and one final model turn — three steps instead of five. For agents with several tools (search, calculator, database lookup, calendar), this difference compounds quickly, especially under rate limits or per-token billing.
If you're running this kind of multi-tool agent behind your own product, you'll also want clean API key separation per environment, usage visibility per tool call, and streaming for the final response so users aren't staring at a spinner while four tools resolve. SubToAPI wraps your Claude access in exactly that: scoped sub_live_ keys, streaming, and tool-use support you can call like a normal REST API — see the tool use docs and the streaming docs for the request/response shapes.
A note on forcing or limiting parallel calls
You can't force Claude to always call tools in parallel — it decides based on whether the task is actually parallelizable. If the second tool call depends on the output of the first (e.g., "convert the price you get from get_weather's city into JPY"), Claude will correctly call them sequentially instead. Don't fight this; design tool schemas so dependent steps are naturally sequential and independent steps are naturally parallel, and the model will route calls efficiently on its own.
Questions
Does Claude always call tools in parallel when multiple tools are available? No. It calls tools in parallel only when the task has independent sub-tasks. Dependent tasks are still called sequentially across separate turns.
What happens if I only send back one tool_result when two tool_use blocks were returned? The next turn will likely fail or produce an incomplete answer — Claude expects a matching tool_result for every tool_use id before continuing.
Can I test parallel tool calls without writing a full agent loop? Yes — send a single prompt designed to need two unrelated lookups and inspect the raw response content array; if it contains more than one tool_use block, parallel calling occurred. See the messages docs for the exact response schema, or start from the quickstart if you're setting this up from scratch.