Integrate MindStudio's AI Agents into your Node.js projects.
Last updated
The is your toolkit for integrating AI-powered workflows seamlessly into any application. This client library offers type-safe interfaces to help you execute MindStudio AI Agents with ease and confidence.
Quick Start
1. Install the Package
npm install mindstudio
2. Get Your API Key
Go to
Create a new API key
3. Choose Your Usage Pattern
Option A: Type-Safe Usage (Recommended)
**// Initialize the client
const client = new MindStudio(process.env.MINDSTUDIO_KEY);
// Execute a workflow
const { success, result } = await client.workers.myWorker.generateText({
prompt: "Write a story about a space cat"
});
// Handle the response
if (success) {
console.log(result);
}**
Option B: Direct Usage
**import { MindStudio } from 'mindstudio';
const client = new MindStudio(process.env.MINDSTUDIO_KEY);
const { success, result } = await client.run({
workerId: "your-worker-id",
workflow: "generateText",
variables: {
prompt: "Write a story about a space cat"
}
});**
Response Format
All workflow executions return a consistent response type:
interface WorkflowResponse<T> {
success: boolean;
result?: T; // The workflow result when success is true
error?: Error; // Error details when success is false
billingCost?: string // Execution cost in credits
}
CLI Commands
sync
Generate type definitions for type-safe usage:
# With API key in environment
npx mindstudio sync
# With explicit API key
npx mindstudio sync --key your-api-key
# From existing config (CI environments)
npx mindstudio sync --offline
test
Test a workflow from the command line:
npx mindstudio test --worker myWorker --workflow generateText --input '{"prompt":"Hello"}'
list
List available Agents and workflows:
# List from existing configuration
npx mindstudio list
# List from API (if no configuration exists)
npx mindstudio list --key your-api-key