Use asyncio.gather with a shared httpx.AsyncClient (created once in the lifespan and reused for connection pooling), and set timeouts.
import asyncio
import httpx
@app.get("/aggregate")
async def aggregate():
async with httpx.AsyncClient(timeout=5.0) as client: # better: reuse one client from lifespan
r1, r2 = await asyncio.gather(client.get(URL_A), client.get(URL_B))
return {"a": r1.json(), "b": r2.json()}Use return_exceptions=True when partial results are acceptable, and a semaphore to cap concurrency against rate-limited services.