Task 4.6
Batch vs Synchronous Processing
Choosing the right processing mode for review workloads
📘What You Need to Know
Two API Modes for Review Workloads
Claude offers synchronous Messages API calls (immediate response) and the Message Batches API (queued processing with up to a 24-hour window). Both run the same models with the same quality — the difference is latency, cost, and integration pattern. Choosing the wrong mode for your workload creates either blocked developers or unnecessary cost.
The exam tests this decision frequently across Domains 3 and 4. The key question is always: does a human or system need the result before proceeding?
When to Use Synchronous Processing
Synchronous API calls return results in seconds. Use them when the workflow blocks on the review result: PR review before merge, real-time code feedback in the IDE, interactive compliance checks during editing, and any CI/CD gate that prevents deployment until review passes.
The developer or pipeline waits for the response. Latency matters more than cost in these scenarios because blocked workflows have higher business cost than API pricing.
- •Blocking PR review — must complete before merge
- •Real-time feedback during development
- •CI/CD gates that block deployment on findings
- •Interactive compliance checks with immediate results
When to Use Batch Processing
The Message Batches API queues requests and processes them within a 24-hour window. It offers approximately 50% cost savings compared to synchronous calls. Use it for workloads where timing is flexible: nightly code audits, weekly compliance scans, bulk document extraction, and retrospective analysis of merged PRs.
Batch processing uses custom_id to track individual requests within a batch. Results arrive asynchronously — your system polls or receives a webhook when the batch completes.
Batch = 50% cost savings, 24-hour window. Sync = immediate results. Match the mode to whether the workflow blocks on the response.
Decision Framework
Ask one question: does anything block until this review completes? If yes → synchronous. If no → batch. A PR review blocks the developer → sync. A weekly audit of all merged PRs from the past 7 days does not block anyone → batch.
Some systems use both: synchronous for PR gates, batch for nightly comprehensive scans that catch issues the fast PR review might miss. This hybrid approach optimizes cost without sacrificing developer velocity.
# Decision matrix
| Workload | Mode | Why |
|-----------------------------|--------|------------------------------|
| PR review before merge | Sync | Blocks developer |
| Real-time IDE feedback | Sync | Interactive, immediate |
| CI/CD deployment gate | Sync | Pipeline waits for result |
| Nightly full codebase audit | Batch | No one waiting, 50% savings |
| Weekly compliance scan | Batch | Scheduled, non-urgent |
| Bulk invoice extraction | Batch | High volume, flexible timing |Common Integration Mistakes
The most frequent mistake is using batch for blocking workflows — a developer waiting for PR review cannot wait 24 hours. The second mistake is using sync for high-volume non-urgent work — paying double for nightly scans that could run overnight via batch.
There is no "batch with priority flag" that gives sync latency at batch pricing. The exam may present this as a distractor. The modes are fundamentally different in latency guarantees.
No priority flag makes batch synchronous. If the workflow blocks, you must use the Messages API directly.
⚠️Exam Traps
Trap: Using batch API when results are needed before merge or deployment
Why it's wrong: Batch has up to a 24-hour processing window — blocking workflows cannot wait.
Trap: Using synchronous API for nightly audits of thousands of files
Why it's wrong: Paying full price for non-urgent bulk work that could run overnight at 50% savings.
Trap: "Batch with priority flag" for faster PR review at reduced cost
Why it's wrong: No such option exists — batch and sync have fundamentally different latency guarantees.
Trap: Assuming batch produces lower-quality results than synchronous
Why it's wrong: Both modes use the same models — quality is identical, only latency and cost differ.
✓Concept Check
A PR review must complete before the developer can merge. The team also runs a weekly compliance scan of all merged code. Which API modes should they use?
🔨Build Exercise
Beginner25 minutesClassify Workloads by API Mode
What you'll learn
- •Match review workloads to sync or batch API mode
- •Apply the blocking vs non-blocking decision framework
- •Design hybrid pipelines using both modes