Tutorial

From Prototype to Production with the Coasty Computer Use API

Priya Patel||8 min
+Space

You can mock a UI or write brittle selectors, but real automation needs to see what sits on the screen. The Coasty computer use API lets you drive a real desktop or browser with vision‑based actions. Start with a quick prototype using stateless prediction, then move to managed Task Runs and Workflows for production. We cover the exact endpoints, fields, and prices so you can copy the code and ship.

How a computer use agent works

The agent receives a screenshot, an instruction, and the CUA version. It returns a list of actions such as click, type, and scroll. For stateless prediction you POST /v1/predict with a base64 screenshot, instruction, and cua_version. The server returns actions and a status. Loop capture, predict, act until the status is done. The Vision endpoint costs $0.05 per call. For production you can POST /v1/runs to let the server drive a Task Run. Each agent step costs $0.05 and the server manages the loop, retries, and human approval.

bash
#!/bin/bash
# Stateless prediction with Coasty computer use API
# Replace $COASTY_API_KEY with your actual key (read from env)

export COASTY_API_KEY=${COASTY_API_KEY:-"your-api-key-here"}

SESSION_ID="$(uuidgen)"

# Capture a screenshot (replace with your tool)
SCREENSHOT=$(base64 -i screenshot.png)

# Stateless predict call
RESPONSE=$(curl -s -X POST https://coasty.ai/v1/predict \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "screenshot": "'$SCREENSHOT'",
    "instruction": "Click the login button and type [email protected].",
    "cua_version": "v3"
  }')

echo "$RESPONSE"

Production: Task Runs

  • POST /v1/runs with machine_id, task, cua_version (default v3, v4 adds a pass/fail verifier)
  • Optional parameters: instructions (appended to base prompt), system_prompt, max_steps, deadline_seconds, on_awaiting_human (pause, fail, cancel), webhook_url
  • Server bills $0.05 per agent step
  • States: queued, running, awaiting_human, succeeded, failed, cancelled, timed_out
  • GET /v1/runs , GET /v1/runs/{id} , POST /v1/runs/{id}/cancel , POST /v1/runs/{id}/resume
  • GET /v1/runs/{id}/events streams Server‑Sent Events with Last‑Event‑ID for reconnects

Orchestration with Workflows

  • POST /v1/workflows to define a versioned JSON DSL of runs
  • POST /v1/workflows/{id}/runs or POST /v1/workflows/runs for ad‑hoc inline runs
  • Step types: task, assert, if, loop, parallel, human_approval, retry, succeed, fail
  • Variables like {{inputs.x}} and stepId.field for dynamic values
  • Hard guards: budget_cents, max_iterations, deadline_seconds
  • Task steps are billed $0.05 each

Each agent step costs $0.05, and Task Runs are billed per step with a server‑driven loop and event stream.

Where this beats brittle automation

Traditional UI automation relies on selectors and IDs that break with layout changes. The computer use agent sees the real screen, so it adapts to any visual layout or dynamic content. It can handle native windows, browser popups, and mixed‑tool workflows. Vision grounding via POST /v1/ground maps a screenshot and element description to precise coordinates for click targets. Combined with the free POST /v1/parse that turns pyautogui code into structured actions, you get a full stack from prototype to production without brittle selectors.

Start with /v1/predict to prototype a vision‑based agent, then switch to /v1/runs for managed Task Runs and /v1/workflows for complex automation. Use the MCP server to drive Coasty from Cursor, Claude Desktop, or other MCP clients. Ready to build? Get a key at https://coasty.ai/developers.

Want to see this in action?

View Case Studies
Try Coasty Free