Tutorial

How to Automate Any Desktop App with the Coasty Computer Use API

Emily Watson||7 min
+Z

Desktop automation often feels like a game of whack-a-mole. You write a script that clicks a button, and three weeks later the UI changes and your automation breaks. The Coasty computer use API solves this by letting you drive any desktop application through its real screen, just like a human would. You send a screenshot and an instruction, and the API returns actions you can replay. This approach works across browsers, terminals, and any native Windows, macOS, or Linux desktop app without relying on fragile selectors or undocumented APIs.

How it works

The core of the Coasty computer use API is the /v1/runs endpoint. You POST a task describing what you want to do on the machine, and the server runs a computer use agent to execute it. The agent runs a loop of capture, predict, and act until the task succeeds or fails. Each agent step is billed at $0.05. The request accepts a machine_id representing the target machine, the task description, and optional parameters like cua_version, instructions, system_prompt, max_steps, deadline_seconds, and on_awaiting_human. The response includes an id for the run and its current state among queued, running, awaiting_human, succeeded, failed, cancelled, and timed_out. You can poll the run with GET /v1/runs/{id} or stream events from GET /v1/runs/{id}/events.

bash
curl -X POST https://coasty.ai/v1/runs \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "machine_id": "machine_123",
    "task": "Open the browser, navigate to example.com, and take a screenshot of the page",
    "cua_version": "v3",
    "max_steps": 50,
    "deadline_seconds": 300,
    "on_awaiting_human": "pause"
  }'

Key parameters for automation

  • machine_id: The target machine where the agent runs. Provision it with POST /v1/machines if needed.
  • task: A natural language description of the end goal. The agent interprets this and plans actions.
  • cua_version: Use "v3" for the standard agent or "v4" for autonomous operation with a pass/fail verifier.
  • instructions: Additional context appended to the base prompt for more precise behavior.
  • max_steps: Maximum number of agent steps. Each step is $0.05.
  • deadline_seconds: Timeout for the run in seconds.
  • on_awaiting_human: Handle human intervention with pause, fail, or cancel.

Each agent step costs $0.05, and the server drives the agent to completion without you writing the click coordinates yourself.

Where this beats brittle automation

Traditional UI automation often relies on XPath selectors, IDs, or class names that can change with a single UI update. When they do, your script breaks, and you must rewrite selectors. The Coasty computer use API bypasses this problem because it works directly on the rendered screen. The agent sees the same UI elements that you see, so changes in layout, text, or styling do not break the automation. It also extends to applications that expose no public APIs, such as legacy tools or desktop dashboards, enabling automation in environments where you would otherwise be stuck.

Next steps

Start automating your desktop workflows today by spinning up a machine and submitting your first task. For more details, see the full documentation at https://coasty.ai/developers and get your API key.

Want to see this in action?

View Case Studies
Try Coasty Free