-
Notifications
You must be signed in to change notification settings - Fork 3
Add browser use guide #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dprevoznik
merged 6 commits into
main
from
danny/kernel-361-docs-integration-guide-for-browser-use
Sep 24, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7ba74bb
Add browser use guide
dprevoznik 9949471
docs: update code samples from OpenAPI
github-actions[bot] 1d12cdd
Update browser-use.mdx
dprevoznik 1e2914b
Simplified kernel install
dprevoznik ec2fa06
Update kernel import
dprevoznik a2b4c5f
Change kernel to client variable name
dprevoznik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| 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) | ||
| ``` | ||
|
|
||
| <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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <CodeGroup> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this from another commit that's not yet in |
||
| ```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> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentional?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohhh good call