Skip to content
Get started

Create a task

tasks.create(TaskCreateParams**kwargs) -> Worker
POST/api/tasks

Run a new task against an existing worker and wait for the result. Send a taskId of a prior task to add a follow-up turn instead of starting a fresh task. Send multipart/form-data to attach files; the bytes are bootstrapped into the worker’s workspace before the task starts. The task runs to completion on the server even if the connection drops; subscribe to task webhooks for long-running tasks.

ParametersExpand Collapse
input: str
minLength1
budget: Optional[Literal["low", "standard", "high", "unlimited"]]

Compute budget the worker is allowed to spend on the task. Defaults to standard.

One of the following:
"low"
"standard"
"high"
"unlimited"
task_id: Optional[str]

Optional client-provided task id. Reuse this id to add turns to an existing task.

minLength1
worker_id: Optional[str]

Worker id the task belongs to. If omitted, a new worker is created on-the-fly using the input as instructions.

minLength1
ReturnsExpand Collapse
class Worker:
id: str
created_at: Optional[int]
error: None
files: List[File]
filename: Optional[str]
media_type: str
url: str
formaturi
size: Optional[int]
minimum0
incomplete_details: None
messages: List[object]
metadata: Dict[str, object]
object: Literal["worker"]
output: List[Output]
id: str
content: List[OutputContent]
text: str
type: Literal["output_text"]
role: Literal["assistant"]
status: Literal["completed"]
type: Literal["message"]
output_text: str
running: bool
sources: List[Source]
id: str
title: Optional[str]
type: Literal["url"]
url: str
status: Literal["running", "completed", "pending"]
One of the following:
"running"
"completed"
"pending"
structured_output: Optional[Dict[str, object]]
url: str

Web URL of the worker in the Handinger dashboard.

usage: Optional[Usage]
duration_ms: Optional[int]
minimum0

Create a task

import os
from handinger import Handinger

client = Handinger(
    api_key=os.environ.get("HANDINGER_API_KEY"),  # This is the default and can be omitted
)
worker = client.tasks.create(
    input="What's the weather today in Barcelona?",
    worker_id="wrk_vk81XUHKHG-qr4",
)
print(worker.id)
{
  "id": "id",
  "created_at": 0,
  "error": null,
  "files": [
    {
      "filename": "filename",
      "mediaType": "mediaType",
      "url": "https://example.com",
      "size": 0
    }
  ],
  "incomplete_details": null,
  "messages": [
    {}
  ],
  "metadata": {
    "foo": "bar"
  },
  "object": "worker",
  "output": [
    {
      "id": "id",
      "content": [
        {
          "text": "text",
          "type": "output_text"
        }
      ],
      "role": "assistant",
      "status": "completed",
      "type": "message"
    }
  ],
  "output_text": "output_text",
  "running": true,
  "sources": [
    {
      "id": "id",
      "title": "title",
      "type": "url",
      "url": "url"
    }
  ],
  "status": "running",
  "structured_output": {
    "foo": "bar"
  },
  "url": "https://v3.handinger.com/worker/wrk_vk81XUHKHG-qr4",
  "usage": {
    "durationMs": 0
  }
}
Returns Examples
{
  "id": "id",
  "created_at": 0,
  "error": null,
  "files": [
    {
      "filename": "filename",
      "mediaType": "mediaType",
      "url": "https://example.com",
      "size": 0
    }
  ],
  "incomplete_details": null,
  "messages": [
    {}
  ],
  "metadata": {
    "foo": "bar"
  },
  "object": "worker",
  "output": [
    {
      "id": "id",
      "content": [
        {
          "text": "text",
          "type": "output_text"
        }
      ],
      "role": "assistant",
      "status": "completed",
      "type": "message"
    }
  ],
  "output_text": "output_text",
  "running": true,
  "sources": [
    {
      "id": "id",
      "title": "title",
      "type": "url",
      "url": "url"
    }
  ],
  "status": "running",
  "structured_output": {
    "foo": "bar"
  },
  "url": "https://v3.handinger.com/worker/wrk_vk81XUHKHG-qr4",
  "usage": {
    "durationMs": 0
  }
}