call_parallel() is a workflow-composition operation for independent child calls. It submits them concurrently through the gateway, waits for the results, and returns them in the input order instead of forcing the parent to process each request sequentially. section 9.4.2
Use call_parallel() when the parent workflow can fan out work without dependencies between child calls.
- Provide a plain Python list of API paths and request bodies; the list may be built dynamically when earlier work discovers the required fan-out size. section 9.4.2
- Receive results in submission order after the child calls complete, allowing predictable unpacking even when individual response times differ. section 9.4.2
- Reuse call() behavior for retries and response modes; a child failure after retries propagates to the parent workflow. section 9.4.2
Research assistant fan-out
A research workflow sends the same topic to paper, news, and patent search workflows concurrently, unpacks the three ordered results, and passes them to a synthesis model. Each child workflow can scale and retry independently. section 9.4.2
Listing 9.16 Parallel calls to multiple child workflows
@workflow(
name="research_assistant",
api_path="/research",
response_mode="sync",
timeout_seconds=120,
max_retries=2
)
def research_topic(topic):
platform = GenAIPlatform()
results = platform.workflows \
.call_parallel([ #A
("/search/papers",
{"query": topic}),
("/search/news",
{"query": topic}),
("/search/patents",
{"query": topic}),
])
papers, news, patents = results #B
synthesis = platform.models.chat( #C
model="o3",
messages=[{"role": "user",
"content": f"Synthesize research"
f" on {topic}\n"
f"Papers: {papers['results']}\n"
f"News: {news['results']}\n"
f"Patents: {patents['results']}"}]
)
return {
"report": synthesis.content,
"sources": {
"papers": papers["sources"],
"news": news["sources"],
"patents": patents["sources"]
}
}Shows the workflow interface, dynamic request structure, ordered result unpacking, and synthesis step. section 9.4.2
Listing 9.17 Executing multiple workflow calls concurrently
from concurrent.futures import (
ThreadPoolExecutor
)
def call_parallel(self, calls): #A
with ThreadPoolExecutor(
max_workers=len(calls)
) as pool:
futures = [
pool.submit( #B
self.call,
api_path,
body
)
for api_path, body in calls
]
results = []
for future in futures: #C
results.append(
future.result()
)
return resultsShows the thread-pool implementation that submits each call concurrently and collects futures in input order. section 9.4.2
