New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@browserbasehq/sdk

Package Overview
Dependencies
Maintainers
0
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@browserbasehq/sdk

Browserbase JS SDK

  • 1.4.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
104K
increased by2.73%
Maintainers
0
Weekly downloads
 
Created
Source

Browserbase logo

Documentation  ·  Playground


Browserbase JS SDK

Browserbase is the best developer platform to reliably run, manage, and monitor headless browsers.

Get browsers' full control and leverage Browserbase's Infrastructure, Stealth Mode, and Session Debugger to power your automation, test suites, and LLM data retrievals.

Installation and setup

1. Install the SDK:

npm install -S @browserbasehq/sdk

2. Get your Browserbase API Key and Project ID:

Usage

import { Browserbase } from '@browserbasehq/sdk'

// Init the SDK
const browserbase = new Browserbase()

// Load a webpage
const rawHtml = await browserbase.load('https://www.browserbase.com')

// Load multiple webpages (returns iterator)
const rawHtmls = browserbase.loadURLs([
  'https://www.browserbase.com',
  'https://docs.browserbase.com',
])

for await (let rawHtml of rawHtmls) {
  // ...
}

// Text-only mode
const text = await browserbase.load('https://www.browserbase.com', {
  textContent: true,
})

// Screenshot (returns bytes)
const result = await browserbase.screenshot('https://www.browserbase.com', {
  textContent: true,
})

Vercel AI SDK Integration

Install the additional dependencies:

npm i ai openai zod
import OpenAI from 'openai'
import { Browserbase, BrowserbaseAISDK } from '@browserbasehq/sdk'
import {
  OpenAIStream,
  StreamingTextResponse,
  generateText,
} from 'ai'

// Create new OpenAI client
const openai = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
})

// Init the Browserbase SDK
const browserbase = new Browserbase()

// Init the tool
const browserTool = BrowserbaseAISDK(browserbase, { textContent: true })

// Load completions
const result = await generateText({
  model: openai.chat('gpt-3.5-turbo'),
  tools: {
    browserTool,
  },
  prompt: 'What is the weather in San Francisco?',
})

Further reading

Keywords

FAQs

Package last updated on 20 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc