Idempotency Keys in the Computer Use API: Never Double Charge
When you fire off a computer use task run, the agent steps through your cloud machine, clicks, types, and drives tools just like a human. If you retry an API call or your network flaps, you might end up with two successful runs for the same task. That is expensive because every agent step costs $0.05. The idempotency key fixes this by letting you replay the same request safely without triggering another billable run.
How it works
The idempotency key is a unique string you include in the POST /v1/runs request. The server checks whether it has already processed a run with that key. If yes, it returns the stored result without creating a new agent trajectory. If no, it proceeds normally and stores the result for future lookups. This works on reserve-and-replay operations when the key is present on the original request.
curl -X POST https://coasty.ai/v1/runs \
-H "Authorization: Bearer $COASTY_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: run-$(date +%s)-prod" \
-d '{
"machine_id": "prod-vm-123",
"task": "Open https://coasty.ai/docs in Chrome and find the pricing page link",
"cua_version": "v4",
"max_steps": 50,
"deadline_seconds": 120
}'Request fields for idempotency
- ●POST /v1/runs creates a task run on a provisioned machine_id
- ●"task" describes the user goal for the agent to act on the real desktop
- ●"cua_version" defaults to v3; v4 adds a pass/fail verifier
- ●"max_steps" caps the number of billed agent steps at $0.05 each
- ●"deadline_seconds" defines the time limit for the run to complete
- ●"Idempotency-Key" must be provided on the original request for reserve-and-replay safety
Response when the key is already known
If you POST the same idempotency key again, the server replies without starting a new agent. The response contains the same run_id, status, and result, and you are not billed for additional steps.
Where this beats brittle automation
Traditional automation relies on brittle selectors and fixed API endpoints. If a UI changes, selectors break and you lose control. With a computer use agent, the model sees the screen and decides where to click, type, or scroll. Idempotency keys let you safely retry or replay the same goal on the same machine without duplicating work. This gives you reliable automation that adapts to UI changes and stays within your budget.
Always include an Idempotency-Key on the original POST /v1/runs request to avoid duplicate billing.
Add idempotency keys to your task runs and ship stable computer use agents that never surprise you with extra charges. Get your API key and start building at https://coasty.ai/developers .