What you’re building: Instead of asking users to understand ComfyUI or API endpoints, you’re creating seamless experiences where AI capabilities feel like native Python functions. Your workflows become the invisible intelligence powering data processing, web applications, and automated systems.
🚀 What’s New in v1.1.4
- 🔄 Updated Response Format: Both
execute_workflowandexecute_workflow_asyncnow returnworkflow_idalongsiderun_id - ✨ Enhanced Polling: Improved
execute_workflow_asyncwith better run status detection and failure handling - 📚 Comprehensive Documentation: Advanced usage examples for FastAPI, Django, Flask, and Jupyter integration
- 🖼️ Dynamic Parameters: Full support for dynamic parameter names matching your ComfyUI workflow structure
- 📤 Multiple File Support: Handle multiple images, videos, and files in single workflow execution
- 📊 Pagination & Filtering: Enhanced
get_runs()with sorting, filtering, and pagination capabilities
Installation: Adding AI Power to Your Python Projects
Ready to bring your AI workflows into your Python applications? Install the FlowScale SDK to start integrating your deployed ComfyUI workflows into any Python project.Quick Start: From Deployment to Integration
Prerequisites: You should have already deployed your ComfyUI workflow as an API through the FlowScale AI platform. If you haven’t, complete the Deploy Workflows guide first.
Connecting Your Python Application to Your AI Infrastructure
This is where your deployed AI workflows become Python application features. Import the SDK and connect to the production APIs you’ve already created:Environment Variables
Add the following to your.env file:
Integration Patterns for Production Applications
Choose the integration pattern that matches your application’s needs:- Web Services (FastAPI/Django/Flask)
- Data Processing & ML Pipelines
- Automation & Scripting
Best for: API endpoints, web applications, microservicesBenefits:
- Production-ready web framework integration
- Built-in authentication and validation
- Scalable request handling
- Easy deployment and monitoring
Configuration
Client Options
Logging Configuration
The SDK includes configurable logging to help with debugging and monitoring:Log Levels
Log Levels
- debug: Most verbose, includes detailed operation information
- info: General information about operations (default)
- warn: Warning messages for potential issues
- error: Only error messages
Core Methods
Platform Health and Status
Check Health Status
Monitor the health of the FlowScale platform, including container status:Response Example
Response Example
Get Queue Status
Retrieve the current workflow queue status:Response Example
Response Example
Workflow Execution
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 poll for its output until completion:Response Example
Response Example
If the workflow doesn’t complete within the timeout period, a
FlowScaleTimeoutError exception will be raised.Dynamic Parameter Support
The SDK supports dynamic parameter names that match your workflow’s requirements:Managing Workflow Runs
Get Run Details
Retrieve detailed information about a specific workflow run:Response Example
Response Example
Get Multiple Runs with Pagination ✨
Retrieve workflow runs with advanced pagination, sorting, and filtering capabilities:group_id(string, optional): Filter runs by group identifiersort_by(string, optional): Field to sort by -"created_at","started_at", or"completed_at"(default:"created_at")sort_order(string, optional): Sort order -"asc"or"desc"(default:"desc")page(int, optional): Page number starting from 1 (default:1)page_size(int, optional): Number of items per page, 1-100 (default:10)
Enhanced Response with Metadata
Enhanced Response with Metadata
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 using its filename:Response Example
Response Example
Advanced Usage Examples
Batch Processing with Groups
Error Handling and Retries
Pagination Helper
Framework Integration
FastAPI Integration
The SDK works seamlessly with FastAPI for building API endpoints:Django Integration
Flask Integration
Jupyter Notebook Integration
File Handling
Working with Different File Types
Downloading and Saving Results
Error Handling
Exception Types
Comprehensive Error Handling Pattern
Best Practices
Environment Configuration
Always store sensitive information such as API keys in environment variables:Performance Optimization
Input Validation
Logging and Monitoring
Testing and Debugging
Unit Testing
Debug Mode Usage
Examples & Recipes
Text to Image Generation
Complete Python examples for text-to-image generation workflows
Image Processing Pipeline
Transform and enhance images using AI-powered workflows
Batch Processing
Process multiple files efficiently with concurrent execution
FastAPI Integration
Build API endpoints with FastAPI and FlowScale workflows
Jupyter Notebooks
Interactive workflow execution in Jupyter environments
Error Handling & Retry Logic
Robust error handling and automatic retry mechanisms
Support
Need help with the Python SDK?API Reference
Complete API documentation and endpoint reference
PyPI Package
Official PyPI 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