browseraiOpen the playground

SDK reference

One ES module, browserai.mjs, with the signing, the payments, the actions and the cookie vault built in.

curl -O https://www.usebrowserai.xyz/sdk/browserai.mjs

BrowserAI

const bai = new BrowserAI({
  privateKey: '0x…',     // or account: any viem account (local key or smart account)
  gateway: 'https://browserai-gw.fly.dev', // optional
})
await bai.stats()            // counters, prices, whether x402 is open
await bai.balance()          // signed: deposited, spent, available, secondsLeft
await bai.deposit('1.5')     // USDG transfer to the treasury, then credit
await bai.claimDeposit(hash)
const s = await bai.open({ pay: 'balance' | 'x402', timeout, idleTimeout, liveView, replay, viewport })

Session

s.connectUrl                 // wss URL for Playwright, Puppeteer or raw CDP
await s.goto(url)
await s.click('#submit')     // a selector, or visible text: s.click('Sign in')
await s.type('#email', 'agent@example.com', { submit: false })
await s.press('Enter')
await s.extract()                                   // { text }
await s.extract({ format: 'list', selector: 'h3' }) // { items }
await s.extract({ format: 'links' })                // { links }
const { buffer } = await s.screenshot({ fullPage: true })
await s.action({ actions: [ … ] })                  // up to 20 actions in order
await s.info()
await s.close()

Every action returns { ok, url, title, … }. Actions on a session run one after another.

Cookie vault

await s.saveCookies('supplier-portal')     // encrypt locally, store ciphertext
const s2 = await bai.open()
await s2.restoreCookies('supplier-portal') // download, decrypt locally, load
await bai.vault.list()
await bai.vault.delete('supplier-portal')