[Go to site: main page, start]

Skip to main content
For AI agents: a documentation index is available at https://docs.parallel.ai/llms.txt. The full text of all docs is at https://docs.parallel.ai/llms-full.txt. You may also fetch any page as Markdown by appending .md to its URL or sending Accept: text/markdown.
The Parallel Task Group API enables you to batch process hundreds or thousands of Tasks efficiently. Instead of running Tasks one by one, you can organize them into groups, monitor their progress collectively, and retrieve results in bulk. The API is comprised of the following endpoints: Creation: To run a batch of tasks in a group, you first need to create a task group, after which you can add runs to it, which will be queued and processed.
  • POST /v1/tasks/groups (Create task-group)
  • POST /v1/tasks/groups/{taskgroup_id}/runs (Add runs. Up to 1,000 runs per POST request.)
Progress Snapshot: At any moment during the task, you can get an instant snapshot of the state of it using GET /{taskgroup_id} and GET /{taskgroup_id}/runs. Please note that the runs endpoint streams back the requested runs instantly (using SSE) to allow for large payloads without pagination, and it doesn’t wait for runs to complete. Runs in a task group are stored indefinitely, so unless you have high performance requirements, you may not need to keep your own state of the intermediate results. However, it’s recommended to still do so after the task group is completed.
  • GET /v1/tasks/groups/{taskgroup_id} (Get task-group summary)
  • GET /v1/tasks/groups/{taskgroup_id}/runs (Fetch task group runs)
Realtime updates: You may want to provide efficient real-time updates to your app. For a high-level summary and run completion events, you can use GET /{taskgroup_id}/events. To also retrieve the task run result upon completion you can use the task run endpoint
  • GET /v1/tasks/groups/{taskgroup_id}/events (Stream task-group events)
  • GET /v1/tasks/runs/{run_id}/result (Get task-run result)
To determine whether a task group is fully completed, you can either use realtime update events, or you can poll the task-group summary endpoint. You can also keep adding runs to your task group indefinitely.

Key Concepts

Task Groups

A Task Group is a container that organizes multiple task runs. Each group has:
  • A unique taskgroup_id for identification
  • A status object with is_active (boolean) and task_run_status_counts (counts by status)
  • The ability to add new Tasks dynamically

Group Status

Track progress with real-time status updates:
  • Total number of task runs
  • Count of runs by status (queued, running, completed, failed)
  • Whether the group is still active (is_active becomes false when all runs finish)
  • Human-readable status messages

Quick Start

1. Define Types and Task Structure

2. Create a Task Group

3. Add Tasks to the Group

By default, the response refreshes and returns the latest status of all runs in the group. If you’re adding tasks at scale and don’t need a fresh status on each response, set refresh_status to false for faster responses — the response will still include a cached status. You can retrieve the latest status at any time via the GET task-group endpoint.

4. Monitor Progress

5. Retrieve Results

The getRuns endpoint returns a Server-Sent Events stream, not a simple JSON response. It emits one event per run currently in the group (a snapshot of each run’s state), then closes. To pick up runs added after that snapshot, resume from the last event_id via the last_event_id parameter. Each event in the stream has:
  • type: Either "task_run.state" or "error"
  • event_id: Cursor for resuming the stream via the last_event_id parameter
  • run: The TaskRun object with run_id, status, and is_active
  • input: The original input (only included when include_input=true)
  • output: The result output (only included when include_output=true and the run completed successfully)
If you want a live stream of completion transitions and group-level status updates instead of a snapshot, use the /events endpoint shown below the getRuns examples.

Batch Processing Pattern

For large datasets, process Tasks in batches to optimize performance. Setting refresh_status to false is recommended when adding tasks in bulk, as it skips refreshing the group status on each request for faster responses:

Error Handling

The Group API provides robust error handling:

Complete Example

Here’s a complete script that demonstrates the full workflow, including all of the setup code above.