Create a Modal.com FastAPI endpoint for high-quality image g...
Prompt
Create a Modal.com FastAPI endpoint for high-quality image generation using FLUX.2 [dev]. Pull it from the unsloth/FLUX.2-dev repository because that one is ungated and doesn't require an access key. The space should take a prompt and parameters, and return the image. It should also return a GIF (or MP4 if the user chooses that). If the user chooses an MP4, encode it with AV1 for size efficiency. Use a seperate non-web function for GIF/video rendering since high-performance NVIDIA AI GPUs (other than the L40S, which isn't fast enough for the image generation). Use the L40S for the video/GIF rendering, and use PyTorch tensor batching for fast rendering. For the image generation, the user can ask for a JPG or PNG. When creating the Modal image, use Ubuntu because of the recent archival of Debian dependency repositories. Return the full Modal script and the API spec.