Skip to content

Latest commit

 

History

History
73 lines (50 loc) · 1.51 KB

README.md

File metadata and controls

73 lines (50 loc) · 1.51 KB

ShenMind AI Node.js Client

Introduction

This project is a Node.js client for the ShenMind AI API, aiming to provide users with a convenient way to access the ShenMind API, explore and utilize AI models, and develop their own applications.

Installation

You can install the package directly via npm:

npm install shenmind

Usage Examples

1. Set Personal API Token

You can retrieve your personal API token from the User Dashboard and configure it as follows:

 export SHENMIND_API_TOKEN=xxxxxxxxxxxxxxxxxxxx

2. Create Prediction

const shenmind = require('shenmind');

async function main() {
  const modelId = 'yP1jM07UrYuQ6xHZ-lqYSQ==';
  const files = {
    'image_path': 'test.png'
  };
  const params = {
    'prompt': 'the product is for sale'
  };

  const prediction = await shenmind.run(modelId, files, params, waitResult = true);
  console.log(prediction);
}

main();

3. Query Prediction Output

const shenmind = require('shenmind');

async function main() {
  const predictionId = 'HkzotuoaEy3rcsCLK8WRyQ==';
  const predictionOutput = await shenmind.getPredictionOutput(predictionId);
  console.log(predictionOutput);
}

main();

4. Cancel Prediction

const shenmind = require('shenmind');

async function main() {
  const predictionId = 'HkzotuoaEy3rcsCLK8WRyQ==';
  const predictionOutput = await shenmind.cancelPrediction(predictionId);
  console.log(predictionOutput);
}

main();