Create a new batch with default settings that will apply to all tasks.Parameters:
Parameter
Type
Default
Description
name
str
None
Optional name for the batch
mode
Literal["fast", "standard", "heavy", "max"]
"standard"
Research mode (preferred): “standard” (default), “heavy” (comprehensive), or “fast” (faster completion). The lite mode is deprecated and maps to standard.
Add tasks to an existing batch. Tasks inherit the batch’s default settings but can override them individually.Parameters:
Parameter
Type
Description
batch_id
str
Batch ID to add tasks to
tasks
List[Union[BatchTaskInput, Dict]]
List of task inputs
Task Input Structure:Each task can be a dictionary or BatchTaskInput object with:
id (optional): User-provided task ID
query (required): Research query or task description
strategy (optional): Natural language research strategy
urls (optional): URLs to extract and analyze
metadata (optional): Custom metadata for this task
Returns:BatchAddTasksResponseExample:
Copy
from valyu.types.deepresearch import BatchTaskInput# Using dictionariestasks = [ {"query": "What are the latest trends in AI?"}, {"query": "Summarize recent developments in quantum computing"}, {"query": "What is the current state of renewable energy?"}]# Or using BatchTaskInput objectstasks = [ BatchTaskInput( id="task-1", query="Analyze OpenAI's latest product launches", strategy="Focus on technical capabilities and market impact", urls=["https://openai.com/blog"], ), BatchTaskInput( id="task-2", query="Analyze Anthropic's Claude AI capabilities", strategy="Focus on safety features and enterprise adoption" )]response = client.batch.add_tasks(batch_id, tasks)if response.success: print(f"Added {response.added} tasks") if response.tasks: print(f"Created tasks: {[t.deepresearch_id for t in response.tasks]}") if response.counts: print(f"Batch counts: {response.counts.total} total, {response.counts.completed} completed")
List all tasks in a batch with their individual statuses. Pass include_output=True to get full output, sources, images, and cost for each task.Parameters:
Parameter
Type
Default
Description
batch_id
str
required
Batch ID to list tasks for
status
str
None
Filter by status: "completed", "failed", "cancelled", "running", "queued"
limit
int
25
Results per page (max: 50)
last_key
str
None
Pagination cursor from previous response
include_output
bool
False
Include full output, sources, images, and cost for each task
Returns:BatchTasksListResponseExample:
Copy
# Lightweight listing (status only)response = client.batch.list_tasks(batch_id)if response.success and response.tasks: for task in response.tasks: print(f"Task ID: {task.task_id or task.deepresearch_id}") print(f"Query: {task.query}") print(f"Status: {task.status}")# Get full output for completed tasksresults = client.batch.list_tasks(batch_id, status="completed", include_output=True)for task in results.tasks: print(f"Task: {task.task_id or task.deepresearch_id}") print(f"Query: {task.query}") print(f"Output: {task.output[:200]}...") print(f"Sources: {len(task.sources)} cited") print(f"Cost: ${task.cost}")# Paginate through all resultslast_key = results.pagination.last_keywhile last_key: next_page = client.batch.list_tasks(batch_id, status="completed", include_output=True, last_key=last_key) for task in next_page.tasks: print(f"Task: {task.deepresearch_id} - {task.query}") last_key = next_page.pagination.last_key
By default, include_output is False, returning a lightweight listing with task status only. Set include_output=True when you need the full output, sources, images, and cost for each task.
Convenience method to create a batch and add tasks in one call. Optionally waits for completion.Parameters:All parameters from create() plus:
Parameter
Type
Default
Description
tasks
List[Union[BatchTaskInput, Dict]]
required
List of task inputs
wait
bool
False
If True, wait for batch to complete before returning
poll_interval
int
10
Seconds between polls when waiting
max_wait_time
int
14400
Maximum wait time in seconds
on_progress
Callable[[BatchStatusResponse], None]
None
Callback for progress updates
Returns:BatchCreateResponseExample:
Copy
tasks = [ {"query": "What is the latest in generative AI?"}, {"query": "Summarize recent ML frameworks"}, {"query": "What are the top AI startups in 2024?"}]# Create and add tasks (don't wait)batch = client.batch.create_and_run( tasks=tasks, name="Quick Research Batch", mode="standard", wait=False)# Or create, add tasks, and wait for completionbatch = client.batch.create_and_run( tasks=tasks, name="Quick Research Batch", mode="standard", wait=True, poll_interval=10, max_wait_time=3600, on_progress=on_progress)