Class ImageGenerator
java.lang.Object
com.codename1.ai.ImageGenerator
Cloud-first image generation. The openai and replicate factory
methods cover the two dominant managed endpoints. On-device
generation via Core ML / ONNX Stable Diffusion is provided
separately by the optional cn1-ai-stablediffusion cn1lib; see
onDevice().
ImageGenerator.openai(KeyStore.get("openai_key"))
.generate(new GenerateImageRequest("A cat in a sombrero").setSize("1024x1024"))
.ready(img -> imageComponent.setIcon(img));
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract AsyncResource<Image> static ImageGeneratoronDevice()On-device generator.static ImageGeneratorstatic ImageGeneratorReplicate runs a wide catalog of third-party image models (SDXL, Flux, etc.) behind a uniform REST API.
-
Constructor Details
-
ImageGenerator
public ImageGenerator()
-
-
Method Details
-
openai
-
replicate
Replicate runs a wide catalog of third-party image models (SDXL, Flux, etc.) behind a uniform REST API. Pass the API token fromhttps://replicate.com/account. -
onDevice
On-device generator. Requires the optional cn1libcn1-ai-stablediffusion; without it this returns anAsyncResourcethat completes withUnsupportedOperationException. -
generate
-