Computer Use Agents
Incorporate Computer Use APIs from Anthropic and OpenAI with one line of code in Stagehand.
Computer Use agents are only available in Stagehand 2.0.
We strongly recommend using computer use agents when you find an iframe or other difficult-to-navigate elements on a page. IFrames are notoriously difficult to navigate with Playwright due to security constraints.
What is a Computer Use Agent?
You might’ve heard of Claude Computer Use or OpenAI’s Computer Using Agent.
These are powerful tools that can convert natural language into actions on the computer. However, you’d otherwise need to write your own code to convert these actions into Playwright commands.
Stagehand not only handles the execution of Computer Use outputs, but also lets you hot-swap between OpenAI and Anthropic models with one line of code.
How to use a Computer Use Agent in Stagehand
Stagehand lets you use Computer Use Agents with one line of code:
IMPORTANT! Configure your browser dimensions
Computer Use Agents will often return XY-coordinates to click on the screen, so you’ll need to configure your browser dimensions.