Setup

Install the required packages:

pip install orgo anthropic

Basic Integration

Connect Orgo with Claude:

from orgo import Computer
from orgo.adapters import AnthropicAdapter
import anthropic

# Initialize components
computer = Computer()  # Uses ORGO_API_KEY environment variable
adapter = AnthropicAdapter(computer)
claude = anthropic.Anthropic()  # Uses ANTHROPIC_API_KEY environment variable

Using Tool Definitions

Include Orgo’s computer in your Claude requests:

# Get the tool definition for Claude
tool_definition = adapter.get_tool_definition()

# Use it in your Claude request
response = claude.beta.messages.create(
    model="claude-3-7-sonnet-20250219",
    tools=[tool_definition],
    messages=[{"role": "user", "content": "Open Firefox and search for cats"}],
    betas=["computer-use-2025-01-24"]  # Required for computer use
)

Handling Tool Use

Process Claude’s tool requests:

if response.stop_reason == "tool_use":
    # Find the tool use request in Claude's response
    tool = next(block for block in response.content if block.type == "tool_use")
    
    # Execute the requested action based on its type
    if tool.input.get("action") == "left_click":
        x, y = tool.input["coordinate"]
        computer.left_click(x, y)
    elif tool.input.get("action") == "type":
        computer.type(tool.input["text"])
    elif tool.input.get("action") == "key":
        computer.key(tool.input["text"])
    
    # Format the result to send back to Claude
    tool_result = adapter.format_result(tool_id=tool.id)
    
    # Continue the conversation with the tool result
    messages.append({"role": "assistant", "content": response.content})
    messages.append({"role": "user", "content": [tool_result]})

Complete Example

Here’s a full agent that can execute tasks:

from orgo import Computer
from orgo.adapters import AnthropicAdapter
import anthropic

def run_agent(prompt):
    computer = Computer()
    adapter = AnthropicAdapter(computer)
    claude = anthropic.Anthropic()
    
    try:
        # Start conversation
        messages = [{"role": "user", "content": prompt}]
        
        while True:
            # Get Claude's response
            response = claude.beta.messages.create(
                model="claude-3-7-sonnet-20250219",
                tools=[adapter.get_tool_definition()],
                messages=messages,
                betas=["computer-use-2025-01-24"]
            )
            
            # Add Claude's response to conversation
            messages.append({"role": "assistant", "content": response.content})
            
            # Check if Claude wants to use a tool
            if response.stop_reason != "tool_use":
                # Task complete, return Claude's final response
                return response.content
            
            # Extract tool use request
            tool = next(block for block in response.content if block.type == "tool_use")
            
            # Execute the requested action
            if tool.input.get("action") == "left_click":
                computer.left_click(tool.input["coordinate"][0], tool.input["coordinate"][1])
            elif tool.input.get("action") == "type":
                computer.type(tool.input["text"])
            elif tool.input.get("action") == "key":
                computer.key(tool.input["text"])
            # Add support for more actions as needed
            
            # Send tool result back to Claude
            tool_result = adapter.format_result(tool_id=tool.id)
            messages.append({"role": "user", "content": [tool_result]})
    
    finally:
        # Always clean up resources
        computer.shutdown()

# Example usage
result = run_agent("Open Firefox and navigate to anthropic.com")
print(result)

Supported Actions

ActionOrgo MethodDescription
left_clickcomputer.left_click(x, y)Left click at coordinates
right_clickcomputer.right_click(x, y)Right click at coordinates
double_clickcomputer.double_click(x, y)Double click at coordinates
typecomputer.type(text)Type text
keycomputer.key(sequence)Press keys (e.g., “Enter”, “ctrl+c”)
screenshotcomputer.screenshot()Take a screenshot
scrollcomputer.scroll(direction, amount)Scroll in a direction