Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Update custom functions

magmueller752f964c4e7f
diff --git a/docs/customize/custom-functions.mdx b/docs/customize/custom-functions.mdx
index b5463fc45..82ea12e95 100644
--- a/docs/customize/custom-functions.mdx
+++ b/docs/customize/custom-functions.mdx
@@ -9,8 +9,7 @@ icon: "code"
Functions can be either `sync` or `async`. Keep them focused and single-purpose.
```python
-from browser_use.controller.service import Controller
-from browser_use import ActionResult
+from browser_use import Controller, ActionResult
# Initialize the controller
controller = Controller()
@@ -45,8 +44,9 @@ agent = Agent(
For actions that need browser access, use the `requires_browser=True` parameter:
```python
-from browser_use.browser.service import Browser
+from browser_use import Browser, Controller, ActionResult
+controller = Controller()
@controller.action('Open website', requires_browser=True)
async def open_website(url: str, browser: Browser):
page = browser.get_current_page()
@@ -61,6 +61,9 @@ For complex actions, you can define parameter schemas using Pydantic models:
```python
from pydantic import BaseModel
from typing import Optional
+from browser_use import Controller, ActionResult, Browser
+
+controller = Controller()
class JobDetails(BaseModel):
title: str