Laminar is an open-source observability and evaluation platform for autonomous AI agents. You can create a cloud account or self-host Laminar for your infrastructure. By integrating Laminar with Kernel, you can trace and monitor your browser automations with full visibility into LLM calls, browser actions, session recordings, and performance metrics.
Browser Use is an AI browser agent framework. Here’s how to integrate it with Laminar and Kernel:
python
Copy
Ask AI
import osimport asynciofrom lmnr import Laminarfrom browser_use import Agent, Browser, ChatOpenAIfrom kernel import Kernel# Initialize LaminarLaminar.initialize(project_api_key=os.environ["LMNR_PROJECT_API_KEY"])async def main(): # Initialize Kernel and create a browser client = Kernel() kernel_browser = client.browsers.create(stealth=True, viewport={'width': 1920, 'height': 1080}) print(f"Live view url: {kernel_browser.browser_live_view_url}") # Configure Browser Use with Kernel's CDP URL browser = Browser( cdp_url=kernel_browser.cdp_ws_url, headless=False, window_size={'width': 1920, 'height': 1080}, viewport={'width': 1920, 'height': 1080}, device_scale_factor=1.0 ) # Initialize the model llm = ChatOpenAI( model="gpt-4.1", ) # Create and run the agent with job extraction task agent = Agent( task="""1. Go to https://www.onkernel.com/docs 2. Navigate to the main Jobs page 3. Extract all the job posting URLs. List each URL you find.""", llm=llm, browser_session=browser ) result = await agent.run() print(f"Job URLs found:\n{result.final_result()}") # Flush traces to Laminar Laminar.flush() # Delete the browser for those who left open the live view url client.browsers.delete_by_id(kernel_browser.session_id)asyncio.run(main())
Stagehand is an AI browser automation framework. Here’s how to use it with Laminar and Kernel:
Typescript/Javascript
Copy
Ask AI
import { Laminar } from '@lmnr-ai/lmnr';import { Stagehand } from '@browserbasehq/stagehand';import Kernel from '@onkernel/sdk';import { z } from 'zod';// Initialize Laminar with Stagehand instrumentationLaminar.initialize({ projectApiKey: process.env.LMNR_PROJECT_API_KEY, instrumentModules: { stagehand: Stagehand, },});// Initialize Kernel and create a browserconst kernel = new Kernel();const kernelBrowser = await kernel.browsers.create({ stealth: true });console.log("Live view url:", kernelBrowser.browser_live_view_url);// Configure Stagehand to use Kernel's browserconst stagehand = new Stagehand({ env: 'LOCAL', verbose: 1, domSettleTimeoutMs: 30_000, modelName: 'openai/gpt-4.1', modelClientOptions: { apiKey: process.env.OPENAI_API_KEY }, localBrowserLaunchOptions: { cdpUrl: kernelBrowser.cdp_ws_url }});await stagehand.init();// Your automation codeconst page = stagehand.page;await page.goto('https://www.onkernel.com/docs');// Navigate to careers pageawait page.goto('https://www.onkernel.com/docs/careers/intro');// Extract all job URLsconst output = await page.extract({ instruction: 'Extract all job posting URLs from the Open Roles section.', schema: z.object({ jobUrls: z.array(z.string()).describe('Array of job posting URLs') })});console.log('Job URLs found:', output.jobUrls);console.log(`Total jobs: ${output.jobUrls.length}`);// Clean up and flush traces to Laminarawait stagehand.close();await Laminar.flush();// Delete the browser for those who left open the live view urlawait kernel.browsers.deleteByID(kernelBrowser.session_id);
View your traces in the Laminar UI’s traces tab to see synchronized browser session recordings and agent execution steps.After running your automation: