comfyui-aimlapi-custom-nodes
Production-ready ComfyUI nodes for AI/ML API video and image endpoints, supporting text-to-image, image-to-image, and video generation.
AI/ML API Custom Nodes for ComfyUI
Overview
This repository provides production-ready ComfyUI nodes for the AI/ML API video and image endpoints. Each node class lives in its own module so contributors can reason about one workflow at a time while sharing common helpers in aimlapi_shared.py.
Features
- Text-to-image and image-to-image support for Google Nano Banana Pro and ByteDance Seedream 4.5
- Video generation for LTXV-2 and Google Veo 3.1 image-to-video
- Video plus audio alignment via Veed Fabric 1.0
- First/last frame interpolation for Kling Video O1, Google Veo fast first/last, and Runway Gen-4 Turbo
- Shared submission and polling utilities with consistent error reporting
Repository Layout
aimlapi_image_generator.py– Text-to-image nodeaimlapi_image_editor.py– Image-to-image nodeaimlapi_video_generator.py– Single-image video node covering LTXV-2 and Veo 3.1aimlapi_video_with_audio.py– Fabric 1.0 node that binds to an audio trackaimlapi_video_first_last.py– Keyframe-based video node for Kling, Veo, and Runwayaimlapi_shared.py– Aspect-ratio helpers, tensor serialization, API submission, and pollingaimlapi_node_registry.py– Central node registration consumed by__init__.py
Installation
- macOS/Linux: run
./install_macos.sh [path-to-ComfyUI]. The script defaults to~/ComfyUI, copies every module, and installs dependencies withuv(falling back to pip). - Windows: run
install_windows.bat [path-to-ComfyUI]from a Developer Command Prompt or PowerShell. It mirrors the same steps using%USERPROFILE%\ComfyUIas the default target. - Manual: copy all
.pyfiles into a folder insideComfyUI/custom_nodesand runuv pip install requests pillow numpy torchinside the ComfyUI virtual environment.
Obtaining an API Key
Create or log into your AI/ML API account and generate a key at https://aimlapi.com/app/keys. The nodes expose an api_key input with the ComfyUI password widget so the value stays masked on screen. You can also feed the key through hidden inputs or environment variables if you need fully headless execution.
Available Nodes
| Node | Description | Key Model Options |
| --- | --- | --- |
| AI/ML API Image Generator | Text prompt to image output | google/nano-banana-pro, bytedance/seedream-4-5 |
| AI/ML API Image Editor | Image editing with prompt guidance | google/nano-banana-pro-edit, bytedance/seedream-4-5 |
| AI/ML API Video Generator | Prompt plus optional reference frame to video | ltxv/ltxv-2, google/veo-3-1-image-to-video |
| AI/ML API Video + Audio | Reference frame plus audio track to lip-synced video | veed/fabric-1.0 |
| AI/ML API Video Keyframes | First/last frame interpolation or single-frame-to-motion | kling-ai/video-o1-image-to-video, google/veo-3-1-first-last-image-to-video-fast, runway/gen4_turbo |
Each node returns a video URL plus the generation ID so you can chain downloads or log metadata downstream.
Usage Notes
- All video jobs flow through
https://api.aimlapi.com/v2/video/generations; payloads differ only by model-specific fields such asfps,tail_image_url, oraudio_url. - The helper functions throttle polling (default five seconds) and throw detailed errors when the API reports failure states such as
canceledorexpired. - For tensor inputs, the helpers convert the first image in the batch to PNG data URIs. Provide direct HTTPS URLs if you want to bypass tensor encoding.
- Logging uses the prefix
[AI/ML API]so you can filter ComfyUI output easily.
Development
- Create a virtual environment or reuse ComfyUI’s
uvenvironment. - Run
PYTHONPYCACHEPREFIX=/tmp python -m py_compile *.pybefore sending pull requests to catch syntax issues without cluttering the repo with__pycache__. - Keep API-specific logic inside the dedicated node module and extend the shared helper file only when multiple nodes will use the new functionality.
- Update
README.mdandAGENTS.mdwhenever you add or rename nodes so downstream users have accurate docs.
Troubleshooting
- If a node fails with
API request failed, review the exact status code and message surfaced in the exception. - Confirm your key has quota and that the selected model supports the provided parameters (for example, Veo fast first/last only allows 720p or 1080p output).
License
Released under the MIT License. See __init__.py for version and author metadata.