Production Security Best PracticesYour AI workflows are now business infrastructure—protect them accordingly. When integrating into client-side applications, your API keys become visible to users, which could lead to unauthorized usage and unexpected costs.Recommended Architecture:
- Backend Integration: Use this SDK in Node.js servers where API keys remain secure
- Proxy Pattern: Create your own API endpoints that internally call FlowScale AI
- Rate Limiting: Control usage to prevent abuse and manage costs
allowDangerouslyExposeApiKey: true to acknowledge the security implications.Installation
Quick Start
Connect to your deployed workflows:Environment Variables
Add the following to your.env file:
Architecture Patterns for Production Applications
Choose the integration pattern that matches your application’s needs:- Backend API Integration (Recommended)
- Direct Browser Integration
Best for: Web applications, mobile app backends, automation systemsBenefits:
- Secure API key management
- Rate limiting and cost control
- User authentication and authorization
- Request logging and monitoring
Configuration
Core Methods
Health Check
Response Example
Response Example
Get Queue Status
Retrieve the current workflow queue status:Response Example
Response Example
Workflow Management
List Available Workflows
Get all deployed workflows in your cluster:Response Example
Response Example
Executing Workflows
Execute Workflow (Synchronous)
Trigger a workflow execution and get immediate response:Response Example
Response Example
Execute Workflow (Asynchronous with Auto-Polling)
Execute a workflow and automatically wait for the result:Migration Notice - executeWorkflowAsync Response FormatStarting from v1.0.18,
executeWorkflowAsync automatically detects single vs multiple outputs and returns the appropriate format for backward compatibility:- Single Output: Returns legacy format with deprecation warning
- Multiple Outputs: Returns new array format
Response Example
Response Example
Managing Workflow Runs
Get Run Details
Retrieve detailed information about a specific run:Response Example
Response Example
Get Multiple Runs
Retrieve runs by group ID or get all runs:Response Example
Response Example
Cancel Running Workflow
Cancel a workflow execution using its run ID:Response Example
Response Example
Retrieving Outputs
Get Workflow Output
Fetch the output of a completed workflow:Response Example
Response Example
TypeScript Support
Type Definitions
The SDK includes comprehensive TypeScript definitions:Workflow-Specific Types
Generate types for your specific workflows:File Handling
Uploading Files
Handle image and file uploads seamlessly across different environments:- Browser File Upload
- URL Input
- Base64 Input
Downloading Results
Error Handling
Comprehensive Error Handling
Retry Logic
React Integration
Custom Hook
Create a React hook for easy workflow execution:Component Example
WebSocket Support
The SDK provides WebSocket functionality for real-time communication:Connecting to WebSocket
Sending Messages
Security Features
Proxy Mode Configuration
For secure frontend usage, use proxy mode to keep your API key safe:Dynamic Header Management
Best Practices
Environment Configuration
Always store sensitive information such as API keys in environment variables:Performance Optimization
Security
Testing and Debugging
- Test workflows in a development environment before deploying to production
- Validate inputs to ensure they match the workflow requirements
- Wrap API calls in try-catch blocks to handle errors gracefully
- Use the SDK’s logging functionality for debugging:
Batch Processing
Process multiple inputs efficiently:Examples & Recipes
Text to Image Generation
Complete React app for text-to-image generation using workflows
Image to Image Processing
Transform existing images with AI-powered workflows
Batch Processing
Process multiple images efficiently with concurrent execution
Real-time WebSocket Updates
Get real-time updates on workflow execution status
File Upload Integration
Handle file uploads in browser and Node.js environments
Error Handling & Retry Logic
Robust error handling and automatic retry mechanisms
Support
Need help with the JavaScript SDK?API Reference
Complete API documentation and endpoint reference
NPM Package
Official NPM package with installation instructions
Discord Community
Chat with other developers and get community support
Support Team
Direct support for technical issues and questions
Documentation
Complete guides and tutorials for getting started