Tutorial

Automating Form Filling and Checkout Flows Over the Computer Use API

Marcus Sterling||8 min
F12

Most checkout bots break when the form layout changes, the site adds a CAPTCHA, or a button moves. The Coasty Computer Use API gives you an agent that sees the screen, reads text, clicks elements, and takes actions just like a human. Use stateful sessions, the ground endpoint, and task runs to automate complex flows reliably.

How it works

Start by creating a stateful session. POST /v1/sessions with your API key returns a session ID. Then POST /v1/sessions/{id}/predict with a base64 screenshot, an instruction, and cua_version. The response contains actions and a status. Loop capture, predict, act until status is done. For element clicks, use POST /v1/ground to map a screenshot and description to x,y coordinates. Task runs (POST /v1/runs) let the server drive the agent with a machine_id and task, billing $0.05 per step. Configure max_steps, deadline_seconds, and on_awaiting_human to handle pauses or failures.

bash
curl -X POST https://coasty.ai/v1/sessions \ -H "X-API-Key: $COASTY_API_KEY" \ -H "Content-Type: application/json" \ -d '{"cua_version": "v3"}'
python
import base64
import os
import requests

API_KEY = os.getenv("COASTY_API_KEY")
BASE_URL = "https://coasty.ai/v1"

# First, create a session
resp = requests.post(
    f"{BASE_URL}/sessions",
    headers={"X-API-Key": API_KEY, "Content-Type": "application/json"},
    json={"cua_version": "v3"},
)
session = resp.json()
session_id = session["id"]

# Loop: capture, predict, act until done
while True:
    # Capture screenshot as base64 (replace with your screenshot capture)
    with open("screen.png", "rb") as f:
        screenshot = base64.b64encode(f.read()).decode("utf-8")

    resp = requests.post(
        f"{BASE_URL}/sessions/{session_id}/predict",
        headers={"X-API-Key": API_KEY, "Content-Type": "application/json"},
        json={
            "screenshot": screenshot,
            "instruction": "Fill the email field with [email protected], click Continue, then enter password and submit."
        },
    )
    result = resp.json()
    actions = result["actions"]
    status = result["status"]
    print("Actions:", actions)
    print("Status:", status)
    if status == "done":
        break
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": "Fill the checkout form and place the order", "cua_version": "v4", "max_steps": 100, "deadline_seconds": 600, "on_awaiting_human": "pause"}'

Key fields and pricing

  • Sessions POST /v1/sessions ($0.10) return an ID for stateful trajectories.
  • Session predict POST /v1/sessions/{id}/predict ($0.04) takes screenshot, instruction, and cua_version.
  • Ground POST /v1/ground ($0.03) maps screenshot + description to x,y coordinates.
  • Task runs POST /v1/runs ($0.05 per agent step) drive an agent with machine_id, task, max_steps, deadline_seconds, and on_awaiting_human.
  • Billing uses prepaid USD, 1 credit = $0.01.
  • Rate limits and scopes prevent abuse (403 INSUFFICIENT_SCOPE, 429 rate limit).

Start with POST /v1/sessions to get a stateful session, then POST /v1/sessions/{id}/predict in a loop until status is done.

Where this beats brittle automation

Traditional bots rely on CSS selectors, XPath, or hard‑coded coordinates. If the site reorders fields or changes class names, the bot fails. The Coasty Computer Use API sees the whole screen, reads text labels, and decides where to click based on what is visible. Grounding lets you map an element description to coordinates reliably. Task runs let the server manage retries, timeouts, and human approvals, so you focus on the business logic, not UI quirks.

Build checkout bots, data entry pipelines, and other workflows that handle dynamic UIs without brittle selectors. Get a key at https://coasty.ai/developers and start automating with the Coasty Computer Use API.

Want to see this in action?

View Case Studies
Try Coasty Free