Skip to main content
POST
/
v1
/
deepresearch
/
batches
/
{id}
/
tasks
Add tasks to a batch
curl --request POST \
  --url https://api.valyu.ai/v1/deepresearch/batches/{id}/tasks \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "tasks": [
    {
      "query": "Analyze Tesla Q4 2024 earnings and forward guidance",
      "id": "task-tesla"
    },
    {
      "query": "Analyze Apple Q4 2024 earnings and iPhone sales",
      "id": "task-apple"
    },
    {
      "query": "Analyze Microsoft Q4 2024 earnings and Azure growth",
      "id": "task-msft"
    }
  ]
}
'
import requests

url = "https://api.valyu.ai/v1/deepresearch/batches/{id}/tasks"

payload = { "tasks": [
{
"query": "Analyze Tesla Q4 2024 earnings and forward guidance",
"id": "task-tesla"
},
{
"query": "Analyze Apple Q4 2024 earnings and iPhone sales",
"id": "task-apple"
},
{
"query": "Analyze Microsoft Q4 2024 earnings and Azure growth",
"id": "task-msft"
}
] }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
tasks: [
{query: 'Analyze Tesla Q4 2024 earnings and forward guidance', id: 'task-tesla'},
{query: 'Analyze Apple Q4 2024 earnings and iPhone sales', id: 'task-apple'},
{query: 'Analyze Microsoft Q4 2024 earnings and Azure growth', id: 'task-msft'}
]
})
};

fetch('https://api.valyu.ai/v1/deepresearch/batches/{id}/tasks', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.valyu.ai/v1/deepresearch/batches/{id}/tasks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'tasks' => [
[
'query' => 'Analyze Tesla Q4 2024 earnings and forward guidance',
'id' => 'task-tesla'
],
[
'query' => 'Analyze Apple Q4 2024 earnings and iPhone sales',
'id' => 'task-apple'
],
[
'query' => 'Analyze Microsoft Q4 2024 earnings and Azure growth',
'id' => 'task-msft'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.valyu.ai/v1/deepresearch/batches/{id}/tasks"

payload := strings.NewReader("{\n \"tasks\": [\n {\n \"query\": \"Analyze Tesla Q4 2024 earnings and forward guidance\",\n \"id\": \"task-tesla\"\n },\n {\n \"query\": \"Analyze Apple Q4 2024 earnings and iPhone sales\",\n \"id\": \"task-apple\"\n },\n {\n \"query\": \"Analyze Microsoft Q4 2024 earnings and Azure growth\",\n \"id\": \"task-msft\"\n }\n ]\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.valyu.ai/v1/deepresearch/batches/{id}/tasks")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"tasks\": [\n {\n \"query\": \"Analyze Tesla Q4 2024 earnings and forward guidance\",\n \"id\": \"task-tesla\"\n },\n {\n \"query\": \"Analyze Apple Q4 2024 earnings and iPhone sales\",\n \"id\": \"task-apple\"\n },\n {\n \"query\": \"Analyze Microsoft Q4 2024 earnings and Azure growth\",\n \"id\": \"task-msft\"\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.valyu.ai/v1/deepresearch/batches/{id}/tasks")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"tasks\": [\n {\n \"query\": \"Analyze Tesla Q4 2024 earnings and forward guidance\",\n \"id\": \"task-tesla\"\n },\n {\n \"query\": \"Analyze Apple Q4 2024 earnings and iPhone sales\",\n \"id\": \"task-apple\"\n },\n {\n \"query\": \"Analyze Microsoft Q4 2024 earnings and Azure growth\",\n \"id\": \"task-msft\"\n }\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "batch_id": "batch_a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "added": 5,
  "tasks": [
    {
      "task_id": "<string>",
      "deepresearch_id": "<string>",
      "status": "queued"
    }
  ],
  "counts": {
    "total": 10,
    "queued": 3,
    "running": 2,
    "completed": 4,
    "failed": 1,
    "cancelled": 0
  }
}
{
"success": false,
"error": "Invalid request parameters"
}
{
"success": false,
"error": "Invalid API key"
}
{
"success": false,
"error": "Insufficient credits. Please top up your account at platform.valyu.ai"
}
{
"success": false,
"error": "API key does not have inference permission"
}
{
"success": false,
"error": "Task not found"
}
{
"success": false,
"error": "Internal server error. Please try again later."
}

Authorizations

X-API-Key
string
header
required

API key for authentication. Get yours at platform.valyu.ai.

Path Parameters

id
string
required

Batch ID.

Body

application/json

Add tasks to an existing batch.

tasks
object[]
required

Tasks to add. Max 100 per request.

Required array length: 1 - 100 elements

Response

Tasks added and queued.

batch_id
string
required

ID of the batch.

Example:

"batch_a1b2c3d4-e5f6-7890-abcd-ef1234567890"

added
integer
required

Number of tasks added.

Example:

5

tasks
object[]
required

Created tasks with their assigned IDs.

counts
object
required

Task count breakdown for a batch.