Skip to content
Get started

Retrieve a worker

client.workers.retrieve(stringworkerID, WorkerRetrieveParams { taskId } query?, RequestOptionsoptions?): Worker { id, created_at, error, 13 more }
GET/api/workers/{workerId}

Retrieve the current worker state and messages from its most recent task (or a specific task via taskId).

ParametersExpand Collapse
workerID: string
query: WorkerRetrieveParams { taskId }
taskId?: string

Return the worker state and messages for a specific task instead of the most recent one.

minLength1
ReturnsExpand Collapse
Worker { id, created_at, error, 13 more }
id: string
created_at: number | null
error: unknown
files: Array<File>
filename: string | null
mediaType: string
url: string
formaturi
size?: number
minimum0
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"
structured_output: Record<string, unknown> | null
url: string

Web URL of the worker in the Handinger dashboard.

usage?: Usage { durationMs }
durationMs?: number
minimum0

Retrieve a worker

import Handinger from '@ramensoft/handinger';

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

const worker = await client.workers.retrieve('t_org_123_w_01HZY2ZJQ8G7K42W2D7WF6V4GM');

console.log(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
  }
}