To generate an image, follow these steps:
- Obtain a Session ID: Call the
/API/GetNewSession endpoint via POST. - Generate Image: Call the
/API/GenerateText2Image endpoint via POST, providing the session_id, prompt, model, and other parameters in the JSON body. - Retrieve Image: The API returns a JSON object containing a list of image paths. Use the
/View/* route to download or view the generated image.
Example Workflow (Bash):
# 1. Get session ID
curl -H "Content-Type: application/json" -d "{}" -X POST http://localhost:7801/API/GetNewSession
# 2. Generate image (using session_id from step 1)
curl -H "Content-Type: application/json" -d '{"session_id":"YOUR_SESSION_ID","images":1,"prompt":"a cat","model":"OfficialStableDiffusion/sd_xl_base_1.0","width":1024,"height":1024}' -X POST http://localhost:7801/API/GenerateText2Image
# 3. Download the image (using the path returned in step 2)
wget "http://localhost:7801/View/local/raw/path/to/image.png"
# First, get a usable session ID:
curl -H "Content-Type: application/json" -d "{}" -X POST http://localhost:7801/API/GetNewSession
# Now, generate the image
curl -H "Content-Type: application/json" -d '{"session_id":"9D3534E30DA38499DE782BC38211976A58555AA6","images":1,"prompt":"a cat","model":"OfficialStableDiffusion/sd_xl_base_1.0","width":1024,"height":1024}' -X POST http://localhost:7801/API/GenerateText2Image
# Now download the image to look at it
wget "http://localhost:7801/View/local/raw/2024-05-19/a cat-OfficialStableDiffusionsd_xl_base_10s-1872258705.png"