u/United_Youth3739

I built a browser-hosted image gen API on Perchance (ntfy relay) — timings, cross-platform quirk, and an upscale bug I can’t fix
▲ 3 r/freetoolsAI+1 crossposts

I built a browser-hosted image gen API on Perchance (ntfy relay) — timings, cross-platform quirk, and an upscale bug I can’t fix

I turned an active browser tab into a fully functional Image Generator API using ntfy as a relay

Generator / Endpoint: https://perchance.org/papi

I built a working Image Generator API where an open browser tab acts as the dedicated compute worker, communicating with external clients entirely through public relays. No cloud API subscription or backend server setup required—it is up, running, and ready to use.

How the System Works

The browser tab is the actual engine powering the generator:

* Start Worker: Open the generator tab, click Start Worker, and leave the tab open.

* Dispatch Job: Any client sends a POST request with a JSON payload to an ntfy topic:

[https://ntfy.sh/\](https://ntfy.sh/){endpointId}-req

* Generate: The open browser picks up the job via the relay, runs the image generation pipeline, and sends the result back to:

[https://ntfy.sh/\](https://ntfy.sh/){endpointId}-res

* Fetch Result: The client listens via SSE or polls the -res topic for the corresponding jobId to receive the output (image URL or base64).

[ Client / App ] ─── POST /req ───▶ [ ntfy.sh Relay ] ─── SSE ───▶ [ Browser Generator ]

│ (generates image)

[ Client / App ] ◀── SSE/Poll ───── [ ntfy.sh Relay ] ◀── POST /res ───────┘

API Contract

Request (-req topic):

{

"jobId": "unique-uuid",

"prompt": "detailed subject description, high detail...",

"negative": "blurry, low quality",

"resolution": "512x512",

"upscale": "off",

"format": "jpeg"

}

Optional parameters: quality, negative. Large, structured prompts work without issue.

Response (-res topic):

{

"ok": true,

"jobId": "unique-uuid",

"width": 512,

"height": 512,

"imageBase64": "...",

"imageUrl": "..."

}

If an error occurs, it returns {"ok": false, "error": "..."}. For large payloads, ntfy converts the data into an attachment.url.

Performance & Benchmarks

Generation speed depends entirely on the host machine running the generator tab, not the requesting client:

| Host Device | Typical Generation Speed |

|---|---|

| Mid-tier PC / Laptop | ~5 – 50 seconds |

| Mobile Device | ~20 – 250 seconds |

* Host Latency Rule: A phone requesting from a PC worker tab receives images at PC speeds.

* Foreground Requirement: Browsers heavily throttle background tabs. The tab must stay open and active in the foreground; background drops throughput by roughly 10×.

Current Status & Roadblocks

* Generation: Stable and fully functional. Though love to hear how we can optemise the speed and add background processing. I tried few things and tell you it help from nothing to something in background tabe problem. But we need to optemise it more.

* AI Upscaling: In-browser ESRGAN tiling currently leaves subtle vertical/horizontal seam lines across tiles. If anyone has clean implementations for border feathering or overlap blending in WebGL/WASM upscaling, advice is welcome.

* In Development: Adding structured JSON conversations for LLM integration and improved parallel job scheduling.

Feel free to plug into the endpoint and test it out. Feedback on the relay flow or tips on in-browser tile seam blending are appreciated!

u/United_Youth3739 — 14 days ago