Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
{
"group": "Integrations",
"pages": [
"integrations/browser-use",
"integrations/valtown",
"integrations/vercel"
]
Expand Down
103 changes: 103 additions & 0 deletions integrations/browser-use.mdx
Original file line number Diff line number Diff line change
@@ -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
pip install onkernel
```

### 2. Initialize Kernel and create a browser

Import the libraries and create a cloud browser session:

```python
from onkernel import Kernel
from browser_use import Browser, Agent

# Initialize Kernel client
kernel = Kernel(api_key="your-api-key")

# Create a Kernel browser session
kernel_browser = kernel.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
kernel.browsers.delete_by_id(kernel_browser.session_id)
```

<Info>
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)
)
```
</Info>

## 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
2 changes: 1 addition & 1 deletion snippets/openapi/delete-browsers-id.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ client = Kernel(
api_key="My API Key",
)
client.browsers.delete_by_id(
"id",
"htzv5orfit78e1m2biiifpbv",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope - wondering if that's from Hiro's work? I didn't change that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohhh good call

)
```
</CodeGroup>
23 changes: 23 additions & 0 deletions snippets/openapi/delete-proxies-id.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<CodeGroup>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this from another commit that's not yet in main?

```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",
)
```
</CodeGroup>
2 changes: 1 addition & 1 deletion snippets/openapi/get-browsers-id.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ client = Kernel(
api_key="My API Key",
)
browser = client.browsers.retrieve(
"id",
"htzv5orfit78e1m2biiifpbv",
)
print(browser.session_id)
```
Expand Down
2 changes: 1 addition & 1 deletion snippets/openapi/get-invocations-id.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ client = Kernel(
api_key="My API Key",
)
invocation = client.invocations.retrieve(
"id",
"rr33xuugxj9h0bkf1rdt2bet",
)
print(invocation.id)
```
Expand Down
26 changes: 26 additions & 0 deletions snippets/openapi/get-proxies-id.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<CodeGroup>
```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)
```
</CodeGroup>
24 changes: 24 additions & 0 deletions snippets/openapi/get-proxies.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<CodeGroup>
```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)
```
</CodeGroup>
26 changes: 26 additions & 0 deletions snippets/openapi/post-proxies.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<CodeGroup>
```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)
```
</CodeGroup>