|
| 1 | +--- |
| 2 | +title: "Magnitude" |
| 3 | +--- |
| 4 | + |
| 5 | +[Magnitude](https://magnitude.run) is an open source AI browser automation framework. It uses vision AI to enable you to control your browser with natural language. By integrating with Kernel, you can run Magnitude agents and automations with cloud-hosted browsers. |
| 6 | + |
| 7 | +## Adding Kernel to existing Magnitude implementations |
| 8 | + |
| 9 | +If you already have a Magnitude implementation, you can easily switch to using Kernel's cloud browsers by updating your browser configuration. |
| 10 | + |
| 11 | +### 1. Install the Kernel SDK |
| 12 | + |
| 13 | +```bash |
| 14 | +npm install @onkernel/sdk |
| 15 | +``` |
| 16 | + |
| 17 | +### 2. Initialize Kernel and create a browser |
| 18 | + |
| 19 | +Import the libraries and create a cloud browser session: |
| 20 | + |
| 21 | +```typescript |
| 22 | +import { startBrowserAgent } from "magnitude-core"; |
| 23 | +import Kernel from '@onkernel/sdk'; |
| 24 | +import z from 'zod'; |
| 25 | + |
| 26 | +const client = new Kernel({ |
| 27 | + apiKey: process.env.KERNEL_API_KEY, |
| 28 | +}); |
| 29 | + |
| 30 | +const kernelBrowser = await client.browsers.create(); |
| 31 | + |
| 32 | +console.log(`Live view url: ${kernelBrowser.browser_live_view_url}`); |
| 33 | +``` |
| 34 | + |
| 35 | +### 3. Update your browser configuration |
| 36 | + |
| 37 | +Replace your existing browser setup to use Kernel's CDP URL and display settings: |
| 38 | + |
| 39 | +```typescript |
| 40 | +const agent = await startBrowserAgent({ |
| 41 | + url: 'https://magnitasks.com', |
| 42 | + narrate: true, |
| 43 | + browser: { |
| 44 | + cdp: kernelBrowser.cdp_ws_url, |
| 45 | + contextOptions: { |
| 46 | + viewport: { width: 1024, height: 768 } |
| 47 | + } |
| 48 | + }, |
| 49 | + virtualScreenDimensions: { width: 1024, height: 768 }, |
| 50 | + llm: { |
| 51 | + provider: 'anthropic', |
| 52 | + options: { |
| 53 | + model: 'claude-sonnet-4-20250514' |
| 54 | + } |
| 55 | + } |
| 56 | +}); |
| 57 | +``` |
| 58 | + |
| 59 | +### 4. Use your agent |
| 60 | + |
| 61 | +Use Magnitude's agent methods with the Kernel-powered browser: |
| 62 | + |
| 63 | +```typescript |
| 64 | +await agent.act([ |
| 65 | + 'click on "Tasks" in the sidebar', |
| 66 | + 'click on the first item in the "In Progress" column' |
| 67 | +]); |
| 68 | + |
| 69 | +const assignee = await agent.extract('Extract the task Assignee', z.string()); |
| 70 | + |
| 71 | +await agent.stop(); |
| 72 | + |
| 73 | +// Clean up the Kernel Browser Session |
| 74 | +await client.browsers.deleteByID(kernelBrowser.session_id); |
| 75 | +``` |
| 76 | + |
| 77 | +## Quick setup with our Magnitude example app |
| 78 | + |
| 79 | +Alternatively, you can use our Kernel app template that includes a pre-configured Magnitude integration: |
| 80 | + |
| 81 | +```bash |
| 82 | +npx @onkernel/create-kernel-app my-magnitude-app |
| 83 | +``` |
| 84 | + |
| 85 | +Choose `TypeScript` as the programming language and then select `Magnitude` as the template. |
| 86 | + |
| 87 | +Then follow the [Quickstart guide](/quickstart/) to deploy and run your Magnitude automation on Kernel's infrastructure. |
| 88 | + |
| 89 | +## Benefits of using Kernel with Magnitude |
| 90 | + |
| 91 | +- **No local browser management**: Run automations without installing or maintaining browsers locally |
| 92 | +- **Scalability**: Launch multiple browser sessions in parallel |
| 93 | +- **Stealth mode**: Built-in anti-detection features for web scraping |
| 94 | +- **Session persistence**: Maintain browser state across automation runs |
| 95 | +- **Live view**: Debug your automations with real-time browser viewing |
| 96 | + |
| 97 | +## Next steps |
| 98 | + |
| 99 | +- Check out [live view](/browsers/live-view) for debugging your automations |
| 100 | +- Learn about [stealth mode](/browsers/stealth) for avoiding detection |
| 101 | +- Learn how to properly [terminate browser sessions](/browsers/termination) |
| 102 | +- Learn how to [deploy](/apps/deploy) your Magnitude app to Kernel |
0 commit comments