import base64, json, urllib.request payload = { "model": "/model", "prompt": "A realistic photograph of a red ceramic teapot on a wooden table beside a window, soft morning light, detailed wood grain.", "negative_prompt": " ", "size": "512x512", "num_inference_steps": 50, "guidance_scale": 4.0, "seed": 42, "response_format": "b64_json", "format": "png", } request = urllib.request.Request( "http://127.0.0.1:8000/v1/images/generations", data=json.dumps(payload).encode(), headers={"Content-Type": "application/json"}) with urllib.request.urlopen(request, timeout=600) as response: result = json.load(response) with open("sample.png", "wb") as output: output.write(base64.b64decode(result["data"][0]["b64_json"])) print("Saved sample.png")