Skip to content
Get started

Retrieve a worker

client.Workers.Get(ctx, workerID, query) (*Worker, error)
GET/api/workers/{workerId}

Retrieve the current worker state. Pass stream=true or request text/event-stream to subscribe to updates.

ParametersExpand Collapse
workerID string
query WorkerGetParams
Stream param.Field[bool]Optional

Return a server-sent event stream instead of JSON.

ReturnsExpand Collapse
type Worker struct{…}
ID string
CreatedAt int64
Error any
Files []WorkerFile
Filename string
MediaType string
URL string
IncompleteDetails any
Messages []any
Metadata map[string, any]
Object WorkerObject
Output []WorkerOutput
ID string
Content []WorkerOutputContent
Text string
Type string
Role string
Status string
Type string
OutputText string
Running bool
Sources []WorkerSource
ID string
Title string
Type string
URL string
Status WorkerStatus
One of the following:
const WorkerStatusRunning WorkerStatus = "running"
const WorkerStatusCompleted WorkerStatus = "completed"
const WorkerStatusPending WorkerStatus = "pending"
Costs WorkerCostsOptional
InternalCostUsd float64
minimum0
ModelCostUsd float64
minimum0
SandboxCostUsd float64
minimum0
ToolCostUsd float64
minimum0
Usage WorkerUsageOptional
CacheReadTokens int64
minimum0
CacheWriteTokens int64
minimum0
CostUsd float64
minimum0
InputTokens int64
minimum0
OutputTokens int64
minimum0
ReasoningTokens int64
minimum0
Steps int64
minimum0
TotalTokens int64
minimum0
Credits int64Optional
minimum0

Retrieve a worker

package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/handinger-go"
  "github.com/stainless-sdks/handinger-go/option"
)

func main() {
  client := handinger.NewClient(
    option.WithAPIKey("My API Key"),
  )
  worker, err := client.Workers.Get(
    context.TODO(),
    "t_org_123_w_01HZY2ZJQ8G7K42W2D7WF6V4GM",
    handinger.WorkerGetParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", 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
  }
}