π Live portfolio page
A few months ago I wanted AI image generation accessible
directly in Telegram β no web UI, no waiting, just type
a prompt and get an image back in the chat. So I built it.
128 developers cloned the repo in the last 2 weeks with
zero promotion. Apparently others wanted the same thing.
Here's exactly how it works.
What it does
- Send any text prompt to the bot
- Bot generates an image using SDXL / Juggernaut XL
- Returns image directly in Telegram chat
- Supports custom models via ComfyUI workflows
- Runs on any GPU server (I use free Kaggle/Colab and a VPS with GPU)
The Stack
- python-telegram-bot β handles all Telegram API
- ComfyUI β the image generation backend
- SDXL / Juggernaut XL β the actual models
- websockets β connects bot to ComfyUI API
- Oracle Cloud ARM β hosts the bot 24/7 for free
How it works
ComfyUI exposes a REST API. The bot sends your prompt
to ComfyUI via websocket, waits for the image, then
sends it back to Telegram. That's the whole loop.
async def generate_image(prompt: str) -> bytes:
# Build ComfyUI workflow with your prompt
workflow = build_workflow(prompt)
# Send to ComfyUI API
async with websockets.connect(COMFYUI_WS) as ws:
await queue_prompt(workflow, ws)
image_data = await wait_for_output(ws)
return image_data
async def handle_message(update, context):
prompt = update.message.text
await update.message.reply_text("Generating... ")
image = await generate_image(prompt)
await update.message.reply_photo(image)
The tricky parts
1. ComfyUI workflow as JSON
ComfyUI workflows are JSON graphs. Export any workflow
from the UI, save as a template, then inject the user
prompt at runtime. This lets you swap models without
changing bot code.
2. Queue management
Multiple users sending prompts simultaneously = queue
needed. I use asyncio queues to process one generation
at a time, with the user getting a "position X in queue"
message.
3. GPU access without paying
For development: Kaggle notebooks (30hrs GPU/week free),
Google Colab free tier.
For production hosting the bot itself (not the GPU),
you need almost nothing β it's just a Python process
making API calls.
Good free/cheap options:
- Railway.app β free tier, deploy straight from GitHub, zero config
- Render.com β free tier, auto-deploys on git push
- Fly.io β free allowance, great for bots
- Any $4/month VPS β DigitalOcean, Hetzner, Vultr
The bot uses ~80MB RAM idle. A $4 Hetzner ARM server
handles it perfectly.
Results
The bot handles ~20-30 image requests per day on a
single deployment. Average generation time: 8-15 seconds
on a mid-range GPU.
Users can also send style keywords:
- "realistic portrait of a cat --style photorealistic"
- "cyberpunk city at night --style anime"
What's next
Currently adding:
- Image-to-image (send a photo + prompt = transformed image)
- Multiple model selection via /model command
- DALL-E 3 fallback when GPU is unavailable
Full source code
Everything is open source:
π Github
π€ Jenerator Bot - AI Image Generation
Production-ready Telegram bot with GPU-accelerated image generation using Stable Diffusion XL Turbo. Generate high-quality images in under 4 seconds with natural language prompts.
π View Full Project Portfolio
β οΈ Note: Demo currently paused for infrastructure optimization. Full codebase and deployment guide available.
β¨ Features
Core Capabilities
- β‘ Lightning-fast generation - Sub-4 second image creation (L40 GPU)
- π¨ High-quality outputs - SDXL Turbo model for photorealistic results
- π§ ComfyUI backend - Professional workflow management
- π¬ Telegram integration - Intuitive bot interface with inline buttons
- π° Payment system - Cryptocurrency payment integration
- π Usage tracking - Credit system with transaction history
- πΌοΈ Gallery system - Browse and regenerate previous images
Technical Highlights
- GPU-optimized inference pipeline
- Asynchronous request handling
- Docker containerization
- Production-grade error handling
- Automatic queue management
- Real-time generation status updates
π― Why This Project Matters
This bot demonstrates:
- Production ML deployment - Not a toyβ¦
π π Live portfolio page
Includes the full bot, ComfyUI workflow templates,
deployment guide on Cloud, and systemd service
config for 24/7 running.
If you build something with it or have questions,
drop a comment β happy to help.
Top comments (0)