Skip to content

Usage

Minimal TypeScript Example (SDK)

Create a stealth cloud browser session and log the session ID:

typescript
import Kernel from '@onkernel/sdk';

const client = new Kernel({
  apiKey: process.env['KERNEL_API_KEY'],
});

const browser = await client.browsers.create({ stealth: true });
console.log(browser.session_id);
// example output: "sess_01j9xkqp7m..."

The session_id can be handed to Playwright or CDP to control the running browser.

Connect via Playwright

typescript
import Kernel from '@onkernel/sdk';
import { chromium } from 'playwright';

const client = new Kernel({ apiKey: process.env['KERNEL_API_KEY'] });
const browser = await client.browsers.create({ stealth: true });

const pw = await chromium.connectOverCDP(browser.ws_url);
const page = await pw.newPage();
await page.goto('https://example.com');
const title = await page.title();
console.log(title); // "Example Domain"

await pw.close();

Deploy an Agent via CLI

Scaffold, deploy, and invoke a computer-use agent:

bash
# scaffold from template
kernel create --template computer-use

# deploy the agent file
kernel deploy agent.ts

# invoke a named action with a payload
kernel invoke my-agent my-task --payload '{"url": "https://example.com"}'

Stream logs from a running deployment:

bash
kernel logs my-agent

Key Environment Variable

VariablePurpose
KERNEL_API_KEYAuthenticates all SDK and REST API requests