NPM Package
Integrate MindStudio's AI Agents into your Node.js projects.
The MindStudio NPM Package 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 mindstudio2. Get Your API Key
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
Response Format
All workflow executions return a consistent response type:
CLI Commands
sync
syncGenerate type definitions for type-safe usage:
test
testTest a workflow from the command line:
list
listList available Agents and workflows:
Team Usage
1. Project Owner:
2. Team Members:
Optional: Add to package.json for automatic type generation:
package.json for automatic type generation:Installation & Setup
Environment Variables
MindStudio requires an API key for authentication. You can provide it in several ways:
Option 1: In your shell
Option 2: In your .env file
Option 3: Pass directly to your CLI commands
For security best practices:
Never commit API keys to version control
Add
.envto your.gitignoreUse environment variables in CI/CD environments
TypeScript Configuration
Error Handling
Common Issues
"Type-safe workers not available"
Run npx mindstudio sync to generate type definitions
"API key is required"
Ensure MINDSTUDIO_KEY is set in your environment or passed to the constructor
"Failed to load configuration"
Run npx mindstudio sync to create initial configuration
Best Practices
1. API Key Security
Store API keys in environment variables
Use
.envfiles only for local developmentNever commit API keys to version control
Use secure environment variables in CI/CD
2. Type Safety
Use the type-safe pattern when possible
Commit
.mindstudio.jsonto version controlRun
syncafter pulling changes
3. Error Handling
Always check
successbefore usingresultImplement proper error handling
Use TypeScript for better type safety
License
MIT
Last updated