langchain · difficulty ◆◆
Parallel Tool Calls on OpenRouter
Set it on the model, not just the binding.
You can set parallelism at the model level, not just per binding.
fully AI-generatedThis text is fully AI-generated and was published without human editorial review.$ ChatOpenRouter(..., parallel_tool_calls=True)- 0.2.4
- Release
- Claude 3.5
- Models
- auto
- Reassembly
What it does
bind_tools on the OpenRouter integration exposes parallel_tool_calls=True as a native option. When enabled, the model can fire multiple tool calls in a single response turn instead of a back-and-forth loop. LangChain handles the streaming chunks internally and merges them into complete tool call sequences.
Why it matters
A research agent that fetches a weather API and a news feed at the same time would otherwise serialize those calls, doubling latency. parallel_tool_calls=True lets the model decide when to act in parallel, and LangChain reassembles the chunks automatically.
Example
$ llm = ChatOpenRouter(model="anthropic/claude-3.5-sonnet", openrouter_api_key="<your-key>", parallel_tool_calls=True)
bound = llm.bind_tools([get_weather, get_news])
resp = bound.invoke("Weather in Vienna and top news in AI?")
for call in resp.tool_calls:
print(f" -> {call['name']}({call['args']})")Tool calls made:
-> get_weather({'city': 'Vienna'})
-> get_news({'topic': 'AI'})Both tools are called in a single model round-trip.
Common flags
- ChatOpenRouter.bind_tools
- Bind tools with optional parallel_tool_calls kwarg
- create_openai_functions_chain
- Converts tool definitions into an OpenAI-format function-calling chain
- create_taggingChain
- Structured output via Pydantic schema, an alternative to tool calling
History
A knob finally surfaced
Many OpenRouter models supported parallel tool execution, but LangChain had not exposed the switch for them. This release surfaced it on the constructor and bind_tools, with chunk reassembly handled automatically.
Under the hood
Streaming chunk reassembly
LangChain merges streaming chunks into complete tool call sequences before passing them up the chain, so parallel calls work transparently even over streaming.
Fun facts
Pros & cons
pros
- + Model-level toggle
- + Automatic chunk reassembly
- + Transparent over streaming
cons
- − Behavior varies by model
- − Requires langchain-openrouter 0.2.4+
Takeaways
- 1parallel_tool_calls=True is also settable on the ChatOpenRouter constructor.
- 2Chunk reassembly is automatic.
- 3Different models decide differently whether to parallelize.
Related commands
archive entry — written and published by a scheduled job, never editorially reviewed. Kept for reference: out of the site’s search index, and no ads run here. the reviewed library →
