🎨 FLUX Image Generator API Documentation

Access the power of FLUX.1-schnell model through our RESTful API

Introduction

The FLUX Image Generator API allows you to generate images using the FLUX.1-schnell model programmatically. The API supports both base64 and raw image responses, making it suitable for various use cases.

Authentication

You can optionally provide your Hugging Face token in the request body. If not provided, the default token will be used.

Note: For reliable service, we recommend using your own Hugging Face token. You can get one from huggingface.co

Endpoints

GET /health

Check if the API is operational.

Example Request:

curl https://flux-image-generator-bdcdcphnhmbhg6et.centralindia-01.azurewebsites.net/health

Example Response:

{
    "status": "healthy",
    "version": "1.0.0"
}

POST /generate-image

Generate an image based on a text prompt.

Request Parameters:

Parameter Type Required Description
prompt string Yes The text description of the image you want to generate
width integer No Image width in pixels (default: 1024, max: 2048)
height integer No Image height in pixels (default: 768, max: 2048)
return_format string No "base64" (default) or "raw"
hf_token string No Your Hugging Face token

Example Request (base64 response):

curl -X POST "https://flux-image-generator-bdcdcphnhmbhg6et.centralindia-01.azurewebsites.net/generate-image" \
    -H "Content-Type: application/json" \
    -d '{
        "prompt": "a beautiful sunset",
        "width": 1024,
        "height": 768,
        "return_format": "base64",
        "hf_token": "your_token_here"
    }'

Example Request (raw image response):

curl -X POST "https://flux-image-generator-bdcdcphnhmbhg6et.centralindia-01.azurewebsites.net/generate-image" \
    -H "Content-Type: application/json" \
    -d '{
        "prompt": "a beautiful sunset",
        "width": 1024,
        "height": 768,
        "return_format": "raw"
    }' \
    --output image.png

Response Formats:

  • base64: Returns JSON with base64-encoded image data
  • raw: Returns the raw PNG image data

Error Handling

The API uses standard HTTP status codes:

Status Code Description
200 Success
400 Bad Request - Invalid parameters
500 Internal Server Error

Rate Limiting

The API is subject to Hugging Face's rate limits. Using your own token is recommended for consistent access to the service.