Back to Blog
Technical Tutorials

Accelerating LLM‑API Interactions with Batch Calls

Speed up AI agents by batching and parallelizing API requests. Learn the patterns, and how MCPify's JSON navigation tools keep the combined results lean.

Herman Sjøberg
Herman Sjøberg
AI Integration Expert
August 27, 202510 min read
LLMAPI performanceMCPBatch ProcessingGPT‑5Parallelization

Key Takeaways

  • Parallel and batched API calls dramatically reduce agent latency
  • Use an API's own batch endpoint where one exists
  • JSON navigation tools keep context windows lean

Accelerating LLM‑API Interactions with Batch Calls

TL;DR: If your AI agent is slow because it hits many endpoints one by one, switch to parallel and batched calls. This post shows both patterns, and how MCPify's JSON navigation tools keep the combined results small enough for GPT‑5 and other LLMs to reason over. You'll ship faster, more responsive agents with less glue code.


Why sequential API calls make LLMs feel slow

When an agent calls five endpoints sequentially, it pays the network cost five times: connection setup, TLS, routing, rate‑limit checks, waiting for each response, and then the next call starts. Even with modern HTTP, each extra round trip adds delay. In contrast, parallel and batched calls collapse that overhead:

  • Parallel: fire requests concurrently so total time approaches the longest single call instead of the sum of all calls.
  • Batched: send multiple operations in a single HTTP request envelope to reduce round trips and shared overhead.

Authoritative sources and industry guidance consistently show parallelism and batching reduce overall latency and speed up data fetching, especially across multiple endpoints.

What we mean by parallel vs batch (and why both matter)

  • Parallel calls Your agent opens multiple requests at once and awaits them together. This is great when you control the client but not the server (the API has no batch endpoint).

  • Batch calls You submit a single request that includes many sub‑operations. This minimizes per‑request overhead and lets the server orchestrate concurrency behind the scenes.

Use both: when the backend supports batching, you win on round‑trip overhead; when it doesn't, parallelize client‑side.


Where MCPify fits

MCPify converts any REST, GraphQL, or proprietary API into an MCP service. When an upstream API has its own batch endpoint, that endpoint becomes a tool like any other, and the agent can call it directly. MCPify's JSON navigation tools then let the agent keep only the fields it needs from the combined result.

Explore the related docs:


Example: from sequential fetches to parallel calls

Imagine an assistant that needs three datasets before drafting a response:

  1. Customer profile (CRM)
  2. Last 5 orders (Commerce)
  3. Current shipment status (Logistics)

The slow baseline: sequential calls (JavaScript)

// Node 18+ with fetch
import { performance } from "node:perf_hooks";

async function getDataSequential(customerId, tracking) {
  const t0 = performance.now();

  const profile = await fetch(`https://api.crm.example.com/customers/${customerId}`).then(r => r.json());
  const orders = await fetch(`https://api.commerce.example.com/orders?customer_id=${customerId}&limit=5`).then(r => r.json());
  const shipping = await fetch(`https://api.logistics.example.com/track?tracking=${encodeURIComponent(tracking)}`).then(r => r.json());

  const t1 = performance.now();
  return { profile, orders, shipping, ms: Math.round(t1 - t0) };
}

getDataSequential("CUST_123", "1Z999AA10123456784").then(res => {
  console.log(`Sequential took ~${res.ms} ms`);
});

Better: client‑side parallel calls with Promise.all

import { performance } from "node:perf_hooks";

async function getDataParallel(customerId, tracking) {
  const t0 = performance.now();

  const [profile, orders, shipping] = await Promise.all([
    fetch(`https://api.crm.example.com/customers/${customerId}`).then(r => r.json()),
    fetch(`https://api.commerce.example.com/orders?customer_id=${customerId}&limit=5`).then(r => r.json()),
    fetch(`https://api.logistics.example.com/track?tracking=${encodeURIComponent(tracking)}`).then(r => r.json())
  ]);

  const t1 = performance.now();
  return { profile, orders, shipping, ms: Math.round(t1 - t0) };
}

getDataParallel("CUST_123", "1Z999AA10123456784").then(res => {
  console.log(`Parallel took ~${res.ms} ms`);
});

Tip: Use MCPify's JSON navigation tools to surgically extract the fields your prompt needs without overfilling the context window. See JSON tools.


Benchmarked pattern: sequential vs parallel

You can adapt the snippets above to produce quick micro‑benchmarks in your environment. Here is a minimal pattern:

async function timeit(label, fn) {
  const t0 = performance.now();
  const out = await fn();
  const t1 = performance.now();
  console.log(`${label}: ~${Math.round(t1 - t0)} ms`);
  return out;
}

await timeit("sequential", () => getDataSequential("CUST_123", "1Z999AA10123456784"));
await timeit("parallel",   () => getDataParallel("CUST_123", "1Z999AA10123456784"));

On a typical dev laptop and average APIs, you might see something like:

sequential: ~1200-1800 ms
parallel:   ~350-600 ms

These numbers are illustrative and will vary with network, backends, rate limits, and payload sizes. The shape of the results is what matters: parallel beats sequential, and server‑side batching, where an API offers it, cuts round trips further.


How to structure batch requests for LLMs

Design your batch payload so the LLM can reason about it easily and safely:

  • Group by intent Combine ops that form one user outcome (for example, "prepare meeting": check calendars, create event, send invites).

  • Keep ops independent when possible Independent sub‑requests maximize parallel speed. If one op depends on another's output, consider a two‑phase approach or let the LLM run a short chain: fetch > compute > batch.

  • Use atomicity deliberately Use all‑or‑nothing semantics where the API offers them, to prevent partial side effects. Accept partial results when partial data is still useful to craft a helpful reply.

  • Budget tokens Request only the fields you need, or immediately post‑process the response with MCPify's JSON tools to discard bulk. This keeps your LLM context lean.

  • Respect rate limits Many public APIs cap payloads per batch and requests per minute; keep concurrency within those caps.


Efficiently combining results in the LLM's context

Once the batched response arrives, your prompt should guide the model to:

  1. Validate each op's status and surface any failed ops succinctly.
  2. Extract only relevant fields (use MCPify's JSON tools: JSONPath, array slicing, field projection).
  3. Summarize large data locally (for example, store raw lists to a reference and keep just aggregates in the context).
  4. Decide whether to do another focused batch (for example, "fetch details for these 3 IDs only, with fields=x,y,z").

A simple tool call for field extraction might look like:

{
  "name": "nav___json_project_fields",
  "arguments": {
    "json": "<_ref from the orders response>",
    "path": "$..orders",
    "columns": ["id", "total_amount", "created_at"]
  }
}

Result: a compact array of {id, total_amount, created_at} ready for the model to reason with, without dragging the entire payload forward.


Why this pays off

Moving from sequential calls to parallel and batch strategies means faster agent responses, fewer user‑visible spinners, and lower token use. This is aligned with well‑known best practices: keep connections warm, minimize round trips, and execute independent network tasks concurrently. API platforms that support batching document the latency benefits clearly, and agents benefit even more because they must coordinate many micro‑requests on every user task.


Implementation checklist

  • Identify agent steps that issue 3+ API calls per user action.
  • Convert independent requests to Promise.all (JS) or asyncio.gather (Python).
  • Use an API's own batch endpoint for repetitive multi‑call patterns, where one exists.
  • Use all‑or‑nothing semantics where atomicity matters.
  • Immediately shrink large responses with JSON path tools.
  • Measure before/after and iterate.

Call to action

MCPify is built on radical transparency for agents: LLMs are the intelligence; we are the plumbing. Let your model decide what to call, when, and how — we'll make the calls fast.


Sources

Who This Article Is For

Developers optimizing AI agent performance and reducing API call latency

About the Author

Herman Sjøberg

Herman Sjøberg

AI Integration Expert

Herman excels at assisting businesses in generating value through AI adoption. With expertise in cloud architecture (Azure Solutions Architect Expert), DevOps, and machine learning, he's passionate about making AI integration accessible to everyone through MCPify.

Connect on LinkedIn