Skip to main content
Integrate deployed ComfyUI workflows into JavaScript and TypeScript applications using the FlowScale SDK.
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
If you must use client-side: Set 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:

Configuration

Core Methods

Health Check

Get Queue Status

Retrieve the current workflow queue status:

Workflow Management

List Available Workflows

Get all deployed workflows in your cluster:

Executing Workflows

Execute Workflow (Synchronous)

Trigger a workflow execution and get immediate response:

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
For new applications, use the new array format which supports multiple outputs.

Managing Workflow Runs

Get Run Details

Retrieve detailed information about a specific run:

Get Multiple Runs

Retrieve runs by group ID or get all runs:

Cancel Running Workflow

Cancel a workflow execution using its run ID:

Retrieving Outputs

Get Workflow Output

Fetch the output of a completed workflow:

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:

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