https://github.com/mrkorzun/ai_gateway_bot
Telegram bot with full OpenAI API integration (Chat, Vision, Image). Supports model selection, user cabinet with balance top-up, auto billing (+50% markup), full request history, PostgreSQL, proxy support, and Docker/GitHub deployment.
https://github.com/mrkorzun/ai_gateway_bot
ai-integration ai-reseller aiogram billing chatbot chatgpt dalle docker docker-compose gpt-vision openai payments postgresql proxy python resell-ai sqlalchemy telegram-bot
Last synced: about 2 months ago
JSON representation
Telegram bot with full OpenAI API integration (Chat, Vision, Image). Supports model selection, user cabinet with balance top-up, auto billing (+50% markup), full request history, PostgreSQL, proxy support, and Docker/GitHub deployment.
- Host: GitHub
- URL: https://github.com/mrkorzun/ai_gateway_bot
- Owner: mrkorzun
- Created: 2025-08-30T14:05:42.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2025-08-30T14:12:59.000Z (about 2 months ago)
- Last Synced: 2025-08-30T16:09:26.095Z (about 2 months ago)
- Topics: ai-integration, ai-reseller, aiogram, billing, chatbot, chatgpt, dalle, docker, docker-compose, gpt-vision, openai, payments, postgresql, proxy, python, resell-ai, sqlalchemy, telegram-bot
- Language: Python
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π€ AI-Gateway-Bot
Telegram bot with full OpenAI API integration designed for **reselling AI services**.
The project provides a convenient interface for using Chat, Vision, and Image Generation models directly in Telegram, while handling billing, balance management, and request logging.This bot is aimed at developers, entrepreneurs, and businesses that want to **monetize AI usage** without building everything from scratch.
It includes a built-in billing system with a 50% markup, user cabinet for balance management, complete request history stored in PostgreSQL, and proxy support for stable API access.Deployed with Docker/GitHub, the bot ensures scalable, maintainable, and production-ready infrastructure.
![]()
![]()
![]()
![]()
![]()
![]()
![]()
---
## π Features
- π¬ **Chat** β interact with any selected OpenAI model.
- π **Vision** β analyze an image (1 request β response β back to main menu).
- π¨ **Image Generation (DALLΒ·E)** β create images from prompts.
- π€ **Personal Cabinet**:
- view user ID and balance,
- top-up balance via payment link,
- verify payment.
- βοΈ **Model Selection** β switch between available models stored in the database.
- πΎ **Request History**:
- logs every request, user, cost, and tokens spent.
- πΈ **Monetization**:
- each model is priced **50% higher** than official OpenAI API rates,
- balance is deducted automatically.
- π **Proxy support** for stable API access.---
## π° Pricing Model & Payments
- Each OpenAI model is billed **50% higher** than the official OpenAI API price.
Example: if the API price is $0.01, the user is charged $0.015.
- User balance is stored in the database and automatically deducted after each request.
- Payment workflow:
1. User clicks **Top Up Balance** in the Personal Cabinet.
2. Enters the desired amount and receives a payment link.
3. After payment, clicks **Verify Payment**:
- if successful β balance is updated, success message is shown;
- if failed β nothing changes.
- All transactions are logged (user ID, amount, status).
- Statistics dashboard will be available in the admin panel.---
## π Tech Stack
- Python 3.11+
- Aiogram (Telegram Bot API)
- OpenAI API (ChatGPT, GPT-Vision, DALLΒ·E)
- PostgreSQL + SQLAlchemy + Alembic
- Docker + docker-compose
- GitHub Actions (CI/CD)---
## π Project Structure
```text
repo/
ββ bot/ # Telegram handlers
ββ services/ # business logic (balance, billing, AI)
ββ providers/ # OpenAI API + proxy
ββ db/ # SQLAlchemy models, Alembic migrations
ββ admin/ # admin panel (stats, CRUD)
ββ tests/ # unit tests
ββ docker/ # Dockerfile and scripts
ββ deploy/ # docker-compose.prod.yml and configs
ββ .env.example # example environment variables
ββ README.md
ββ requirements.txt
```---
## βοΈ Installation & Run
```bash
git clone https://github.com//.git
cdcp .env.example .env
# fill in keys and settingsdocker-compose up --build -d
```---
## π Roadmap
- [x] Basic Telegram bot
- [ ] OpenAI API integration (chat/vision/image)
- [ ] Personal cabinet + balance tracking
- [ ] Balance top-up & payment verification
- [ ] PostgreSQL + SQLAlchemy + Alembic
- [ ] Token & cost tracking
- [ ] Admin panel (stats, users)
- [ ] Docker + server deployment
- [ ] CI/CD via GitHub Actions