1

Generate your API key

Head to the Settings tab on the Plato dashboard and copy your API key. Keep this secure - you’ll need it for all API requests.

Your API key provides access to your Plato environments. Never share it publicly or commit it to version control.

2

Install the SDK

Choose your preferred language and install the Plato SDK:

pip install plato-client

Python SDK requires Python 3.8+ and JavaScript SDK requires Node.js 16+

3

Set up your environment variables

Create a .env file in your project root and add your API key:

.env
PLATO_API_KEY=your_api_key_here
PLATO_BASE_URL=https://api.plato.so  

The SDK will automatically load these environment variables.

4

Create your first environment

Let’s create a browser environment and connect to it:

import asyncio
from plato import Plato

async def main():
    # Initialize client (uses PLATO_API_KEY from environment)
    client = Plato()
    
    # Create a new environment
    print("Creating environment...")
    env = await client.make_environment(
        env_id="doordash",  # Choose from available simulators
        open_page_on_start=True,
        viewport_width=1920,
        viewport_height=1080
    )
    
    # Wait for environment to be ready
    print("Waiting for environment to initialize...")
    await env.wait_for_ready(timeout=300.0)
    
    # Start a session
    print("Starting session...")
    await env.reset()
    
    print(f"✅ Environment ready! ID: {env.id}")
    
    # Get live view URL for monitoring
    live_url = await env.get_live_view_url()
    print(f"🔗 Monitor your environment: {live_url}")
    
    # Clean up
    await env.close()
    await client.close()

if __name__ == "__main__":
    asyncio.run(main())
5

Connect with browser automation

Now let’s connect to the environment and perform some browser automation:

import asyncio
from plato import Plato
from playwright.async_api import async_playwright

async def main():
    client = Plato()
    env = await client.make_environment("doordash")
    
    await env.wait_for_ready()
    await env.reset()
    
    # Get CDP URL for browser connection
    cdp_url = await env.get_cdp_url()
    
    # Connect with Playwright
    async with async_playwright() as p:
        browser = await p.chromium.connect_over_cdp(cdp_url)
        
        # Get existing page or create new one
        contexts = browser.contexts
        if contexts:
            context = contexts[0]
            pages = context.pages
            page = pages[0] if pages else await context.new_page()
        else:
            context = await browser.new_context()
            page = await context.new_page()
        
        # Navigate to a website
        await page.goto("https://example.com")
        
        # Take screenshot
        await page.screenshot(path="screenshot.png")
        
        # Get page title
        title = await page.title()
        print(f"Page title: {title}")
        
        # Perform actions
        await page.click("h1")  # Click the heading
        
        await browser.close()
    
    # Get environment state
    state = await env.get_state()
    print(f"Environment state: {state}")
    
    await env.close()
    await client.close()

asyncio.run(main())

The environment provides a real browser that persists state between operations. Perfect for complex workflows that require maintaining session data, cookies, and page state.

6

Load and run tasks

Plato provides pre-built tasks for various simulators. Here’s how to load and run them:

Python
import asyncio
from plato import Plato

async def main():
    client = Plato()
    
    # List available simulators
    simulators = await client.list_simulators()
    print("Available simulators:")
    for sim in simulators:
        print(f"  - {sim['name']}: {sim['description']}")
    
    # Load tasks for a specific simulator
    tasks = await client.load_tasks("doordash")
    print(f"\nFound {len(tasks)} tasks for DoorDash:")
    
    for task in tasks[:3]:  # Show first 3 tasks
        print(f"  📋 {task.name}")
        print(f"     Prompt: {task.prompt}")
        print(f"     Start URL: {task.start_url}")
        print(f"     Avg. time: {task.average_time}s")
        print()
    
    # Run a specific task
    if tasks:
        task = tasks[0]
        env = await client.make_environment(task.env_id)
        await env.wait_for_ready()
        
        # Reset with the specific task
        await env.reset(task=task)
        
        # Your agent code would go here
        print(f"🚀 Ready to run task: {task.name}")
        
        # Get live view for monitoring
        live_url = await env.get_live_view_url()
        print(f"🔗 Monitor execution: {live_url}")
        
        await env.close()
    
    await client.close()

asyncio.run(main())
7

Integrate your own agent

Here’s how to integrate your own agent with a Plato environment:

Python
import asyncio
from plato import Plato

class YourAgent:
    def __init__(self, cdp_url):
        self.cdp_url = cdp_url
    
    async def start(self):
        # Your agent implementation here
        # Connect to the browser using the CDP URL
        # Perform your automation logic
        print(f"Agent connected to: {self.cdp_url}")
        # Return any results or state
        return {"status": "completed", "actions_taken": 5}

async def main():
    # Initialize client
    client = Plato()
    
    # List available simulators
    simulators = await client.list_simulators()
    print(f"Available simulators: {[s['name'] for s in simulators]}")
    
    # Load tasks for a specific simulator
    tasks = await client.load_tasks("doordash")
    print(f"Found {len(tasks)} tasks")
    
    # Create environment
    env = await client.make_environment("doordash")
    await env.wait_for_ready()
    
    # Start interaction
    await env.reset()
    cdp_url = await env.get_cdp_url()
    
    # Take actions with your agent
    your_agent = YourAgent(cdp_url)
    agent_result = await your_agent.start()
    
    # Get final state mutations
    state_changes = await env.get_state()
    
    print(f"Agent result: {agent_result}")
    print(f"State changes: {state_changes}")
    
    # Clean up
    await env.close()
    await client.close()

asyncio.run(main())

Replace YourAgent with your actual agent implementation. The CDP URL provides direct access to the browser for any automation framework.

8

Evaluate task completion

After running your automation, evaluate whether the task was completed successfully:

Python
# After running your automation logic

# Get final environment state
final_state = await env.get_state()
print(f"Final state: {final_state}")

# Evaluate task completion
result = await env.evaluate()
print(f"Task completed: {result.success}")
if result.success:
    print("✅ Task completed successfully!")
else:
    print(f"❌ Task failed: {result.reason}")

# Optionally log results
await env.log({
    "task_name": task.name,
    "success": result.success,
    "custom_data": "any additional info"
}, type="info")

What’s Next?

Need Help?

  • Environment not starting? Check that your API key is valid and you have sufficient credits
  • Browser connection issues? Ensure you’re calling reset() before get_cdp_url()
  • Task evaluation failing? Review the task requirements and ensure your automation achieves the expected outcome

Use the live view URL to monitor your environment in real-time. This is invaluable for debugging and understanding how your automation is performing.