> ## 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.

# Manage research batches

> Manage DeepResearch batches: add up to 100 tasks per request, share configuration, track statuses, paginate results, handle failures and use webhooks.

The Batch API accepts 1-100 DeepResearch tasks per add request and schedules them for processing with shared configuration, unified monitoring, and aggregated cost tracking. Use it for bulk research where many queries share the same mode, output formats, and search settings.

For your first batch, follow the [batch quickstart](https://docs.valyu.ai/guides/deepresearch-batch-quickstart.md). This guide covers shared settings, pagination, failures and completion notifications. Use [individual tasks](https://docs.valyu.ai/guides/deepresearch.md) when you need files, deliverables or MCP servers.

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).

## Workflow: create, add tasks, wait

Create the batch with shared settings, save its `batch_id`, then add queries in requests of up to 100 tasks. Track task counts until the batch reaches a terminal state. Actual concurrency depends on account limits and capacity.

Keep your submitted queries and their task IDs so you can reconcile every input with a completed, failed or cancelled result. Do not treat a completed-only results page as proof that the whole batch succeeded.

## Shared vs per-task configuration

Tasks inherit `mode`, `output_formats`, and `search` from the batch and **cannot override them**. Each task can set its own `research_strategy`, `report_format`, `urls`, and `metadata`.

Mode pricing and search parameters are identical to standard DeepResearch - see the [search configuration](https://docs.valyu.ai/guides/deepresearch.md#search-configuration) section for the full source list, date filters, and category options. Set them in the batch `search` object and they apply to every task.

## Retrieve results

Check the batch status and task counts for failures as well as successes. A completed-only listing omits failed and cancelled tasks; use an unfiltered listing to reconcile every submitted query.

Use `list_tasks` with `include_output=True` to get full outputs. It's paginated; follow `pagination.last_key` for more pages.

```python Python theme={null}
results = valyu.batch.list_tasks(batch_id, status="completed", include_output=True)

for task in results.tasks:
    print(f"Query: {task.query}")
    print(f"Output: {task.output[:200]}...")
    print(f"Sources: {len(task.sources)} cited, cost: {task.cost}")

# Next page
last_key = results.pagination.last_key
while last_key:
    page = valyu.batch.list_tasks(
        batch_id, status="completed", include_output=True, last_key=last_key
    )
    for task in page.tasks:
        print(task.query)
    last_key = page.pagination.last_key
```

```typescript TypeScript theme={null}
const results = await valyu.batch.listTasks(batchId, {
  status: "completed",
  includeOutput: true,
});

for (const task of results.tasks) {
  console.log(`Query: ${task.query}`);
  console.log(`Output: ${task.output?.substring(0, 200)}...`);
  console.log(`Sources: ${task.sources?.length} cited, cost: ${task.cost}`);
}

// Next page
let lastKey = results.pagination.last_key;
while (lastKey) {
  const page = await valyu.batch.listTasks(batchId, {
    status: "completed",
    includeOutput: true,
    lastKey,
  });
  for (const task of page.tasks) console.log(task.query);
  lastKey = page.pagination.last_key;
}
```

```bash cURL theme={null}
curl -X GET "https://api.valyu.ai/v1/deepresearch/batches/${BATCH_ID}/tasks?status=completed&include_output=true&limit=25" \
  -H "X-API-Key: ${VALYU_API_KEY}"
```

> [!TIP]
>
> `include_output` defaults to `false` for a lightweight status-only listing. Set it to `true` only when you need full output, sources, and cost per task.

## Batch and task statuses

| Batch status | Meaning |
| - | - |
| `open` | Created, ready to accept tasks |
| `processing` | At least one task is queued, running, or completed |
| `completed` | All tasks finished successfully |
| `completed_with_errors` | All tasks finished, some failed |
| `cancelled` | Cancelled before completion |

Individual tasks use the standard `queued` / `running` / `completed` / `failed` / `cancelled` states.

## Webhooks

Set a `webhook_url` to get notified when the batch reaches a terminal state (`completed`, `completed_with_errors`, or `cancelled`) instead of polling.

```python theme={null}
batch = valyu.batch.create(
    name="Research Batch",
    mode="standard",
    webhook_url="https://your-domain.com/webhook"
)
# Save the secret immediately - it's only returned once
webhook_secret = batch.webhook_secret
```

## Limitations

The batch API does **not** support `deliverables`, `files`, `mcp_servers`, `previous_reports`, or `alert_email`, and `code_execution` is always on. Use individual task creation (`POST /v1/deepresearch/tasks`) if you need any of these.

Other constraints: 1-100 tasks per request; the batch must be `open` or `processing` to add tasks.

## Billing

Creating a batch is free and holds nothing. Adding tasks holds the mode price of every task in the request against your balance in one all-or-nothing step: either every task is added or none are. If your available balance (after holds for your other queued and running tasks) is too low, you get a `402` whose `error` message starts with `Insufficient credits for N tasks` and states the total cost, your available balance and how many tasks you can afford.

If billing cannot be checked, you get `503` with `{"error": "Billing temporarily unavailable"}` and nothing is added; retry with backoff. A task that waits in the queue for more than 48 hours needs enough balance when it starts, otherwise it fails with an `Insufficient credits - ...` error. Failed tasks are not charged. The batch `cost` field is the sum of its tasks' charges. See [billing and credit holds](https://docs.valyu.ai/guides/deepresearch.md#billing-and-credit-holds).

## Next steps

> [card] [DeepResearch guide](https://docs.valyu.ai/guides/deepresearch.md)
>
> Individual task features: files, deliverables, MCP servers

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

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

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


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