Introducing a powerful API server for asynchronous image generation using mflux. Designed for optimal GPU resource management, it handles image tasks one at a time while providing useful features like task queuing and computation time forecasting. Whether you’re building a web interface or integrating into your existing software, our server simplifies the entire image generation process.
mflux-server is a powerful API server designed for asynchronous image generation tasks using mflux, particularly suited for environments where GPU resources are shared among various tasks, such as generative AI applications. This server is engineered to ensure that only one image generation task runs simultaneously, maximizing GPU utilization while offering a multi-image generation interface through a default user interface.
Key Features:
- Asynchronous Image Generation: Efficiently handle multiple image generation tasks with a queuing mechanism.
- Compute Time Estimation: Provides users with an approximation of completion times for better experience in multi-user settings.
- Task Management: Easily manage task statuses and retrieve generated images.
- Self-Documentation: Access a Swagger endpoint to explore the API and its functionalities.
Example Workflows:
To get started, you'll interact with the API through a series of endpoints:
- Initialize Image Generation: Use the
/api/generate
endpoint to start the image creation process, which will return atask_id
for tracking. - Check Status: Monitor the task's progress with
/api/status
to see if the image generation is completed and get estimated wait times for the frontend display. - Retrieve Image: Once the generation is complete, fetch the image using
/api/image
and receive the JPEG binary.
Example Requests:
Here's how you can initialize an image generation task:
curl -X 'POST' \
'http://localhost:4030/api/generate' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"prompt": "A beautiful landscape",
"seed": "1725311496",
"height": 1024,
"width": 1024,
"steps": 4,
"format": "JPEG",
"quality": 85,
"priority": false
}'
The response will include a task_id
, which you can use to check the status:
curl -X 'GET' \
'http://localhost:4030/api/status?task_id=1fc9cc4f' \
-H 'accept: application/json'
And to retrieve the generated image:
curl -X 'GET' \
'http://localhost:4030/api/image?task_id=1fc9cc4f' \
-H 'accept: application/json'
Python Client Example:
For easy integration, here's a sample Python client implementation:
def mflux_generate_client(mfluxendpoint, prompt, width=1280, height=720, steps=4, seed=None, format="JPEG", quality=85, priority=False):
# Function implementation here
def mflux_status_ready(mfluxendpoint, task_id):
# Function implementation here
def mflux_get_image(mfluxendpoint, task_id):
# Function implementation here
This structure allows for straightforward communication with the mflux-server, providing a seamless experience in generating and retrieving images.