Skip to content
Get started

Create a worker

client.workers.create(WorkerCreateParams { input, budget, stream } body, RequestOptionsoptions?): Worker { id, created_at, error, 12 more }
POST/api/workers

Create a new agent worker and start it with the supplied instruction.

ParametersExpand Collapse
body: WorkerCreateParams { input, budget, stream }
input: string
minLength1
budget?: "low" | "standard" | "high" | "unlimited"
One of the following:
"low"
"standard"
"high"
"unlimited"
stream?: boolean
ReturnsExpand Collapse
Worker { id, created_at, error, 12 more }
id: string
created_at: number | null
error: unknown
files: Array<File>
filename: string | null
mediaType: string
url: string
incomplete_details: unknown
messages: Array<unknown>
metadata: Record<string, unknown>
object: "worker"
output: Array<Output>
id: string
content: Array<Content>
text: string
type: "output_text"
role: "assistant"
status: "completed"
type: "message"
output_text: string
running: boolean
sources: Array<Source>
id: string
title: string | null
type: "url"
url: string
status: "running" | "completed" | "pending"
One of the following:
"running"
"completed"
"pending"
costs?: Costs | null
internalCostUsd: number
minimum0
modelCostUsd: number
minimum0
sandboxCostUsd: number
minimum0
toolCostUsd: number
minimum0
usage?: Usage { cacheReadTokens, cacheWriteTokens, costUsd, 6 more }
cacheReadTokens: number
minimum0
cacheWriteTokens: number
minimum0
costUsd: number
minimum0
inputTokens: number
minimum0
outputTokens: number
minimum0
reasoningTokens: number
minimum0
steps: number
minimum0
totalTokens: number
minimum0
credits?: number
minimum0

Create a worker

import Handinger from 'handinger';

const client = new Handinger({
  apiKey: process.env['HANDINGER_API_KEY'], // This is the default and can be omitted
});

const worker = await client.workers.create({ input: 'x' });

console.log(worker.id);
{
  "id": "id",
  "created_at": 0,
  "error": null,
  "files": [
    {
      "filename": "filename",
      "mediaType": "mediaType",
      "url": "url"
    }
  ],
  "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",
  "costs": {
    "internalCostUsd": 0,
    "modelCostUsd": 0,
    "sandboxCostUsd": 0,
    "toolCostUsd": 0
  },
  "usage": {
    "cacheReadTokens": 0,
    "cacheWriteTokens": 0,
    "costUsd": 0,
    "inputTokens": 0,
    "outputTokens": 0,
    "reasoningTokens": 0,
    "steps": 0,
    "totalTokens": 0,
    "credits": 0
  }
}
Returns Examples
{
  "id": "id",
  "created_at": 0,
  "error": null,
  "files": [
    {
      "filename": "filename",
      "mediaType": "mediaType",
      "url": "url"
    }
  ],
  "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",
  "costs": {
    "internalCostUsd": 0,
    "modelCostUsd": 0,
    "sandboxCostUsd": 0,
    "toolCostUsd": 0
  },
  "usage": {
    "cacheReadTokens": 0,
    "cacheWriteTokens": 0,
    "costUsd": 0,
    "inputTokens": 0,
    "outputTokens": 0,
    "reasoningTokens": 0,
    "steps": 0,
    "totalTokens": 0,
    "credits": 0
  }
}