Overview
The Batch API provides a way to:- Create a batch container for multiple research tasks
- Add tasks to a batch (can be done incrementally)
- Monitor batch progress and individual task status
- Wait for batch completion with progress callbacks
- Cancel batches and their pending tasks
- List all batches and their tasks
How It Works
The Batch API follows a simple workflow:- Create a Batch - Initialize a new batch with optional configuration
- Add Tasks - Add one or more research tasks to the batch
- Monitor Progress - Check batch status and task counts
- Wait for Completion - Optionally wait for all tasks to complete
- Retrieve Results - Access individual task results through the DeepResearch API
Batch Lifecycle
A batch progresses through the following statuses:open- Batch is created but no tasks are running yetprocessing- At least one task is queued, running, or completedcompleted- All tasks have finished successfullycompleted_with_errors- All tasks finished, but some failedcancelled- Batch was cancelled before completion
API Methods
batch.create(options?)
Creates a new batch container. Returns a batch ID that you’ll use for subsequent operations.
Parameters:
batch.addTasks(batchId, options)
Adds one or more tasks to an existing batch. You can call this multiple times to add tasks incrementally.
Constraints:
- Maximum tasks per request: 100
- Minimum tasks per request: 1
- Batch must be in
"open"or"processing"status
batch.status(batchId)
Gets the current status of a batch, including task counts and cost information.
Response:
batch.listTasks(batchId)
Lists all tasks in a batch with their individual statuses.
Response:
batch.waitForCompletion(batchId, options?)
Waits for a batch to complete by polling its status at regular intervals. This is useful for long-running batches where you want to be notified when all tasks finish.
Parameters:
DeepResearchBatch object when the batch reaches a terminal state (completed, completed_with_errors, or cancelled).
Example:
batch.cancel(batchId)
Cancels a batch and all its pending tasks. Tasks that are already running will continue, but queued tasks will be cancelled.
Response:
batch.list()
Lists all batches associated with your API key.
Response:
Complete Example
Here’s a complete example that demonstrates the full batch workflow:Search Configuration
Search parameters control which data sources are queried, what content is included/excluded, and how results are filtered by date or category. When set at the batch level, these parameters are applied to all tasks in the batch and cannot be overridden by individual tasks.Search Type
Controls which backend search systems are queried for all tasks in the batch:"all"(default): Searches both web and proprietary data sources"web": Searches only web sources (general web search, news, articles)"proprietary": Searches only proprietary data sources (academic papers, finance data, patents, etc.)
Included Sources
Restricts search to only the specified source types for all tasks in the batch. When specified, only these sources will be searched. Tasks inherit this setting and cannot override it. Available source types:"web": General web search results (news, articles, websites)"academic": Academic papers and research databases (ArXiv, PubMed, BioRxiv/MedRxiv, Clinical trials, FDA drug labels, WHO health data, NIH grants, Wikipedia)"finance": Financial and economic data (Stock/crypto/FX prices, SEC filings, Company financial statements, Economic indicators, Prediction markets)"patent": Patent and intellectual property data (USPTO patent database, Patent abstracts, claims, descriptions)"transportation": Transit and transportation data (UK National Rail schedules, Maritime vessel tracking)"politics": Government and parliamentary data (UK Parliament members, bills, votes)"legal": Case law and legal data (UK court judgments, Legislation text)
Excluded Sources
Excludes specific source types from search results for all tasks in the batch. Uses the same source type values asincludedSources. Cannot be used simultaneously with includedSources (use one or the other).
Start Date
Format: ISO date format (YYYY-MM-DD)
Filters search results to only include content published or dated on or after this date for all tasks in the batch. Applied to both publication dates and event dates when available. Works across all source types.
End Date
Format: ISO date format (YYYY-MM-DD)
Filters search results to only include content published or dated on or before this date for all tasks in the batch. Applied to both publication dates and event dates when available. Works across all source types.
Category
Filters results by a specific category for all tasks in the batch. The exact categories available depend on the data source. Category values are source-dependent and may not be applicable to all source types.How Batch Search Parameters Work
All tasks inherit batch search parameters when you add tasks to a batch. They automatically inherit the batch’s search configuration. Individual tasks in a batch cannot override the batch-level search parameters (they inherit them).Important Notes
Parameter Enforcement
Batch-level parameters are enforced and cannot be overridden by individual tasks. This ensures consistent search behavior across all tasks in the batch. Tool-level source specifications are ignored if batch-level sources are specified.Date Filtering
Dates are applied to both publication dates and event dates when available. ISO format (YYYY-MM-DD) is required. Date filtering works across all source types. If only startDate is provided, results include all content from that date forward. If only endDate is provided, results include all content up to that date. Both dates can be combined for a specific date range.
Best Practices
1. Batch Configuration
- Set batch-level search configuration when all tasks use the same search parameters to avoid repetition
- Use metadata to tag batches and tasks for easier organization and filtering
- Choose the right mode:
fastfor quick results,standardfor balanced quality/speed,heavyfor thorough research
2. Task Management
- Add tasks incrementally - You can add tasks to a batch at any time before it’s completed (1-100 tasks per request)
- Use task metadata to track source, category, or other custom attributes
- Tasks inherit batch settings - All tasks inherit
mode,output_formats, andsearch_paramsfrom the batch - Limited task-level options - Tasks can only specify:
id,query,strategy,urls, andmetadata - Not all DeepResearch features available - Batch tasks do not support files, deliverables, MCP servers, or other advanced features
- Monitor task status individually if you need fine-grained control
3. Usage Management
- Monitor cost through the
costfield in batch status - Set appropriate modes based on your research needs
- Use search filters to focus on relevant data
4. Error Handling
- Check
successflags on all API responses - Handle
completed_with_errorsstatus - Some tasks may fail while others succeed - Use try-catch around
waitForCompletionto handle timeouts
5. Webhooks
- Set up webhooks for production use to avoid polling
- Verify webhook signatures using the
webhook_secretreturned on batch creation - Handle webhook retries in your webhook endpoint
6. Performance
- Use appropriate poll intervals - Don’t poll too frequently (10 seconds is reasonable)
- Set reasonable timeouts - Use
maxWaitTimeto prevent indefinite waiting - Process results asynchronously - Don’t block on batch completion if you can process results incrementally
Batch-Level vs Task-Level Parameters
The Batch API supports parameters at two levels:Batch-Level Parameters (set when creating the batch)
mode- Applied to all tasks in the batchoutputFormats- Applied to all taskssearch- Default search configuration for all taskswebhookUrl- Batch completion webhookmetadata- Batch-level metadata
Task-Level Parameters (set when adding tasks)
id- Optional custom task identifier (for tracking)query- The research query (preferred field name)strategy- Task-specific research strategy instructionsurls- URLs to analyze for this taskmetadata- Task-specific metadata
mode- Always inherited from batchoutput_formats- Always inherited from batchsearch_params- Always inherited from batch
search- Tasks cannot override batch-level search configurationfiles- File attachmentsdeliverables- Requested deliverables (CSV, XLSX, PPTX, DOCX)mcpServers- MCP server configurationscodeExecution- Always enabled (cannot disable)previousReports- Previous report referencesbrandCollectionId- Branding configuration
client.deepresearch.create()) instead of batch processing.
Integration with DeepResearch API
Individual tasks in a batch are DeepResearch tasks. You can:- Get task status:
client.deepresearch.status(task.deepresearch_id) - Stream task updates:
client.deepresearch.stream(task.deepresearch_id, callbacks) - Update running tasks:
client.deepresearch.update(task.deepresearch_id, instruction) - Cancel individual tasks:
client.deepresearch.cancel(task.deepresearch_id)
mode, output_formats, and search_params from the batch and cannot override them. Advanced features like files, deliverables, and MCP servers are not available in batch mode. Use client.deepresearch.create() for full feature support.
Error Codes
Common error scenarios:- Batch not found: Invalid
batchId- check that the batch exists - Tasks array empty: Must provide at least one task when adding
- Too many tasks: Maximum 100 tasks per request
- Invalid task input: Task
queryfield is required and cannot be empty - Batch already completed: Cannot add tasks to a completed batch (must be
"open"or"processing") - Timeout:
waitForCompletionexceededmaxWaitTime
Rate Limits
- Batch creation: Standard API rate limits apply
- Adding tasks: Can add tasks multiple times, but rate limits apply per request
- Status polling: Use reasonable poll intervals (10+ seconds recommended)
See Also
- DeepResearch API - For individual task management
- Batch Processing Guide - Complete guide with examples

