Skip to content

Commit 3f6f90b

Browse files
Add browser use guide (#52)
* Add browser use guide Added browser user integration guide to docs. It includes a guide for integrating into an existing browser use implementation as well as starting from scratch with our app template. * docs: update code samples from OpenAPI * Update browser-use.mdx Updated to UV method and included dependency name. * Simplified kernel install Simplified to use uv add instead of two steps * Update kernel import Updated kernel import * Change kernel to client variable name To avoid confusion, changing name of class to client instead of the package name kernel --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 67a3532 commit 3f6f90b

File tree

9 files changed

+206
-3
lines changed

9 files changed

+206
-3
lines changed

docs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
{
8282
"group": "Integrations",
8383
"pages": [
84+
"integrations/browser-use",
8485
"integrations/valtown",
8586
"integrations/vercel"
8687
]

integrations/browser-use.mdx

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
title: "Browser Use"
3+
---
4+
5+
[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.
6+
7+
## Adding Kernel to existing Browser Use implementations
8+
9+
If you already have a Browser Use implementation, you can easily switch to using Kernel's cloud browsers by updating your Browser definition.
10+
11+
### 1. Install the Kernel SDK
12+
13+
```bash
14+
uv add kernel
15+
```
16+
17+
### 2. Initialize Kernel and create a browser
18+
19+
Import the libraries and create a cloud browser session:
20+
21+
```python
22+
from kernel import Kernel
23+
from browser_use import Browser, Agent
24+
25+
# Initialize Kernel client
26+
client = Kernel(api_key="your-api-key")
27+
28+
# Create a Kernel browser session
29+
kernel_browser = client.browsers.create()
30+
```
31+
32+
### 3. Update your Browser definition
33+
34+
Replace your existing Browser initialization to use Kernel's CDP URL and display settings:
35+
36+
```python
37+
# Update your Browser definition to use Kernel's CDP URL
38+
browser = Browser(
39+
cdp_url=kernel_browser.cdp_ws_url,
40+
headless=False,
41+
window_size={'width': 1024, 'height': 786},
42+
viewport={'width': 1024, 'height': 786},
43+
device_scale_factor=1.0
44+
)
45+
```
46+
47+
### 4. Create and run your agent
48+
49+
Use your existing Agent setup with the Kernel-powered browser:
50+
51+
```python
52+
# Use with your existing Agent setup
53+
agent = Agent(
54+
task="Your automation task",
55+
llm=your_llm_instance,
56+
browser_session=browser
57+
)
58+
59+
# Run your automation
60+
result = agent.run()
61+
62+
# Clean up
63+
client.browsers.delete_by_id(kernel_browser.session_id)
64+
```
65+
66+
<Info>
67+
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:
68+
69+
```python
70+
agent = Agent(
71+
task="Your automation task",
72+
llm=your_llm_instance,
73+
browser_session=BrowserSessionCustomResize(cdp_url=kernel_browser.cdp_ws_url)
74+
)
75+
```
76+
</Info>
77+
78+
## Quick setup with our Browser Use example app
79+
80+
Alternatively, you can use our Kernel app template that includes a pre-configured Browser Use integration:
81+
82+
```bash
83+
npx @onkernel/create-kernel-app my-browser-use-app
84+
```
85+
86+
Choose Python as the programming language and then select `browser-use` as the template.
87+
88+
Then follow the [Quickstart guide](/quickstart/) to deploy and run your Browser Use automation on Kernel's infrastructure.
89+
90+
## Benefits of using Kernel with Browser Use
91+
92+
- **No local browser management**: Run automations without installing or maintaining browsers locally
93+
- **Scalability**: Launch multiple browser sessions in parallel
94+
- **Stealth mode**: Built-in anti-detection features for web scraping
95+
- **Session persistence**: Maintain browser state across automation runs
96+
- **Live view**: Debug your automations with real-time browser viewing
97+
98+
## Next steps
99+
100+
- Check out [live view](/browsers/live-view) for debugging your automations
101+
- Learn about [stealth mode](/browsers/stealth) for avoiding detection
102+
- Learn how to properly [terminate browser sessions](/browsers/termination)
103+
- Learn how to [deploy](/apps/deploy) your Browser Use app to Kernel

snippets/openapi/delete-browsers-id.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ client = Kernel(
1717
api_key="My API Key",
1818
)
1919
client.browsers.delete_by_id(
20-
"id",
20+
"htzv5orfit78e1m2biiifpbv",
2121
)
2222
```
2323
</CodeGroup>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<CodeGroup>
2+
```typescript Typescript/Javascript
3+
import Kernel from '@onkernel/sdk';
4+
5+
const client = new Kernel({
6+
apiKey: 'My API Key',
7+
});
8+
9+
await client.proxies.delete('id');
10+
```
11+
12+
13+
```python Python
14+
from kernel import Kernel
15+
16+
client = Kernel(
17+
api_key="My API Key",
18+
)
19+
client.proxies.delete(
20+
"id",
21+
)
22+
```
23+
</CodeGroup>

snippets/openapi/get-browsers-id.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ client = Kernel(
1919
api_key="My API Key",
2020
)
2121
browser = client.browsers.retrieve(
22-
"id",
22+
"htzv5orfit78e1m2biiifpbv",
2323
)
2424
print(browser.session_id)
2525
```

snippets/openapi/get-invocations-id.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ client = Kernel(
1919
api_key="My API Key",
2020
)
2121
invocation = client.invocations.retrieve(
22-
"id",
22+
"rr33xuugxj9h0bkf1rdt2bet",
2323
)
2424
print(invocation.id)
2525
```
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<CodeGroup>
2+
```typescript Typescript/Javascript
3+
import Kernel from '@onkernel/sdk';
4+
5+
const client = new Kernel({
6+
apiKey: 'My API Key',
7+
});
8+
9+
const proxy = await client.proxies.retrieve('id');
10+
11+
console.log(proxy.id);
12+
```
13+
14+
15+
```python Python
16+
from kernel import Kernel
17+
18+
client = Kernel(
19+
api_key="My API Key",
20+
)
21+
proxy = client.proxies.retrieve(
22+
"id",
23+
)
24+
print(proxy.id)
25+
```
26+
</CodeGroup>

snippets/openapi/get-proxies.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<CodeGroup>
2+
```typescript Typescript/Javascript
3+
import Kernel from '@onkernel/sdk';
4+
5+
const client = new Kernel({
6+
apiKey: 'My API Key',
7+
});
8+
9+
const proxies = await client.proxies.list();
10+
11+
console.log(proxies);
12+
```
13+
14+
15+
```python Python
16+
from kernel import Kernel
17+
18+
client = Kernel(
19+
api_key="My API Key",
20+
)
21+
proxies = client.proxies.list()
22+
print(proxies)
23+
```
24+
</CodeGroup>

snippets/openapi/post-proxies.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<CodeGroup>
2+
```typescript Typescript/Javascript
3+
import Kernel from '@onkernel/sdk';
4+
5+
const client = new Kernel({
6+
apiKey: 'My API Key',
7+
});
8+
9+
const proxy = await client.proxies.create({ type: 'datacenter' });
10+
11+
console.log(proxy.id);
12+
```
13+
14+
15+
```python Python
16+
from kernel import Kernel
17+
18+
client = Kernel(
19+
api_key="My API Key",
20+
)
21+
proxy = client.proxies.create(
22+
type="datacenter",
23+
)
24+
print(proxy.id)
25+
```
26+
</CodeGroup>

0 commit comments

Comments
 (0)