diff --git a/docs.json b/docs.json index 3cbe64f..340b812 100644 --- a/docs.json +++ b/docs.json @@ -81,6 +81,7 @@ { "group": "Integrations", "pages": [ + "integrations/browser-use", "integrations/valtown", "integrations/vercel" ] diff --git a/integrations/browser-use.mdx b/integrations/browser-use.mdx new file mode 100644 index 0000000..87efc76 --- /dev/null +++ b/integrations/browser-use.mdx @@ -0,0 +1,103 @@ +--- +title: "Browser Use" +--- + +[Browser Use](https://github.com/browser-use/browser-use) is the AI browser agent that empowers anyone to automate repetitive online tasks, no code required. By integrating with Kernel, you can run Browser Use Agents and automations with cloud-hosted browsers. + +## Adding Kernel to existing Browser Use implementations + +If you already have a Browser Use implementation, you can easily switch to using Kernel's cloud browsers by updating your Browser definition. + +### 1. Install the Kernel SDK + +```bash +uv add kernel +``` + +### 2. Initialize Kernel and create a browser + +Import the libraries and create a cloud browser session: + +```python +from kernel import Kernel +from browser_use import Browser, Agent + +# Initialize Kernel client +client = Kernel(api_key="your-api-key") + +# Create a Kernel browser session +kernel_browser = client.browsers.create() +``` + +### 3. Update your Browser definition + +Replace your existing Browser initialization to use Kernel's CDP URL and display settings: + +```python +# Update your Browser definition to use Kernel's CDP URL +browser = Browser( + cdp_url=kernel_browser.cdp_ws_url, + headless=False, + window_size={'width': 1024, 'height': 786}, + viewport={'width': 1024, 'height': 786}, + device_scale_factor=1.0 +) +``` + +### 4. Create and run your agent + +Use your existing Agent setup with the Kernel-powered browser: + +```python +# Use with your existing Agent setup +agent = Agent( + task="Your automation task", + llm=your_llm_instance, + browser_session=browser +) + +# Run your automation +result = agent.run() + +# Clean up +client.browsers.delete_by_id(kernel_browser.session_id) +``` + + +If you're using Browser Use versions `< 0.7.9`, you may need to use a [custom resize class](https://github.com/onkernel/create-kernel-app/blob/main/templates/python/browser-use/session.py) to correct viewport sizing for the browser session. Here's how to use it: + +```python +agent = Agent( + task="Your automation task", + llm=your_llm_instance, + browser_session=BrowserSessionCustomResize(cdp_url=kernel_browser.cdp_ws_url) +) +``` + + +## Quick setup with our Browser Use example app + +Alternatively, you can use our Kernel app template that includes a pre-configured Browser Use integration: + +```bash +npx @onkernel/create-kernel-app my-browser-use-app +``` + +Choose Python as the programming language and then select `browser-use` as the template. + +Then follow the [Quickstart guide](/quickstart/) to deploy and run your Browser Use automation on Kernel's infrastructure. + +## Benefits of using Kernel with Browser Use + +- **No local browser management**: Run automations without installing or maintaining browsers locally +- **Scalability**: Launch multiple browser sessions in parallel +- **Stealth mode**: Built-in anti-detection features for web scraping +- **Session persistence**: Maintain browser state across automation runs +- **Live view**: Debug your automations with real-time browser viewing + +## Next steps + +- Check out [live view](/browsers/live-view) for debugging your automations +- Learn about [stealth mode](/browsers/stealth) for avoiding detection +- Learn how to properly [terminate browser sessions](/browsers/termination) +- Learn how to [deploy](/apps/deploy) your Browser Use app to Kernel \ No newline at end of file diff --git a/snippets/openapi/delete-browsers-id.mdx b/snippets/openapi/delete-browsers-id.mdx index cdf3340..950e158 100644 --- a/snippets/openapi/delete-browsers-id.mdx +++ b/snippets/openapi/delete-browsers-id.mdx @@ -17,7 +17,7 @@ client = Kernel( api_key="My API Key", ) client.browsers.delete_by_id( - "id", + "htzv5orfit78e1m2biiifpbv", ) ``` diff --git a/snippets/openapi/delete-proxies-id.mdx b/snippets/openapi/delete-proxies-id.mdx new file mode 100644 index 0000000..3866791 --- /dev/null +++ b/snippets/openapi/delete-proxies-id.mdx @@ -0,0 +1,23 @@ + +```typescript Typescript/Javascript +import Kernel from '@onkernel/sdk'; + +const client = new Kernel({ + apiKey: 'My API Key', +}); + +await client.proxies.delete('id'); +``` + + +```python Python +from kernel import Kernel + +client = Kernel( + api_key="My API Key", +) +client.proxies.delete( + "id", +) +``` + diff --git a/snippets/openapi/get-browsers-id.mdx b/snippets/openapi/get-browsers-id.mdx index bc84e3b..6c6e3b4 100644 --- a/snippets/openapi/get-browsers-id.mdx +++ b/snippets/openapi/get-browsers-id.mdx @@ -19,7 +19,7 @@ client = Kernel( api_key="My API Key", ) browser = client.browsers.retrieve( - "id", + "htzv5orfit78e1m2biiifpbv", ) print(browser.session_id) ``` diff --git a/snippets/openapi/get-invocations-id.mdx b/snippets/openapi/get-invocations-id.mdx index 7dbd194..277a603 100644 --- a/snippets/openapi/get-invocations-id.mdx +++ b/snippets/openapi/get-invocations-id.mdx @@ -19,7 +19,7 @@ client = Kernel( api_key="My API Key", ) invocation = client.invocations.retrieve( - "id", + "rr33xuugxj9h0bkf1rdt2bet", ) print(invocation.id) ``` diff --git a/snippets/openapi/get-proxies-id.mdx b/snippets/openapi/get-proxies-id.mdx new file mode 100644 index 0000000..c2d7c42 --- /dev/null +++ b/snippets/openapi/get-proxies-id.mdx @@ -0,0 +1,26 @@ + +```typescript Typescript/Javascript +import Kernel from '@onkernel/sdk'; + +const client = new Kernel({ + apiKey: 'My API Key', +}); + +const proxy = await client.proxies.retrieve('id'); + +console.log(proxy.id); +``` + + +```python Python +from kernel import Kernel + +client = Kernel( + api_key="My API Key", +) +proxy = client.proxies.retrieve( + "id", +) +print(proxy.id) +``` + diff --git a/snippets/openapi/get-proxies.mdx b/snippets/openapi/get-proxies.mdx new file mode 100644 index 0000000..7df6a00 --- /dev/null +++ b/snippets/openapi/get-proxies.mdx @@ -0,0 +1,24 @@ + +```typescript Typescript/Javascript +import Kernel from '@onkernel/sdk'; + +const client = new Kernel({ + apiKey: 'My API Key', +}); + +const proxies = await client.proxies.list(); + +console.log(proxies); +``` + + +```python Python +from kernel import Kernel + +client = Kernel( + api_key="My API Key", +) +proxies = client.proxies.list() +print(proxies) +``` + diff --git a/snippets/openapi/post-proxies.mdx b/snippets/openapi/post-proxies.mdx new file mode 100644 index 0000000..7e81422 --- /dev/null +++ b/snippets/openapi/post-proxies.mdx @@ -0,0 +1,26 @@ + +```typescript Typescript/Javascript +import Kernel from '@onkernel/sdk'; + +const client = new Kernel({ + apiKey: 'My API Key', +}); + +const proxy = await client.proxies.create({ type: 'datacenter' }); + +console.log(proxy.id); +``` + + +```python Python +from kernel import Kernel + +client = Kernel( + api_key="My API Key", +) +proxy = client.proxies.create( + type="datacenter", +) +print(proxy.id) +``` +