VYSP.AI Product Documentation
VYSP.AI Homepage
  • Welcome to our Documentation!
  • VYSP.AI Security Platform and API Usage Documentation
  • Basic Concepts of VYSP.AI Security API
  • Get started
    • Rules
    • Flows
    • Gates
    • Knowledge Databases
  • Using the platform
  • SSO Authentication
  • Python Client
    • Python Client Library for VYSP API
    • Quick Setup with Python Client Library
    • Demo Project (Flask/Python)
    • Documentation for Python Client Library Functions and Classes
  • TypeScript/JS Client
    • TS/JS Client Library for VYSP.AI API
    • Quick Setup with TS/JS Client Library
    • Demo Project (Next.JS)
    • Documentation for TypeScript Client Library Functions and Classes
  • JavaScript Client
    • JavaScript Client Library for VYSP API
    • Quick Setup with JavaScript Client Library
    • Demo Project (Next.JS)
    • Documentation for JavaScript Client Library Functions and Classes
Powered by GitBook
On this page
  • Installation
  • Basic Usage
  1. TypeScript/JS Client

Quick Setup with TS/JS Client Library

Setting up the Client Library for VYSP API is easy. Follow these steps to integrate it into your project.

Installation

Use npm to install the library:

npm install --save-dev vysp@latest

Basic Usage

Here is a simple example to get you started:

import VYSPClient, { VYSPClientConfig } from 'vysp';

const vyspClientConfig: VYSPClientConfig = {
  tenantApiKey: process.env.VYSP_TENANT_API_KEY!,
  gateApiKey: process.env.VYSP_GATE_API_KEY!,
  installationType: "cloud",
}

const client = VYSPClient.clientFromConfig(vyspClientConfig)

const prompt = 'sample input'; // gather input from user
const modelOutput = 'sample model output'; // send a request to model

async function performCheckInput() {
    try {
        const response = await client.checkInput('user1', prompt);
        console.log(response);
    } catch (error) {
        console.error('Error:', error.message);
    }
}

async function performCheckOutput() {
    try {
        const response = await client.checkOutput('user1', prompt, modelOutput);
        console.log(response);
    } catch (error) {
        console.error('Error:', error.message);
    }
}

performCheckInput();
performCheckOutput();
PreviousTS/JS Client Library for VYSP.AI APINextDemo Project (Next.JS)

Last updated 1 year ago