When to use Tasks
Tasks is an asynchronous wrapper. It does not make individual calls cheaper or faster than the synchronous endpoints. Reach for it when:- Bulk workloads: CRM enrichment, backfills, batch research over hundreds of queries.
- Long-running jobs: submit and poll later, instead of holding an HTTP connection open.
- Scheduled pipelines: kick off a nightly batch, retrieve results in the morning.
- Mixed batches: combine Search, Fetch, and Research calls in one submission.
- Concurrency overflow: the workload exceeds the synchronous concurrency budget.
Batch sizing
The hard limit is 100 tasks per submission. For larger workloads, submit multiple batches in parallel. There is no penalty for doing so.Polling strategy
Two strategies are appropriate, depending on the workload: Per-task polling (when results must be processed as they arrive):- Mostly
"search"("fast"/"standard") and"fetch": 1–2 second intervals. - Mostly
"research": 5 second intervals, with backoff to 30 seconds for long-running batches. - Mixed: start at 2 seconds, back off to 10.
Error handling
Each task in a batch completes or fails independently. A failure in one task does not fail the batch. Inspecterror on individual tasks and retry
only the failures.
Mixed-endpoint batches
A common pattern combines Search to find URLs and Fetch to read them in one batch.Cost behavior
Tasks does not change pricing. Each task is billed exactly as a direct synchronous call to its endpoint. Tasks is appropriate for workflow benefits, not cost reduction. Cost reduction is achieved by selecting the appropriatedepth ("standard"
over "deep" when the workload allows), using includeDomains to reduce
work, and designing schemas to be shallow.
Result lifetime
Completed task results are retrievable for a bounded period. For long-running pipelines, persist results to durable storage as soon as they complete rather than relying on Tasks for storage.Common pitfalls
Bad → Fix pairs grounded in the documented behavior of Tasks (per-task billing identical to direct calls, 1 rps poll cap, bounded result lifetime). Polling each task individually when the batch is large. Wastes API budget against the 1 rps cap.Bad
Fix
Bad
Fix
taskIds late and losing results to the bounded result
lifetime.
Bad
Fix