Skip to content
Get started

Create a task

tasks.create(**kwargs) -> Worker { id, created_at, error, 13 more }
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: String
minLength1
budget: :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: String

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

minLength1
worker_id: String

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, created_at, error, 13 more }
id: String
created_at: Integer
error: nil
files: Array[File{ filename, media_type, url, size}]
filename: String
media_type: String
url: String
size: Integer
minimum0
incomplete_details: nil
messages: Array[untyped]
metadata: Hash[Symbol, untyped]
object: :worker
output: Array[Output{ id, content, role, 2 more}]
id: String
content: Array[Content{ text, type}]
text: String
type: :output_text
role: :assistant
status: :completed
type: :message
output_text: String
running: bool
sources: Array[Source{ id, title, type, url}]
id: String
title: String
type: :url
url: String
status: :running | :completed | :pending
One of the following:
:running
:completed
:pending
structured_output: Hash[Symbol, untyped]
url: String

Web URL of the worker in the Handinger dashboard.

usage: Usage{ credits, duration_ms}
credits: Integer
minimum0
duration_ms: Integer
minimum0

Create a task

require "handinger"

handinger = Handinger::Client.new(api_key: "My API Key")

worker = handinger.tasks.create(input: "What's the weather today in Barcelona?")

puts(worker)
{
  "id": "id",
  "created_at": 0,
  "error": null,
  "files": [
    {
      "filename": "filename",
      "mediaType": "mediaType",
      "url": "url",
      "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": {
    "credits": 0,
    "durationMs": 0
  }
}
Returns Examples
{
  "id": "id",
  "created_at": 0,
  "error": null,
  "files": [
    {
      "filename": "filename",
      "mediaType": "mediaType",
      "url": "url",
      "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": {
    "credits": 0,
    "durationMs": 0
  }
}