Claude Computer Use API: Building GUI Automation Agents That See, Click, and Navigate Desktop Applications
The Claude Computer Use API grants AI the ability to interact with graphical user interfaces the same way a human does — by viewing screenshots, identifying UI elements, and executing mouse clicks and keyboard inputs.
1. How Computer Use Works
[ Capture Screenshot ] --> [ Claude Vision Analysis ] --> [ Identify UI Elements ]
|
v
[ Generate Click Coordinates ]
|
v
[ Execute Mouse/Keyboard Action ]
|
v
[ Capture New Screenshot & Repeat ]
2. Implementation Example
import anthropic
client = anthropic.Anthropic()
def computer_use_agent(task: str):
messages = [{"role": "user", "content": task}]
while True:
response = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1024,
tools=[{
"type": "computer_20241022",
"name": "computer",
"display_width_px": 1920,
"display_height_px": 1080
}],
messages=messages
)
for block in response.content:
if block.type == "tool_use":
# Execute the action (click, type, screenshot)
result = execute_computer_action(block.input)
messages.append({"role": "tool", "content": result})
if response.stop_reason == "end_turn":
break
computer_use_agent("Open Chrome, navigate to our CRM, and export last month's sales report as CSV")
Computer Use API bridges the gap between AI automation and legacy software that lacks APIs — enabling automation of any desktop application.



















