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
}
}Add Tasks to Batch
Reference for adding tasks to a batch via POST /v1/deepresearch/batches//tasks.
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
}
}Add up to 100 task inputs to an existing batch in
open or processing state. Keep a mapping between each submitted task and the record in your application that needs the result.
The mode price for every task in the request is held against your balance in one step. If the balance can’t cover all of them, the request returns 402 and no tasks are added. A 503 means billing couldn’t be checked and nothing was added; retry with backoff. A task that waits in the queue for more than 48 hours needs balance again when it starts; if the balance no longer covers it, the task fails and is not charged.
After submission, use List batch tasks to inspect individual outcomes. A batch may contain successful and failed tasks; handle them separately.Authorizations
API key for authentication. Get yours at platform.valyu.ai.
Body
application/json
Response
Tasks added and queued.
Was this page helpful?