Skip to main content

Installation

Install the BCTRL SDK:
npm install @bctrl/sdk

Get your API Key

1

Create an account

Sign up at app.bctrl.ai
2

Generate API key

Go to SettingsAPI KeysCreate new key
3

Set environment variable

export BCTRL_API_KEY=your_api_key_here

Your First Script

Create a file called demo.ts:
import { playwright } from '@bctrl/sdk';

async function main() {
  // Create a remote browser session
  const session = await playwright.connect({
    apiKey: process.env.BCTRL_API_KEY
  });

  // Get the default page
  const page = session.page;

  // Navigate and interact
  await page.goto('https://news.ycombinator.com');

  // Get page title
  const title = await page.title();
  console.log('Page title:', title);

  // Take a screenshot
  await page.screenshot({ path: 'screenshot.png' });

  // Clean up
  await session.close();
}

main();
Run it:
npx tsx demo.ts
You should see “Page title: Hacker News” and a screenshot.png file in your directory.

Using AI Agents

Add AI-powered automation with a single line:
import { playwright } from '@bctrl/sdk';

const session = await playwright.connect({
  apiKey: process.env.BCTRL_API_KEY
});

await session.page.goto('https://example.com');

// Use natural language to interact
await session.stagehand.act('Click the login button');
await session.stagehand.act('Fill in the email field with [email protected]');

// Extract structured data
const data = await session.stagehand.extract(
  'Get all article titles and their links',
  z.array(z.object({
    title: z.string(),
    url: z.string()
  }))
);

console.log(data);

await session.close();

Next Steps