## Retrieve a worker `workers.retrieve(worker_id, **kwargs) -> Worker` **get** `/api/workers/{workerId}` Retrieve the current worker state and messages from its most recent task (or a specific task via `taskId`). ### Parameters - `worker_id: String` - `task_id: String` Return the worker state and messages for a specific task instead of the most recent one. ### Returns - `class Worker` - `id: String` - `created_at: Integer` - `error: nil` - `files: Array[File{ filename, media_type, url, size}]` - `filename: String` - `media_type: String` - `url: String` - `size: Integer` - `incomplete_details: nil` - `messages: Array[untyped]` - `metadata: Hash[Symbol, untyped]` - `object: :worker` - `:worker` - `output: Array[Output{ id, content, role, 2 more}]` - `id: String` - `content: Array[Content{ text, type}]` - `text: String` - `type: :output_text` - `:output_text` - `role: :assistant` - `:assistant` - `status: :completed` - `:completed` - `type: :message` - `:message` - `output_text: String` - `running: bool` - `sources: Array[Source{ id, title, type, url}]` - `id: String` - `title: String` - `type: :url` - `:url` - `url: String` - `status: :running | :completed | :pending` - `: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` - `duration_ms: Integer` ### Example ```ruby require "handinger" handinger = Handinger::Client.new(api_key: "My API Key") worker = handinger.workers.retrieve("t_org_123_w_01HZY2ZJQ8G7K42W2D7WF6V4GM") puts(worker) ``` #### Response ```json { "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 } } ```