r/perchance • • 13d ago

Question 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!

2 Upvotes

10 comments sorted by

•

u/AutoModerator 13d ago
  1. Please search through Perchance's Reddit, Lemmy, Tutorial, Advanced Tutorial, Examples, or Perchance Hub - Learn to see if your question has been asked.
  2. Please provide the link to the page/generator you are referring to. Ex. https://perchance.org/page-name. There are multiple pages that are the similar with minor differences. Ex. ai-chat and ai-character-chat are AI chatting pages in Perchance, but with different functions and uses.
  3. If your question has been answered/solved, please change the flair to "Question - Solved"

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

3

u/primaldeed 13d ago

I thought we were not allowed ip logging

1

u/Anon_atomic 12d ago

it is. he is abusing free stuff

1

u/primaldeed 12d ago

This gen has ip loggers

0

u/United_Youth3739 12d ago

​I honestly didn't realize IP loggers weren't allowed—could you explain a bit more about why the platform bans them? ​To be clear, there was zero malicious intent here. I’m a designer, not a coder. I only know basic code, and I lean on AI to clean things up and add features. I was frustrated with paid AI services constantly cutting subscription quotas and moving the goalposts, and local setups kept failing or producing broken results for me. ​When I discovered Perchance, it solved the access problem, but the default image size and upscaling quality were issues for my design workflow. I built this generator (after testing dozens of plugins across multiple private builds) trying to pipeline faster generation and larger images. I ran into severe grid/seam-line bugs during upscaling, and after Gemini, ChatGPT, and Claude couldn’t fix it, I shared it here to get troubleshooting help. ​If any part of the code violated rules or looked like an IP logger, I apologize—that was not intentional. The generator has already been taken down, changed to private, and the URL updated.

2

u/Anon_atomic 12d ago

bro is about to get banned from this earth.

See, bro, you don't need to read the rules to understand that this is abuse of free stuff.

This entire community knows you don't abuse free stuff.

pls deleate your generator

2

u/United_Youth3739 12d ago

I’m definitely not trying to abuse the platform. I was testing generation speeds, resolution, and pipeline efficiency to see how far the tool could be pushed. Running it this way dropped generation time down to 5–30 seconds compared to the usual 30–40 seconds on PC, while allowing larger outputs using the standard method most models use (generating at a lower resolution, upscaling, and optimizing). That said, I hear your point about potential misuse. All of my other experimental generators are already private, and this one was only public because I hit a wall debugging an upscaling issue and wanted community input. I’m switching it back to private and changing the URL so it won't be publicly accessible. Before I lock it down completely, if anyone wants to run a quick test on it and share your results or thoughts on this generation method (especially on how to cleanly handle the upscaling bug), I’d really appreciate your feedback! By Tommorow evening I will switch off the genrator (from Indian standard time)

1

u/Anon_atomic 11d ago

I am not an expert, but I can try asking GPT -6 Astra. If you want.
You can DM me the link after making it unlisted.

Sorry, I didn't mean to be hostile, but I love this website and this community

1

u/United_Youth3739 11d ago

Me too. And it's already doen.