Lesson 4.1
Batch processing at scale
Looping over ten thousand rows with sequential HTTP calls is slow and fragile. The batch endpoints accept a list of complete requests and execute them concurrently on the platform's thread pool. There is one for single agents and one for full swarms:
/v1/agent/batch/completions/v1/swarm/batch/completionstriage_agent = {
"agent_name": "Ticket Triage",
"system_prompt": (
"Classify the support ticket by urgency (low/medium/high) "
"and category. Respond as JSON."
),
"model_name": "gpt-4.1",
"max_loops": 1,
}
payload = [
{"agent_config": triage_agent, "task": ticket}
for ticket in tickets # e.g. thousands of ticket strings
]
response = requests.post(
f"{BASE_URL}/v1/agent/batch/completions",
headers=headers,
json=payload,
)
results = response.json()The swarm batch endpoint works the same way with SwarmSpec objects: fifty due-diligence swarms submitted as one overnight job is the canonical enterprise pattern. Batch endpoints are premium features available on Pro and Ultra plans.