Skip to content
Get started

Create a worker

workers.create(WorkerCreateParams**kwargs) -> Worker
POST/api/workers

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

ParametersExpand Collapse
input: str
minLength1
budget: Optional[Literal["low", "standard", "high", "unlimited"]]
One of the following:
"low"
"standard"
"high"
"unlimited"
stream: Optional[bool]
ReturnsExpand Collapse
class Worker:
id: str
created_at: Optional[int]
error: None
files: List[File]
filename: Optional[str]
media_type: str
url: str
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"
costs: Optional[Costs]
internal_cost_usd: float
minimum0
model_cost_usd: float
minimum0
sandbox_cost_usd: float
minimum0
tool_cost_usd: float
minimum0
usage: Optional[Usage]
cache_read_tokens: int
minimum0
cache_write_tokens: int
minimum0
cost_usd: float
minimum0
input_tokens: int
minimum0
output_tokens: int
minimum0
reasoning_tokens: int
minimum0
steps: int
minimum0
total_tokens: int
minimum0
credits: Optional[int]
minimum0

Create a worker

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.workers.create(
    input="x",
)
print(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
  }
}