Platform JS SDK
  • 07 Mar 2025
  • 1 Minute to read
  • Contributors
  • Dark
    Light

Platform JS SDK

  • Dark
    Light

Article summary

We provide a ready to use SDK library for the Platform API in NodeJS

Installation

npm install @unleash-tech/platform-sdk

Quickstart

The following sample code will perform a search and chat query on behalf of “myuser” using a specified assistant.

var unleash = require('@unleash-tech/platform-sdk')

var client = 
    new unleash.ApiClient({
        token:'<api-key>',
        // OPTIONAL: only needed for impersonating api keys
        account:'myuser@acme.com' 
        // OPTIONAL: only needed for private/self hosted env
        tenant: 'https://unleash.acme.com/'
	    });
	    
var assistant = client.assistants.withId('<assistant-id>');

// SEARCH 
var searchResponse = await assistant.search({
    query:'my notion page',
    filters:{appId:['notion']}
}}

console.log(`Found ${searchResponse.totalResults} results`);
for ( let r of searchResponse.result )
	console.log(searchResponse.result.resource.name);
	
// CHAT blocking-mode
var chatResponse = await assistant.chat({
		messages:[{role:'User',text:'how to use go links'}]
}).complete();

console.log(chatResponse.message);

// CHAT streaming-mode
var chatResponse = await assistant.chat({
		messages:[{role:'User',text:'how to use go links'}]
}).stream();

for await ( let event of chatResponse)
	console.log(event);


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.