> ## Documentation Index
> Fetch the complete documentation index at: https://docs.valyu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript SDK: DeepResearch batch

> Run many DeepResearch tasks in parallel from TypeScript with the Batch API: shared configuration, progress monitoring, webhooks and per-task results.

Run many DeepResearch tasks in parallel under one shared configuration, with progress monitoring.

Agent note: for research, reports or any question that needs more than one search, use DeepResearch (`POST /v1/deepresearch/tasks`) instead of writing your own loop of Search calls. Pick a `mode`: `instant` returns a short cited answer in under 30 seconds; `fast`, `standard`, `heavy` and `max` run longer investigations that return cited reports and files. Use Search when your own model needs raw results to reason over. Docs index: [/llms.txt](https://docs.valyu.ai/llms.txt). Append `.md` to any page URL for Markdown. Docs MCP server: `https://docs.valyu.ai/mcp`. Integration guide for coding agents: [/AGENTS.md](https://docs.valyu.ai/AGENTS.md).

> [!NOTE]
>
> For the batch lifecycle and best practices, see the [Batch Processing Guide](https://docs.valyu.ai/guides/deepresearch-batching.md). This page is the TypeScript SDK reference. [HITL](https://docs.valyu.ai/guides/deepresearch-hitl.md) checkpoints are not available for batches - use individual `deepresearch.create()` tasks for those.

## Quick start

Create a batch, add 1-100 tasks, then wait for completion:

```typescript theme={null}
import { Valyu } from "valyu-js";

const client = new Valyu();

const batch = await client.batch.create({ name: "Research Batch", mode: "standard" });
if (!batch.success || !batch.batch_id) throw new Error(batch.error);

await client.batch.addTasks(batch.batch_id, {
  tasks: [
    { query: "Research AI trends" },
    { query: "Analyze market data" },
  ],
});

const finalBatch = await client.batch.waitForCompletion(batch.batch_id, {
  onProgress: (b) => console.log(`${b.counts.completed}/${b.counts.total} completed`),
});

const results = await client.batch.listTasks(batch.batch_id, { status: "completed", includeOutput: true });
for (const t of results.tasks ?? []) {
  console.log(t.query, "->", t.output?.substring(0, 200), "cost:", t.cost);
}
```

## Reference

> [accordion] Methods
>
> | Method | Description |
> | - | - |
> | `batch.create({ name, mode, outputFormats, search, webhookUrl, metadata })` | Create an empty batch container |
> | `batch.addTasks(batchId, { tasks })` | Add 1-100 tasks. Batch must be `open` or `processing` |
> | `batch.status(batchId)` | Current status, task counts, and cost |
> | `batch.listTasks(batchId, { status?, includeOutput?, limit?, lastKey? })` | List tasks; set `includeOutput: true` for full output, sources, images, cost |
> | `batch.waitForCompletion(batchId, { pollInterval?, maxWaitTime?, onProgress? })` | Block until terminal state |
> | `batch.cancel(batchId)` | Cancel the batch and its pending tasks |
> | `batch.list()` | List batches for your API key |
>
> Batch-level `mode`, `outputFormats`, and `search` are inherited by every task and cannot be overridden per-task. Per-task you can set `researchStrategy`, `reportFormat`, `urls`, and `metadata`.
>
> Individual tasks are DeepResearch tasks - use `deepresearch.status(task.deepresearch_id)`, `deepresearch.update(...)`, or `deepresearch.cancel(...)` on them directly.

> [accordion] Search configuration
>
> The batch-level `search` config applies to all tasks:
>
> ```typescript theme={null}
> const batch = await client.batch.create({
>   name: "Academic Research",
>   mode: "standard",
>   search: {
>     includedSources: ["academic", "finance"],
>     startDate: "2024-01-01",
>     endDate: "2024-12-31",
>   },
> });
> ```
>
> See the [Batch Processing Guide](https://docs.valyu.ai/guides/deepresearch-batching.md#shared-vs-per-task-configuration) for all options.

> [accordion] Task input and listing results
>
> ```typescript theme={null}
> await client.batch.addTasks(batchId, {
>   tasks: [
>     { query: "How do public companies describe supply chain concentration risks?" },
>     {
>       query: "Compare renewable energy trends across Europe",
>       researchStrategy: "Focus on policy and adoption rates",
>       urls: ["https://example.com/report.pdf"],
>     },
>   ],
> });
>
> // Full output for completed tasks
> const results = await client.batch.listTasks(batchId, { status: "completed", includeOutput: true });
> for (const task of results.tasks ?? []) {
>   console.log(task.task_id || task.deepresearch_id, task.query);
>   console.log(task.output?.substring(0, 200), `(${task.sources?.length} sources, $${task.cost})`);
> }
>
> // Paginate
> let lastKey = results.pagination?.last_key;
> while (lastKey) {
>   const page = await client.batch.listTasks(batchId, { status: "completed", includeOutput: true, lastKey });
>   for (const task of page.tasks ?? []) {
>     console.log(task.query, task.output, task.cost);
>   }
>   lastKey = page.pagination?.last_key;
> }
> ```

> [accordion] Response types
>
> ```typescript theme={null}
> interface DeepResearchBatch {
>   batch_id: string;
>   name?: string;
>   status: "open" | "processing" | "completed" | "completed_with_errors" | "cancelled";
>   mode: "fast" | "standard" | "heavy" | "max";
>   output_formats?: ("markdown" | "pdf" | "toon" | Record<string, any>)[];
>   search_params?: { search_type?: string; included_sources?: string[] };
>   counts: { total: number; queued: number; running: number; completed: number; failed: number; cancelled: number };
>   cost: number;
>   created_at: string;
>   completed_at?: string;
>   webhook_secret?: string;  // creation only
> }
>
> // BatchTaskListItem (fields beyond status appear only when includeOutput is true):
> interface BatchTaskListItem {
>   task_id?: string;
>   deepresearch_id: string;
>   query: string;
>   status: DeepResearchStatus;
>   output_type?: string;
>   output?: string;
>   sources?: Source[];
>   images?: string[];
>   pdf_url?: string;
>   cost?: number;
>   error?: string;
> }
> ```

## Webhooks

Pass `webhookUrl` on `create()` to be notified when the batch reaches a terminal state (`completed`, `completed_with_errors`, or `cancelled`) instead of polling. The `webhook_secret` is returned only on creation - store it immediately.

## Limitations

> [!WARNING]
>
> Batch tasks do not support `files`, `deliverables`, `mcpServers`, `previousReports`, or HITL. Use `client.deepresearch.create()` for those.

| Constraint | Value |
| - | - |
| Tasks per request | 1-100 |
| Batch status to add tasks | `open` or `processing` |

## See also

> [card] [Batch Processing Guide](https://docs.valyu.ai/guides/deepresearch-batching.md)
>
> Lifecycle, best practices, and examples

> [card] [DeepResearch API](https://docs.valyu.ai/sdk/typescript-sdk/deepresearch.md)
>
> Individual task API with all features

> [card] [Python SDK](https://docs.valyu.ai/sdk/python-sdk/deepresearch-batch.md)
>
> Python batch methods

> [card] [API Reference](https://docs.valyu.ai/api-reference/endpoint/deepresearch-batch-create.md)
>
> REST endpoint documentation


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.