Tutorial

Build a Self-Running QA Bot with the Computer Use API

Rachel Kim||10 min
Ctrl+H

You want to test user flows in production-like environments. Traditional approaches rely on brittle selectors and hard-coded API endpoints. That breaks when UI changes or when you need to test real desktop apps, browsers, or terminal workflows. The Coasty Computer Use API lets you spin up a cloud VM, provision a machine, and drive a computer use agent that actually sees the screen and acts like a human. The agent performs clicks, types, and navigation, then reports pass/fail outcomes. This guide shows how to build a self-running QA testing bot using the real endpoints, fields, and pricing.

How it works

You start by provisioning a cloud VM with POST /v1/machines. That machine hosts a real desktop environment. You then create a task run with POST /v1/runs. The run sends the task description and optional instructions to a computer use agent. The agent operates from cua_version 'v3' or 'v4' (v4 is autonomous with a pass/fail verifier). The agent captures screenshots, predicts actions, and executes steps. Each agent step costs $0.05. The run can include a system_prompt, max_steps, deadline_seconds, on_awaiting_human, and webhook_url. The server streams events via GET /v1/runs/{id}/events. The run states are queued, running, awaiting_human, succeeded, failed, cancelled, timed_out. When the run finishes, you retrieve the final status from GET /v1/runs/{id}.

bash
#!/bin/bash

COASTY_API_KEY="${COASTY_API_KEY}"

# Provision a cloud machine
curl -s https://coasty.ai/v1/machines \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "qa-vm",
    "image": "ubuntu-22.04-desktop",
    "plan": "small"
  }' | jq '.machine_id' > machine_id.txt

MACHINE_ID=$(cat machine_id.txt)

echo "Machine ID: $MACHINE_ID"

# Submit a QA task run
curl -s https://coasty.ai/v1/runs \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{
    \"machine_id\": \"$MACHINE_ID\",
    \"task\": \"Open Firefox, navigate to https://example.com, verify the page title contains 'Example Domain', then close Firefox.\",
    \"cua_version\": \"v3\",
    \"max_steps\": 50,
    \"deadline_seconds\": 300,
    \"on_awaiting_human\": \"pause\"
  }" | jq -r '.run_id' > run_id.txt

RUN_ID=$(cat run_id.txt)

echo "Run ID: $RUN_ID"

# Stream run events until done
while true
do
  curl -s https://coasty.ai/v1/runs/$RUN_ID/events \
    -H "X-API-Key: $COASTY_API_KEY" \
    --no-buffer | while IFS= read -r line
do
    if [[ $line == data:* ]]; then
      echo "${line#data:}"
      event=$(echo "${line#data:}" | jq -r '.state')
      if [[ $event == succeeded || $event == failed || $event == cancelled || $event == timed_out ]]; then
        break 2
      fi
    fi
done
done

echo "Run state: $(cat run_id.txt | xargs curl -s https://coasty.ai/v1/runs/$RUN_ID -H "X-API-Key: $COASTY_API_KEY" | jq -r '.state')"

Key fields and options

  • machine_id is required and comes from POST /v1/machines.
  • task can include any human-readable QA scenario.
  • cua_version can be 'v3' for controlled steps or 'v4' for autonomous pass/fail verification.
  • max_steps limits the number of agent steps (each $0.05).
  • deadline_seconds prevents runs that run forever.
  • on_awaiting_human can be 'pause', 'fail', or 'cancel' when the agent needs human input.
  • webhook_url receives final status updates (HMAC signed).
  • run_id is returned from POST /v1/runs and used to stream events with GET /v1/runs/{id}/events.
  • States include queued, running, awaiting_human, succeeded, failed, cancelled, timed_out.

POST /v1/runs with machine_id and task, then GET /v1/runs/{id}/events to stream events and finalize QA status.

Where this beats brittle automation

Traditional automation relies on CSS selectors, XPath, or hardcoded API paths. When layout changes or the app adds new elements, your tests break. The computer use agent sees the actual screen pixels and understands context. It can click buttons by approximate location, read text from the page, and handle dynamic content. It works across browsers, desktop apps, and terminals without brittle selectors. You also pay only per agent step ($0.05), making it economical for exploratory testing and regression suites. The server drives an agent to completion, so you do not need to coordinate events, timeouts, or retries yourself.

Extending your QA bot

  • Use POST /v1/workflows to define multi-step QA workflows with conditions, retries, and assertions.
  • Configure webhook_url to push results to your CI/CD system or internal dashboard.
  • Read COASTY_API_KEY from environment to avoid hardcoding secrets.
  • Tune max_steps and deadline_seconds based on test complexity.
  • Experiment with cua_version 'v4' for fully autonomous pass/fail verification.
  • Integrate with the MCP server to drive Coasty directly from Cursor or Claude Desktop.

You now have a template for a self-running QA bot that uses real machines, runs real user flows, and reports pass/fail outcomes. Build a workflow that scans multiple pages, retries on transient errors, and integrates with your CI pipeline. Ready to start? Get a key at https://coasty.ai/developers and build your first computer use agent today.

Want to see this in action?

View Case Studies
Try Coasty Free