From Prototype to Production with the Coasty Computer Use API
Building a desktop automation prototype often means writing brittle selectors or talking to APIs that never change. When the UI shifts or the app adds a new modal, the script breaks. The Coasty computer use API flips that by letting an AI agent see the screen and act like a human. You can start with a simple loop of vision predictions, then move to a full machine-backed workflow that starts sessions, monitors progress, and handles failures automatically.
How it works
The Coasty computer use API has three core pieces for production. First, provision a cloud machine with POST /v1/machines. The machine_id is what the agent will use to drive a real desktop, browser, or terminal. Second, submit a task run with POST /v1/runs, which spins up an agent using the machine_id and a task description. The agent sees screenshots, predicts actions, and runs until it succeeds, fails, or hits a deadline. Third, stream events with GET /v1/runs/{id}/events to watch state transitions like queued, running, awaiting_human, succeeded, failed, cancelled, or timed_out. Pricing is $0.05 per agent step for task runs. Vision predictions cost $0.05 each when using the stateless endpoint. A session-based trajectory costs $0.04 per predict call, and the ground endpoint is $0.03 per element map.
#!/usr/bin/env bash
# 1. Provision a cloud machine
COASTY_API_KEY="${COASTY_API_KEY}"
MACHINE_ID=$(curl -s -X POST "https://coasty.ai/v1/machines" \
-H "X-API-Key: $COASTY_API_KEY" \
-H "Content-Type: application/json" \
-d ' {
"name": "demo-machine",
"OS": "windows",
"plan": "small"
}' | jq -r .machine_id)
echo "Machine ID: $MACHINE_ID"
# 2. Start a task run on that machine
RUN_ID=$(curl -s -X POST "https://coasty.ai/v1/runs" \
-H "X-API-Key: $COASTY_API_KEY" \
-H "Content-Type: application/json" \
-d ' {
"machine_id": "'$MACHINE_ID'",
"task": "Open Chrome, navigate to cozy.com, and log in with email [email protected] and password DemoPass123",
"cua_version": "v4",
"max_steps": 100,
"deadline_seconds": 300,
"on_awaiting_human": "pause"
}' | jq -r .run_id)
echo "Run ID: $RUN_ID"
# 3. Stream events (tail as the agent runs)
curl -s -N "https://coasty.ai/v1/runs/$RUN_ID/events" \
-H "X-API-Key: $COASTY_API_KEY" | jq -r '.state'Stateful sessions and trajectory memory
- ●Use POST /v1/sessions to create a stateful trajectory that persists between predictions.
- ●Each predict call costs $0.04 and can reference prior steps via stepId.field variables.
- ●Combine sessions with vision predictions for long-running workflows that need memory.
- ●The stateful API is ideal when you need to maintain context across multiple UI interactions.
POST /v1/runs is your production entry point: one request spins up a machine, launches a computer use agent, and streams state back to you.
Where this beats brittle automation
Traditional automation relies on CSS classes, IDs, or XPath selectors that break when UI changes. The Coasty computer use API lets an agent see the screen, understand natural language instructions, and take actions like clicking, typing, and dragging. It works across browsers, desktop apps, and terminals as long as the machine can display them. Workflows let you orchestrate tasks, retries, parallel branches, and human approval steps without rewriting code every time the UI shifts. A production agent can handle unexpected modals, missing elements, or dynamic content by re-evaluating the visual state on the next iteration.
Workflow orchestration for production
- ●POST /v1/workflows defines a versioned JSON DSL with steps like task, assert, if, loop, parallel, human_approval, retry, succeed, and fail.
- ●Variables use double-brace syntax like inputs.x and stepId.field to reference previous outputs.
- ●Budget guards (budget_cents), iteration limits (max_iterations), and deadlines (deadline_seconds) prevent runaway costs.
- ●A workflow can chain multiple agents, parallelize checks, and automatically retry failed tasks.
From a prototype that guesses where to click to a production workflow that drives real machines and handles failures, the Coasty computer use API gives you a path forward. Start by provisioning a machine, submitting a task run, and streaming events. Then expand into stateful sessions for trajectory memory and workflows for orchestration. Get your API key and start building at https://coasty.ai/developers.