Loading repository data…
Loading repository data…
invuk / repository
Kontext4J is a chaotic yet powerful Java wrapper for BFL/Flux Kontext APIs. Edit, fill, generate, or expand images with one slick file—no 200 lines of boilerplate, no ritual sacrifices. Handles paths, URLs, base64, polls until ready, and downloads results. The nano-banana of Java AI libs.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
The Java lib that’s too cool for bloated dependencies. Edits, fills, expands, generates, and low-key judges every other library still downloading 300 MB of JARs.
If other image libs were at a party, they'd still be figuring out Maven while Kontext4J already made your avatar a cyberpunk queen and found a mysterious nano banana in your pocket. 🍌💀
new Kontext4J().init(key).generate(...).getUrl()edit(...) — multi-image editing, masks, prompts, negative prompts, seeds, guidance… basically everything you want.fill(...) — inpainting with optional masks and mask modes.generate(...) — text → image, also supports reference images.expand(...) — outpaint top/bottom/left/right like a boss.status == Ready.getUrl(), getUrls(), or download(path).org.json.Other libs be like:
Copy Kontext4J.java into your project (src/main/java/io/github/initio/kontext4j/Kontext4J.java).
Dependencies:
org.json:jsonMaven snippet:
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20230227</version>
</dependency>
Kontext4J k = new Kontext4J().init("YOUR_API_KEY_HERE");
// no api key? no magic. 💀
k.model("generate")
.generate(
"A tiny robot sipping coffee, cinematic lighting, ultra detailed",
null, "16:9", 42, 30, 7.5, null, null,
"png", null, null, 1, null, null, null
);
System.out.println("Image URL: " + k.getUrl());
// other libs would still be configuring XML, we already sipping coffee. ☕🤖
k.generateSimple("Cyberpunk cat in neon alley");
System.out.println(k.getUrl());
// because we don't need 300 MB of JARs for one cat. 🐱💡
k.edit(
"/home/me/pic1.jpg",
"/home/me/pic2.jpg",
null, null,
"Make all subjects wear futuristic helmets",
null, "1:1", 12345, 40, 6.0,
null, null, "jpg",
null, null, 2
);
System.out.println(k.getUrls());
// other libs: "please configure 12 XML files." 🤡
k.editSimple("/home/me/selfie.jpg", "Add sunglasses and party lights");
System.out.println(k.getUrl());
k.editMerge(List.of("/pic1.jpg","/pic2.jpg"), "Turn them into a superhero squad");
System.out.println(k.getUrls());
k.fill(
"/home/me/photo.jpg",
"/home/me/mask.png",
"replace",
"Make subject wear a futuristic helmet",
null, "1:1", 12345, 40, 6.0, null, null,
"jpg", null, null, 1
);
System.out.println(k.getUrls());
// inpainting so smooth, other libs cry into their 17 threads. 😭
k.expand(
"https://example.com/input.png",
200, 0, 0, 200,
"Extend environment to neon city skyline",
null, 40, 7.0, null, null, "png", null, null, 1
);
System.out.println(k.getUrl());
// other libs: "Wait… which edge is left again?" 🤔
k.download(Paths.get("kontext_result.png"));
// no fuss, no spaghetti code. 🍝
k.downloadIndex(Paths.get("kontext_result2.png"), 0);
init(String apiKey)model(String modelName) — "edit" | "fill" | "generate" | "expand"setRequestTimeout(Duration d)setPollIntervalMillis(long ms)setMaxWaitMillis(long ms)edit(...), editSimple(...), editMerge(...)fill(...)generate(...), generateSimple(...)expand(...)getUrls(), getUrl(), getLastRawResult()download(Path), downloadIndex(Path, int)Sometimes, very rarely, a URL or sample might contain a nano banana. No promises. Full giggle guaranteed when it shows up.
No result available — forgot init(apiKey)?Polling timed out — increase setMaxWaitMillis(...) or check webhook.Invalid JSON — server sent a JSON-shaped potato 🥔.MIT recommended. Free, petty, and small — like your nano banana.
(Memes > bug reports)
Kontext4J is tiny but opinionated: minimal dependencies, sane defaults, speed > drama. Use it to edit, generate, fill, expand — maybe find a nano banana too. 🍌