Welcome! In this guide, we will walk you through the exciting journey of transforming ComfyUI into a serverless API using RunPod. Whether you’re an AI enthusiast or a developer, this step-by-step tutorial will make it as comfy as a plush chair for you to implement image generation functionalities!
Quickstart
To kick things off, choose one of the available Docker images for your serverless endpoint. Here’s a list of the options you have:
- timpietruskybliblarunpod-worker-comfy:3.1.0-base: A clean ComfyUI without any frills.
- timpietruskybliblarunpod-worker-comfy:3.1.0-flux1-schnell: Contains the necessary components for FLUX.1 schnell.
- timpietruskybliblarunpod-worker-comfy:3.1.0-flux1-dev: Contains components for FLUX.1 dev.
- timpietruskybliblarunpod-worker-comfy:3.1.0-sdxl: Prepped for Stable Diffusion XL.
- timpietruskybliblarunpod-worker-comfy:3.1.0-sd3: Configured for Stable Diffusion 3 medium.
Once you have selected an image, you’re ready to take the next steps!
Features
This setup leverages the power of ComfyUI, allowing for:
- Seamless image generation using any ComfyUI workflow.
- Input images as base64-encoded strings.
- Output customization to return results as base64 strings or upload directly to AWS S3.
Getting Started
Let’s dive into the key steps, explaining along the way how to streamline your experiences with this serverless API!
1. Upload Image to AWS S3
If you want to upload images to AWS S3, you need to set up an S3 bucket and configure some IAM permissions. Follow these steps:
- Create a bucket in your preferred region.
- Set up an IAM user with access to that bucket and generate access keys.
- Define environment variables on your RunPod worker using:
BUCKET_ENDPOINT_URL=
BUCKET_ACCESS_KEY_ID=
BUCKET_SECRET_ACCESS_KEY=
2. Create Your Template
Go to RunPod and create a new template for your worker configuration:
- Name your template (e.g., runpod-worker-comfy).
- Select “serverless” as the template type.
- Use your chosen Docker image.
3. Create Your Endpoint
To create your endpoint in RunPod, follow these steps:
- Go to the Serverless Endpoints section and click on New Endpoint.
- Configure based on your specific needs, from active workers to GPU selection.
API Specification
Here, you’ll interact with the API using a JSON Request Body that looks something like this:
{
"input": {
"workflow": "your-comfy-workflow",
"images": [
{
"name": "example_image_name.png",
"image": "base64_encoded_string"
}
]
}
}
4. Example Request for SDXL with cURL
You can generate an image with a sample cURL command like this:
curl -X POST -H "Authorization: Bearer api_key" -H "Content-Type: application/json" -d '{
"input": {
"workflow": {
"your_workflow_configuration"
},
"images": [
{
"name": "example_image_name.png",
"image": "base64_encoded_string"
}
]
}
}' https://api.runpod.ai/v2/endpoint_id/runsync
Troubleshooting
If you encounter issues during setup, consider the following troubleshooting tips:
- Check your API keys and access permissions in AWS S3.
- Ensure that your endpoint has been configured correctly and is active.
- Verify the accuracy and encoding of your base64 strings for images.
If problems persist, don’t hesitate to reach out for assistance or to connect with the community. For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
Conclusion
Congratulations! You’ve successfully set up ComfyUI as a serverless API using RunPod. With this powerful setup, you’re now equipped to generate images using sophisticated workflows. At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.