POST /api/v1/browsing/async
Creates a browsing task and returns task_id at once.
Request body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
task | string | One of task / script | Natural-language instruction, carried out by an LLM agent in the browser |
script | string | One of task / script | Custom Python instead of a task; enabled per API key. See Custom Scripts |
timeout_sec | uint32 | No | The task’s budget in seconds, at most 1200 (20 minutes); more is 400. Omitted: 10 minutes. The legacy timeout is in milliseconds |
fanout | uint32 | No | How many parallel runs for the task, 1–10, default 1; the first result wins |
filter.country_iso_included | string[] | No | The countries the task may run from, ISO 3166-1 alpha-2 (["DE", "US"]). See Countries |
filter.country_iso_excluded | string[] | No | The countries the task must not run from. Not together with country_iso_included: send one list or the other |
session_key | string | No | Up to 128 characters. Each task of a session runs independently of the others |
ttl_days | uint32 | No | How many days the request and result are kept, 1–30. Omitted: 7. See How long the result is kept |
screenshots.mode | string | With screenshots | final_only, every_step or on_navigation. See Screenshots |
screenshots.full_page | bool | No | Whole page rather than the viewport |
emulate_human | bool | No | Human-like input: the pointer moves to its target and text is typed character by character. Slower. See emulate_human |
max_steps | uint32 | No | Cap on the agent’s steps for a task, 1–500. Reaching it fails the task with what the agent had by then. See max_steps |
uv_args | string | No | Extra uv run arguments for a custom script, usually packages; up to 1024 characters. Gated by the same flag as script |
retry | bool | No | For a script: run it again on another node when Cloudflare blocks the browser or the node itself fails. Default true; false keeps the task on its first node. See Retry on another node |
hedge | bool | No | For a script: also start it on a second node when the first has not answered by the time this script usually has; the first answer wins. Default true; send false for a script that posts, buys or signs in. See Hedge on a second node |
Unknown JSON fields are rejected (400), so a typo in a name does not pass silently.
Response (200):
{ "task_id": "web:550e8400-e29b-41d4-a716-446655440000" }While a quota is used up or under a tenth of what the plan included, the response also
carries balance_warning, and the same sentence in the X-Balance-Warning header. See
Account & Balance.
curl -sS -X POST "https://llm.dat.ai/api/v1/browsing/async" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"task": "Open https://example.com and summarize the page",
"filter": { "country_iso_included": ["DE"] },
"screenshots": { "mode": "final_only", "full_page": true },
"fanout": 1,
"timeout_sec": 600
}'Countries
filter says where the task may run, one way or the other:
{ "filter": { "country_iso_included": ["DE", "AT", "CH"] } }{ "filter": { "country_iso_excluded": ["CN", "TW"] } }country_iso_included restricts the task to the listed countries; country_iso_excluded
keeps it out of them and lets it run anywhere else. The two are mutually exclusive: a
request with both gets 400. Codes are ISO 3166-1 alpha-2, case-insensitive. Without a
filter the task runs from any country except RU, which is excluded unless
country_iso_included names it. Which countries are available right now, and roughly how
many, is what GET /api/v1/supply/countries says. A filter whose countries have
no browser online at all is refused at once with 503 no_browsers_in_country; one whose
browsers are all busy waits for one within the task’s budget.
emulate_human
By default a click is delivered at its target instantly and a string is entered in one go.
With emulate_human the pointer moves to the target along a curve, the button is held for
a short interval, and text is typed character by character with a drifting delay.
The task takes about a quarter longer. Useful wherever the interaction itself matters, such as forms, logins and interactive apps.
max_steps
An agent works in steps: look at the page, decide, act. A task’s other limit is
timeout_sec, and the two say different things. When the budget runs out the task fails
with the task did not finish within N ms; when the steps run out it fails with the task did not finish within N steps. Both replies carry what the agent had by then: result
(the answer so far), steps, and a screenshot of where it stopped when screenshots were
asked for. Without max_steps the agent stops at its own limit of 500 steps, which in
practice means the budget is reached first.
Each step costs one action of the account’s steps quota and about six seconds. See
Sizing a task for what that means for a task over several
pages.
How long the result is kept
A task’s request (the task text or script) and its result (payload) are kept
for ttl_days after the task is created, 7 days unless you say otherwise, 30 at most, and
then deleted. Collect the result within that window; it is not recoverable afterwards.
The task itself is not deleted: status keeps answering with the status, timings and
traffic figures, and once the result is gone it says so with "payload_expired": true
instead of a payload. The day the result goes away is in payload_expires_on.
Screenshot files are kept for 5 days.
POST /api/v1/browsing/sync
Same request body as async. Waits for the result in the same HTTP request: the task’s own
budget (timeout_sec, 10 minutes when omitted) plus a margin for the result to arrive. When
nothing came in that time the answer is 504 {"error": "Task timeout"}, while the task
itself may still finish and can be read from status. Use sync for short tasks; anything
that may take more than a minute is better started with async.
Response (200), a task that opened example.com and returned its title:
{
"task_id": "web:fa8cf4c6-2e74-4e55-aa4b-76b74971043e",
"success": true,
"payload": "{\"success\":true,\"result\":\"The page title of https://example.com is 'Example Domain'.\",\"steps\":2,\"no_result\":false,\"traffic_in\":473,\"traffic_out\":722}",
"step_cnt": 2,
"execution_time_ms": 21889,
"traffic_in": 473,
"traffic_out": 722,
"traffic_total": 1195
}payload is a JSON string; parsed, its result is the agent’s answer and steps how many
steps it took. On failure success is false and error says why, with payload carrying
what the browser reported. A task that ran out of max_steps:
{
"task_id": "web:8b733a4f-9b21-464f-b4c4-176f0a55cdc4",
"success": false,
"error": "RuntimeError: the task did not finish within 1 steps",
"payload": "{\"success\":false,\"error_type\":\"RuntimeError\",\"error_message\":\"the task did not finish within 1 steps\",\"max_steps\":1,\"steps\":1,\"result\":\"The task could not be completed because the step limit was reached before any navigation or data collection could occur. No page titles were retrieved.\",\"traffic_in\":0,\"traffic_out\":0}",
"step_cnt": 1,
"execution_time_ms": 10250
}A sync call that outlived its wait answers 504 { "error": "Task timeout" }; the task
may still finish, poll status. While a quota is used up or nearly so, the response also
carries balance_warning (see Account & Balance).
Traffic fields:
| Field | Meaning |
|---|---|
traffic_in | Bytes the task downloaded |
traffic_out | Bytes the task uploaded |
traffic_total | traffic_in + traffic_out, the figure your usage is measured against |
Traffic is reported only for a task that finished and produced a result. The three fields are omitted when the run failed or the traffic could not be measured.
GET /api/v1/browsing/status
Status and result by task_id.
Query: task_id (required)
curl -sS "https://llm.dat.ai/api/v1/browsing/status?task_id=web:YOUR_TASK_ID" \
-H "Authorization: Bearer YOUR_API_KEY"Response (200), a finished task:
{
"task_id": "web:fa8cf4c6-2e74-4e55-aa4b-76b74971043e",
"status": "completed",
"created_at": "2026-09-18T09:40:12Z",
"assigned_at": "2026-09-18T09:40:12Z",
"started_at": "2026-09-18T09:40:14Z",
"completed_at": "2026-09-18T09:40:36Z",
"payload_expires_on": "2026-09-25",
"success": true,
"payload": "{\"success\":true,\"result\":\"The page title of https://example.com is 'Example Domain'.\",\"steps\":2,\"no_result\":false,\"traffic_in\":473,\"traffic_out\":722}",
"step_cnt": 2,
"execution_time_ms": 21889,
"traffic_in": 473,
"traffic_out": 722,
"traffic_total": 1195
}A task still running answers with the status alone:
{
"task_id": "web:42efa955-d7cf-47bf-ac81-d516edd984ec",
"status": "assigned",
"created_at": "2026-09-18T09:25:45Z",
"assigned_at": "2026-09-18T09:25:45Z",
"payload_expires_on": "2026-09-25"
}status | Meaning |
|---|---|
queued | Waiting to be picked up |
assigned | Picked up and working on the task |
completed | Finished; success, payload, execution_time_ms are present |
failed | Failed; success: false and error are present, and payload when one was reported |
cancelled | Cancelled |
A failed task carries the reason: the exception a script raised, the budget the agent ran
out of, the site’s refusal. A task that could not be completed fails within about a minute
with error: "the browser's node disconnected before reporting a result"; a task that ran
past its budget with no reply says so too. status_reason is error or timeout.
A task that ran out of max_steps, with what the agent had by then:
{
"task_id": "web:8b733a4f-9b21-464f-b4c4-176f0a55cdc4",
"status": "failed",
"status_reason": "error",
"created_at": "2026-09-18T09:41:24Z",
"assigned_at": "2026-09-18T09:41:24Z",
"completed_at": "2026-09-18T09:41:35Z",
"payload_expires_on": "2026-09-25",
"success": false,
"error": "RuntimeError: the task did not finish within 1 steps",
"payload": "{\"success\":false,\"error_type\":\"RuntimeError\",\"error_message\":\"the task did not finish within 1 steps\",\"max_steps\":1,\"steps\":1,\"result\":\"The task could not be completed because the step limit was reached before any navigation or data collection could occur. No page titles were retrieved.\",\"traffic_in\":0,\"traffic_out\":0}",
"step_cnt": 1,
"execution_time_ms": 10250,
"traffic_in": 0,
"traffic_out": 0,
"traffic_total": 0
}A custom script that raised, and a task whose browser was lost:
{
"task_id": "web:...",
"status": "failed",
"status_reason": "error",
"success": false,
"error": "NameError: name 'page' is not defined",
"payload": "{\"success\": false, \"error_type\": \"NameError\", \"error_message\": \"name 'page' is not defined\", \"traceback\": \"...\"}",
"execution_time_ms": 4411
}{
"task_id": "web:...",
"status": "failed",
"status_reason": "error",
"success": false,
"error": "the browser's node disconnected before reporting a result"
}payload is the task’s answer as a JSON string; parse it to get at the result your
task or script produced. payload_expires_on is the day after which the result is deleted
(see How long the result is kept); past that day the response carries "payload_expired": true
and no payload, everything else stays.
Errors: 400 (no task_id), 401, 403 (the task belongs to another account), 404 (task
not found):
{ "error": "task_id is required" }
{ "error": "Task not found" }Screenshots
screenshots in the create request asks for captures of the page:
mode | What is captured |
|---|---|
final_only | The page as the task ends. The only mode that applies to custom scripts |
every_step | After every agent step |
on_navigation | After every step that changed the URL |
full_page: true captures the whole page rather than the viewport. Another value of mode
is rejected with 400.
The images are stored on the server, and the screenshots list in the task’s payload
carries a url for each of them:
GET /api/v1/browsing/screenshots/task_id/filename
curl -sS "https://llm.dat.ai/api/v1/browsing/screenshots/web%3AYOUR_TASK_ID/screenshot-01.png" \
-H "Authorization: Bearer YOUR_API_KEY" \
-o screenshot.pngtask_idandfilenameare URL-encoded in the path- Returns the image (
image/png) on success (200) - 403 if the task belongs to another account
- 404 if the task or the file does not exist
Screenshots exist only when screenshots was set in the create request. Files are kept for
5 days, then deleted.
Errors
All browsing endpoints return { "error": "..." }. As the server gives them:
// 400
{ "error": "task or script is required" }
{ "error": "timeout_sec must be less than or equal to 1200" }
{ "error": "filter must specify only one of country_iso_included or country_iso_excluded" }
{ "error": "task_id is required" }
{ "error": "Invalid input data" }
// 401
{ "error": "Authentication required: missing Authorization header. Please provide Authorization header with Bearer token format: 'Authorization: Bearer <your-api-key>'" }
// 402
{ "error": "Insufficient balance: the browser_seconds quota is used up and there is no USD balance to cover overage; top up in the dashboard (https://dash.dat.ai) or check GET /api/v1/account/balance", "code": "insufficient_balance", "exhausted": "browser_seconds" }
// 403
{ "error": "custom browsing scripts are not enabled for this API key" }
// 404
{ "error": "Task not found" }
// 504 (sync)
{ "error": "Task timeout" }| Status | Cause |
|---|---|
| 400 | Invalid JSON, an unknown field, neither task nor script, timeout_sec over 1200, max_steps over 500 or with a script, missing task_id, country_iso_included together with country_iso_excluded |
| 401 | Missing or invalid API key |
| 402 | No active subscription, or insufficient balance. The body names the quota: {"error": "...", "code": "insufficient_balance", "exhausted": "browser_seconds"}. See Account & Balance |
| 403 | Task belongs to another account, or script / uv_args not enabled for this API key |
| 404 | Task or screenshot not found |
| 405 | Wrong HTTP method for the endpoint |
| 503 | No browser is online in any country of country_iso_included: {"error": "...", "code": "no_browsers_in_country", "countries": ["PT"]}. Nothing is created or charged; pick a country from GET /api/v1/supply/countries |
| 504 | sync waited past the timeout; the task itself may still finish, poll status |