How to Automate Any Desktop App with the Coasty Computer Use API
Most desktop automation is fragile. You hardcode selectors, assume DOM stability, or call a thin API that never sees the UI. That breaks whenever a layout changes. The Coasty computer use API removes the guesswork by letting an AI agent see the screen and act on it like a human user. You send a task and some constraints, and the agent drives a real cloud VM to complete it. This guide shows you how to automate any desktop app, from a local tool to a browser-based workflow, using the real HTTP endpoints and pricing from the Coasty API.
How it works
The core flow is a task run that uses a computer use agent. You POST to /v1/runs with a machine_id, the task description, and a cua_version. The agent runs on a cloud VM, captures screenshots, and calls /v1/predict for each step. Each step costs $0.05. The agent continues until it hits max_steps, a deadline, or a terminal state. You can stream events with GET /v1/runs/{id}/events in Server-Sent Events format. The run can succeed, fail, be cancelled, or wait for human approval. You control the policy with on_awaiting_human (pause, fail, or cancel).
#!/bin/bash
# This example starts a Coasty task run on a cloud machine and streams events.
# Set your API key first. If you use a shell environment, export COASTY_API_KEY.
COASTY_API_KEY=${COASTY_API_KEY:-"your-key-here"}
BASE="https://coasty.ai/v1"
# Create a run (example task: open Chrome and navigate to Coasty)
RUN_RESPONSE=$(curl -s -X POST "$BASE/runs" \
-H "X-API-Key: $COASTY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"machine_id": "machine-123",
"task": "Open Chrome web browser and navigate to https://coasty.ai/developers",
"cua_version": "v3",
"max_steps": 50,
"deadline_seconds": 300,
"on_awaiting_human": "pause"
}')
RUN_ID=$(echo "$RUN_RESPONSE" | jq -r .id)
echo "Run started with ID: $RUN_ID"
# Stream events from the run
curl -N "$BASE/runs/$RUN_ID/events" \
-H "X-API-Key: $COASTY_API_KEY" \
--no-bufferReactive workflows with retries and conditions
- ●Use /v1/workflows to define a versioned JSON DSL of runs.
- ●A workflow can have task, assert, if, loop, parallel, human_approval, retry, succeed, and fail steps.
- ●Conditions are structured objects. You can guard with budget_cents, max_iterations, and deadline_seconds.
- ●Each task step within a workflow is billed $0.05, the same as a standalone run.
- ●You can launch a workflow run with POST /v1/workflows/{id}/runs or POST /v1/workflows/runs for ad-hoc inline workflows.
POST /v1/runs is the simplest way to start an AI-driven automation, then switch to workflows for complex, multi-step logic.
Where this beats brittle automation
Traditional automation relies on stable selectors, XPath, or an undocumented API. When the UI changes, scripts break. The Coasty computer use agent sees the actual screen state. It can handle placeholder text, dynamic classes, and elements that lack stable selectors. It can interact with a terminal, a desktop app, or a browser in the same way a human does. This matters for enterprise workflows, legacy tools, and any system where UI changes are common. You also get full replayability and streaming events, so you can debug runs in real time.
Getting started
- ●Get an API key from https://coasty.ai/developers.
- ●Set COASTY_API_KEY as an environment variable in your code or shell.
- ●Provision a machine with POST /v1/machines if you want a dedicated VM.
- ●Start a run with POST /v1/runs, then stream events with GET /v1/runs/{id}/events.
- ●Check your wallet for credits (1 credit = $0.01).
The Coasty computer use API turns desktop automation from brittle scripting into an AI-driven, observable workflow. Build end-to-end automation for any app, browser, or terminal. Get your API key at https://coasty.ai/developers and start automating.