$ cat node-template.py

I

Image Creation

// Generates an image from a text prompt. Supports configurable aspect ratio, megapixel resolution, and reproducible seeds.

Process
Image
template.py
1import os2import sys3import json4import random5import traceback67from gais import Gais89OUTPUT_DIR = "/data/output"101112def main():13    try:14        input_json = sys.stdin.read()15        execution_input = json.loads(input_json)16        inputs = execution_input.get("inputs", {})17        service_defaults = execution_input.get("service_defaults", {})1819        prompt = inputs.get("prompt", "")20        aspect_ratio = float(inputs.get("aspect_ratio", 1.667) or 1.667)21        megapixel = float(inputs.get("megapixel", 1.0) or 1.0)2223        seed_mode = inputs.get("seed_mode", "random")24        seed_in = inputs.get("seed", -1)25        seed_input = int(seed_in) if seed_in not in (None, "") else -12627        if seed_mode == "fixed" and seed_input >= 0:28            seed_value = seed_input29        else:30            seed_value = random.randint(0, 2**31 - 1)3132        if not prompt:33            raise ValueError("Prompt is required")34        if not (0.25 <= aspect_ratio <= 4.0):35            raise ValueError(f"Aspect ratio must be between 0.25 and 4.0, got {aspect_ratio}")36        if not (0.25 <= megapixel <= 4.0):37            raise ValueError(f"Megapixel must be between 0.25 and 4.0, got {megapixel}")3839        print(40            f"Requesting generation: aspect_ratio={aspect_ratio}, megapixel={megapixel}, seed={seed_value}",41            file=sys.stderr,42        )4344        result = Gais.image.generate(45            prompt=prompt,46            aspect_ratio=aspect_ratio,47            megapixel=megapixel,48            seed_mode=seed_mode,49            seed=seed_value,50        )5152        os.makedirs(OUTPUT_DIR, exist_ok=True)53        out_path = os.path.join(OUTPUT_DIR, "generated_image.png")54        with open(out_path, "wb") as f:55            f.write(result.content)5657        seed_used = result.metadata.get("seed", "unknown")58        inference_time = result.metadata.get("inference_time_ms", "unknown")59        print(60            f"Generated: seed={seed_used}, time={inference_time}ms",61            file=sys.stderr,62        )6364        # Probe output dimensions and emit aspect_ratio + resolution so65        # downstream nodes can chain (Number / String ports respectively).66        try:67            from PIL import Image68            with Image.open(out_path) as _im:69                _w, _h = _im.size70        except Exception:71            _w, _h = 0, 07273        output = {74            "image": "generated_image.png",75            "aspect_ratio": round(_w / _h, 4) if _h else 0.0,76            "resolution": f"{_w}x{_h}",77        }78        print(json.dumps(output, indent=2))7980    except Exception as e:81        error_output = {82            "error": str(e),83            "errorType": type(e).__name__,84            "traceback": traceback.format_exc(),85        }86        print(json.dumps(error_output), file=sys.stderr)87        sys.exit(1)888990if __name__ == "__main__":91    main()

$ git log --oneline

v1.5.1
HEAD
2026-08-18
v1.5.02026-05-07
v1.3.12026-04-28
v1.1.02026-03-29
v1.0.02026-03-20