Build a Self-Running QA Bot with the Computer Use API
Traditional end-to-end tests rely on brittle selectors and hard‑coded IDs. When UI changes, tests break. You need a QA bot that can see the screen, follow instructions, and handle updates without rewriting selectors. The Coasty Computer Use API lets you launch a cloud VM with a real desktop, give it natural language instructions, and watch it drive the UI like a human. You can assert outcomes by reading the screen or checking state. This guide shows how to wire a self‑running QA bot from start to finish.
Architecture Overview
- ●Create a cloud machine via POST /v1/machines. The machine provides a real desktop where the agent can interact.
- ●Start the machine to get a headless or headful environment. The agent uses this desktop to perform actions.
- ●Post a Task Run with POST /v1/runs. Include the machine_id, a task description, and the cua_version ("v4" for autonomous verification).
- ●The API bills $0.05 per agent step. You can monitor progress via GET /v1/runs/{id}/events (Server-Sent Events).
- ●When the run completes, inspect events for success, failure, or human approval. The run status is one of queued, running, awaiting_human, succeeded, failed, cancelled, timed_out.
Create a Machine
- ●Machines are provisioned via POST /v1/machines. You can stop and start them later.
- ●The API returns a machine object with an id and status. Use the id when you create a Task Run.
- ●You can choose headless or headful environments depending on whether you need to see the UI or run headless browsers.
# Create a cloud machine for QA workloads
# Reads COASTY_API_KEY from the environment
API_KEY=$(cat "$HOME/.coasty_key")
curl -s https://coasty.ai/v1/machines \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"machine_type": "linux-desktop",
"os": "ubuntu-22.04",
"headless": false,
"name": "qa-bot-machine"
}' | jq .Run the QA Task
- ●POST /v1/runs creates a fully autonomous run. You provide the machine_id, a task, and optional instructions.
- ●Set cua_version to "v4" for an autonomous run with a pass/fail verifier. This is ideal for QA verification.
- ●You can append custom instructions to the base prompt by including an instructions field.
- ●The server drives the agent until it finishes or hits the defined max_steps and deadline_seconds.
- ●The total cost is $0.05 per agent step. You allocate credits via a prepaid USD wallet.
# Submit a QA task to the machine
API_KEY=$(cat "$HOME/.coasty_key")
RUN_ID=$(curl -s https://coasty.ai/v1/runs \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"machine_id": "mch_abc123def456",
"task": "Log in to https://example.com/login, fill username and password, submit the form, and verify that the dashboard loads.",
"cua_version": "v4",
"instructions": "Use Chrome for web tasks and Mozilla Firefox for testing the legacy portal.",
"max_steps": 1000,
"deadline_seconds": 600
}' | jq -r .id)
echo "Run ID: $RUN_ID"POST /v1/runs with cua_version:"v4" gives you an autonomous QA agent that drives the desktop and validates results.
Monitor Progress
- ●Use GET /v1/runs/{id} to check the current status and summary of the run.
- ●Stream detailed events with GET /v1/runs/{id}/events. This endpoint returns Server-Sent Events (SSE).
- ●Reconnect SSE streams using the Last-Event-ID header to resume after a disconnect.
- ●Events include action descriptions, screen captures, and status updates. This lets you log them for debugging.
# Stream events for a run
API_KEY=$(cat "$HOME/.coasty_key")
RUN_ID="r123456789"
curl -s https://coasty.ai/v1/runs/$RUN_ID/events \
-H "X-API-Key: $API_KEY" \
--no-buffer 2>/dev/null | while read -r line; do
if [[ $line == data:* ]]; then
echo "$line" | jq .
else
echo "$line"
fi
done
# Alternatively poll status
STATUS=$(curl -s https://coasty.ai/v1/runs/$RUN_ID \
-H "X-API-Key: $API_KEY" | jq -r .status)
echo "Run status: $STATUS"Where This Beats Brittle Automation
- ●The bot sees the screen. It can read dynamic text, labels, and layouts that selectors often miss.
- ●It can follow instructions in natural language. You update the task instead of rewriting selectors.
- ●It can handle complex workflows with multiple apps and browser tabs, which is hard with API‑only tools.
- ●The agent drives a real desktop, so the test environment matches production more closely.
- ●You can reuse the same machine for different QA tasks, reducing setup overhead.
You now have a blueprint for a self‑running QA bot that drives real desktops using the Coasty Computer Use API. Start by provisioning a machine, then submit runs with clear task descriptions and cua_version:"v4". You can monitor runs via status endpoints and event streams. To start building, get your API key at https://coasty.ai/developers .