How to Automate Any Desktop App with the Coasty Computer Use API
Most desktop automation tools rely on brittle selectors. A change in a CSS class or an app update breaks scripts instantly. The Coasty Computer Use API lets you build a computer use agent that sees the screen, interprets text and layouts, and takes actions like a human. You drive any desktop app, browser, or terminal through a simple REST API. This guide shows how to set up a Task Run, follow the event stream, and keep your automation resilient.
How it works
A Task Run is the primary way to hand off a job to a Coasty agent. You POST /v1/runs with a machine_id, a task description, and optional settings like cua_version, max_steps, and deadline_seconds. You can also set a webhook_url to receive real-time updates. The server starts a cloud VM, launches an agent, and drives the desktop. You then GET /v1/runs/{id}/events to stream Server-Sent Events. The agent loops capture, predict, act until status is done, succeeded, failed, or cancelled. Each agent step costs $0.05 and bills against a prepaid USD wallet where 1 credit equals $0.01.
curl -X POST https://coasty.ai/v1/runs \ \
-H "Authorization: Bearer $COASTY_API_KEY" \ \
-H "Content-Type: application/json" \ \
-d '{
"machine_id": "m-abc123",
"task": "Open Chrome, navigate to https://example.com, and click the first heading",
"cua_version": "v4",
"max_steps": 100,
"deadline_seconds": 600,
"webhook_url": "https://your-domain.com/webhook/coasty"
}'
Track runs with the event stream
- ●GET /v1/runs/{id}/events streams events as Server-Sent Events.
- ●Use the Last-Event-ID header to reconnect after a disconnect.
- ●Events include status changes and step details.
- ●Each event is small and can be parsed line by line.
GET /v1/runs/{id}/events with Last-Event-ID for resilient streaming.
Where this beats brittle automation
A computer use agent does not need HTML structures, XPath, or selectors. It looks at the pixel layout and text to decide where to click. If an app repaints or changes class names, the agent adapts. This approach works across browsers, native apps, and terminals without brittle selectors or API-only tools. You can also use stateful trajectory memory with /v1/sessions for long-running workflows that remember context across steps.
Use workflows for repeatable automation
- ●Workflows are a versioned JSON DSL of runs.
- ●Step types include task, assert, if, loop, parallel, human_approval, retry, succeed, and fail.
- ●Variables use double-brace syntax like {{inputs.x}} and stepId.field.
- ●Set budget_cents, max_iterations, and deadline_seconds as hard guards.
You can now automate any desktop app by handing off tasks to a computer use agent. Build resilient workflows, track runs with the event stream, and scale across machines. Get your API key at https://coasty.ai/developers and start automating.