Tutorial

Automating Form Filling and Checkout Flows Over the Computer Use API

Michael Rodriguez||6 min
End

Checkout pages are a nightmare for brittle automation. They shift layouts, change IDs, and hide fields behind JavaScript. You can try to map every possible selector or scrape hidden inputs, but that is fragile and hard to maintain. The Coasty Computer Use API gives you a computer use agent that sees the screen and acts exactly as a human would. It reads the current state, follows visual cues, and completes multi-step flows reliably. You drive the agent from your own code over the API. In this post you will build a complete form-filling and checkout flow using the real endpoints and pricing from the API.

How it works

The API lets you drive a cloud desktop or browser session. You send a task description and the agent acts on the screen. The flow is built from two main pieces. First you provision a machine. Second you run a task that fills a form and completes checkout. The stateful session remembers the history of actions, so the agent can reference variables like {{ inputs.email }} for the email you pass in. The agent sees the screenshot, predicts actions, and repeats until the status is done. You pay per agent step at 0.05 USD per step. The session API costs 0.10 USD to create, 0.04 USD per predict call, and 0.03 USD for the ground call to map visual descriptions to coordinates.

bash
curl https://coasty.ai/v1/machines \ -X POST \ -H "X-API-Key: $COASTY_API_KEY" \ -H "Content-Type: application/json" \ -d '{
  "app_name": "chrome",
  "os": "linux"
}'

Provisioning a machine

  • POST /v1/machines creates a cloud VM with a browser or desktop environment.
  • Provide app_name (e.g., chrome) and os (e.g., linux) to get the right environment.
  • The machine starts in a ready state you can pause, stop, or snapshot.
python
import os
import requests

class CoastyClient:
    def __init__(self):
        self.api_key = os.getenv("COASTY_API_KEY")
        self.base = "https://coasty.ai/v1"

    def create_session(self, machine_id):
        resp = requests.post(
            f"{self.base}/sessions",
            headers={"X-API-Key": self.api_key},
            json={"machine_id": machine_id},
        )
        resp.raise_for_status()
        return resp.json()  # returns {"id": "sess-...", "status": "running"}

client = CoastyClient()
sess = client.create_session("machine-123")
print(sess)

A machine ID is required for each session. The session API costs $0.10 to create.

Running a task for form filling and checkout

Once you have a session, you send a task that fills inputs, clicks buttons, and handles checkout. You use the predict endpoint repeatedly. The agent returns actions and a status. When the status is done, the task is finished. You can also use workflows for multi-step flows with variables and guards. The task is billed $0.05 per agent step. The predict call costs $0.04 per request. Ground calls to map element descriptions to coordinates cost $0.03 each.

python
import os
import base64
import requests

class CoastyClient:
    def __init__(self):
        self.api_key = os.getenv("COASTY_API_KEY")
        self.base = "https://coasty.ai/v1"

    def create_session(self, machine_id):
        resp = requests.post(
            f"{self.base}/sessions",
            headers={"X-API-Key": self.api_key},
            json={"machine_id": machine_id},
        )
        resp.raise_for_status()
        return resp.json()

    def capture_and_predict(self, sess_id, instruction):
        # In a real flow you would read a screenshot from the machine
        # Here we show the API call structure
        resp = requests.post(
            f"{self.base}/sessions/{sess_id}/predict",
            headers={
                "X-API-Key": self.api_key,
                "Content-Type": "application/json",
            },
            json={
                "instruction": instruction,
                "cua_version": "v3",
            },
        )
        resp.raise_for_status()
        return resp.json()  # {"actions": [...], "status": "running"}

# Example usage
client = CoastyClient()
sess = client.create_session("machine-123")
result = client.capture_and_predict(sess["id"], "Fill the email field with my test email and click checkout.")
print(result)

Where this beats brittle automation

With selectors you must know every possible ID, class, and XPath for every element. When a layout changes, your script breaks. The computer use agent sees the screen. It can read labels, placeholders, and even text next to an input. It clicks buttons based on text and position, not hardcoded IDs. This means you can run the same flow on many sites without re-encoding selectors for each one. The agent also handles human-like delays and navigation. You do not need to build complex wait logic or work around CAPTCHAs manually. The API gives you a real desktop or browser environment, so the agent interacts with the page exactly as a human would.

You can now build checkout automation that reads pages, fills forms, and completes flows reliably. Use workflows for multi-step processes with variables, retries, and guards. Start with a simple form fill and extend to complex checkout journeys. Get your API key at https://coasty.ai/developers and build your first computer use agent.

Want to see this in action?

View Case Studies
Try Coasty Free