Guide

Building an Autonomous Agent That Finishes a Task With /v1/runs

Daniel Kim||7 min
Ctrl+R

You need an agent that logs into a web app, fills out a form, clicks a button, and then downloads a report. Traditional automation with selectors breaks when the UI changes or the element is hidden. The Coasty Computer Use API solves this with a task run endpoint. You describe what to do and the server drives a real desktop or browser to finish the job. You only pay $0.05 per agent step.

How /v1/runs works

POST /v1/runs starts a task run. The server provisions a machine, starts a desktop environment, and launches an agent that receives screenshots and instructions. The agent emits a stream of actions such as click, type, scroll, and keyboard shortcuts. The server bills $0.05 per agent step. The run progresses through states queued, running, awaiting_human, succeeded, failed, cancelled, or timed_out. You can retrieve the run status with GET /v1/runs/{id} and stream events with GET /v1/runs/{id}/events (Server-Sent Events). You can cancel with POST /v1/runs/{id}/cancel or resume with POST /v1/runs/{id}/resume.

bash
curl -X POST https://coasty.ai/v1/runs \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "machine_id": "prod-vm-001",
    "task": "Open https://example.com, log in with [email protected]/pass123, download the report, and save it to /tmp/report.pdf",
    "cua_version": "v4",
    "instructions": "Do not install any additional software. Close all other windows after the task completes.",
    "max_steps": 200,
    "deadline_seconds": 600,
    "on_awaiting_human": "pause",
    "webhook_url": "https://example.com/v1/callback"
  }'

Key fields and options

  • machine_id: the cloud VM you provisioned with POST /v1/machines
  • task: a natural language description of the goal
  • cua_version: v3 for guided runs or v4 for autonomous runs with a pass/fail verifier
  • instructions: additional context you want the agent to follow
  • max_steps: maximum number of agent steps before the run times out for you
  • deadline_seconds: total time limit for the run
  • on_awaiting_human: pause, fail, or cancel when the agent needs human help
  • webhook_url: receive a POST with the final status and event payload
  • billing: $0.05 per agent step, debited from your prepaid wallet (1 credit = $0.01)

POST /v1/runs is the one line you need to ship an autonomous agent that works on any UI.

Where this beats brittle automation

API-only tools rely on stable selectors, exact element IDs, or hidden APIs. When a website changes a class name or hides a field, your script fails. A computer use agent sees the screen like a human. It can read labels, follow breadcrumbs, and adapt to layout shifts. It can click a button that appears after a loader completes or use keyboard shortcuts to navigate menus. Because the agent acts on pixels and text, you do not need to maintain brittle selectors. You just describe the task in natural language.

What to build next

Try a real workflow with POST /v1/workflows. Define a versioned JSON DSL that chains tasks, asserts conditions, and handles retries. Use a machine with a specific OS and browser. Test with small tasks first, then scale to complex multi-step processes. Get your API key at https://coasty.ai/developers and start building autonomous agents that finish actual work.

Want to see this in action?

View Case Studies
Try Coasty Free