Skip to main content
Our Agent Platform Javascript SDK (AgP JS SDK) gives you the tools to build AI-powered agents in minutes. Designed with ease, speed, and simplicity in mind, it provides you with prebuilt functions and libraries, examples, API wrappers, and more, to help you get started as fast as possible so you can focus on what really matters: building great AI-powered agents. Here’s a glimpse at what’s included in the SDK:
  • Quickstart and installation: Get started in minutes with a few quick and simple steps.
  • Basic usage: Learn how to configure your agent and engineer prompts and task execution.
  • Advanced features: Discover advanced capabilities like trajectory management.
  • Real-time updates: Monitor events and control real-time execution manually.
  • Error handling: Learn how to handle and recover from common errors.
  • Examples: Explore ready-to-use code snippets for a number of workflows.
  • API Reference: Find detailed documentation for all available methods and options.

Setup requirements

Currently, you can set up the AgP JS SDK using the following methods:
MethodDescriptionAuthentication requirements
Browser (Recommended)Launch the SDK in your browser with a script tag.JWT Token or API Key
Package managerInstall the SDK in your Node.js or frontend project using npm or Yarn, then import it into your code.API Key

Using the AgP JS SDK

Every task or workflow using the AgP JS SDK must be run asynchronously in your browser or Node.js by wrapping the commands inside an async function. Within the async function, the following steps and their corresponding functions must be included.
1

Authenticate and initialize

const agent = await AGP.WebAgent.init({
  authCallback: (login) => {
    const loginBtn = document.getElementById('login-btn');
    loginBtn.style.display = 'block';
    loginBtn.onclick = login; // Opens Portal-H login popup
  }
});
2

Define the task

  const task = await agent.run('Search for best noise-cancelling headphones', {
    startUrl: 'https://google.com'
});
3

Attach a listener

task.onUpdate((event) => {
  console.log(event.type, event.data);
});
4

Wait for completion

await task.waitForCompletion();
I