Tutorial

Build an Autonomous Agent That Finishes a Task with /v1/runs

Rachel Kim||8 min
+B

You have a complex task that spans multiple windows, web forms, and system menus. You could write 500 lines of selectors and wait for them to break. Instead, send a machine_id, a task description, and a deadline to /v1/runs and let Coasty drive a real desktop until the task succeeds or times out. The server runs an agent that sees the screen, interprets text, and acts like a human. You only pay per agent step.

How it works

POST /v1/runs creates a task run that the server drives to completion. You provide machine_id (a cloud VM you provision), task (short natural-language instruction), and optional fields like cua_version, instructions, system_prompt, max_steps, deadline_seconds, on_awaiting_human, and webhook_url. The server returns an id and initial state (queued). The run progresses through states: queued, running, awaiting_human, succeeded, failed, cancelled, timed_out. You can poll GET /v1/runs/{id} or stream events via GET /v1/runs/{id}/events. Billing is $0.05 per agent step.

bash
curl -X POST https://coasty.ai/v1/runs \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "machine_id": "vm-123",
    "task": "Open Chrome, navigate to https://example.com, find the first heading and print its text",
    "cua_version": "v4",
    "system_prompt": "You are a helpful assistant that reads the screen and types human-like actions.",
    "max_steps": 100,
    "deadline_seconds": 300
  }'

Key fields and options

  • machine_id: Cloud VM ID the agent will drive (POST /v1/machines first).
  • task: Natural language description of the overall objective.
  • cua_version: 'v3' for guided, 'v4' for autonomous with pass/fail verifier.
  • instructions: Additional text appended to the base prompt, useful for custom rules.
  • system_prompt: Custom system message to shape the agent's behavior.
  • max_steps: Cap on agent steps per run to prevent runaway processes.
  • deadline_seconds: Total time budget for the run.
  • on_awaiting_human: Action to take when the agent needs human input ('pause'/'fail'/'cancel').
  • webhook_url: Optional callback for events (signed with HMAC).
  • Billing: $0.05 per agent step.

POST /v1/runs with machine_id and task lets the server drive a real desktop until success or deadline.

Where this beats brittle automation

Traditional automation relies on stable selectors (XPaths, CSS, IDs) that break when UI changes, layouts shift, or frameworks inject IDs. Coasty sees the screen like a human and chooses actions based on text, context, and visual layout. It handles multi-step workflows across browsers, terminals, and desktop apps without brittle selectors. You define the goal in natural language and let the computer use agent figure out the clicks and keystrokes.

Start an autonomous run with POST /v1/runs, poll or stream events, and manage results. Build agents that open apps, fill forms, navigate websites, and verify outcomes. Get your API key at https://coasty.ai/developers and try a run today.

Want to see this in action?

View Case Studies
Try Coasty Free