An open API service indexing awesome lists of open source software.

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.

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
cd

cp .env.example .env
# fill in keys and settings

docker-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