How I evolved a simple open-source BYOK bot into a Zero-Knowledge AI assistant with long-term memory using Python, asyncio, and cryptography.
When you use a Telegram bot to access an AI model, who do you actually trust? The answer is more complex than it seems. The chain of trust has at least three links: Telegram itself, a corporation like Google or OpenAI, and—the most unpredictable link—the third-party bot developer. They stand directly between you, your API key, and your entire conversation history.
This question bothered me when I built my first open-source project, MyGemini. It's a simple Telegram bot that works on a BYOK (Bring Your Own Key) model, giving users full control over their API costs. It was a step in the right direction, but it only solved part of the problem. Even with open-source code, a "weakest link" remained: me, the server administrator. Users had to trust not just the code, but also the person running it.
On top of that, I was frustrated by the fundamental "amnesia" of AI models. Every new conversation started from scratch.
What if we could just remove that weak link from the equation? Not with promises, but with cryptography. What if we could build a system where even the service creator is technically incapable of seeing your data, and that system could remember everything?
That's the idea behind MyGemini Zero. It's not just an update; it's my answer to both of these problems.
The Big Question: Why Pay if I'm Still Using My Own API Key?
This is the right question to ask. And yes, MyGemini Zero still operates on the BYOK model—you use your personal Google AI API key. You aren't paying for AI access (that's yours already). You're paying for the sophisticated infrastructure and unique features built on top of it.
Here’s what that means in practice.
1. Long-Term Memory: Your Personal "Second Brain"
- The Problem: Standard chatbots are great performers but poor partners. They don't remember what you discussed yesterday.
- The Solution: I integrated a personal vector database (ChromaDB + LangChain) into the bot. Now, every message you send and every file (
.txt
,.md
) you upload becomes a "memory." When you ask a new question, the bot performs a semantic search on your past interactions to find relevant context and injects it into the prompt.
In practice: You can ask, "What were the key takeaways from that marketing article I uploaded last week?" or "Remind me of the main risks in 'Project Quantum' we talked about," and the bot will understand.
2. Privacy: Removing the Weakest Link
When using a third-party bot, your chain of trust looks like this:
- Telegram (with your messages)
- Google/OpenAI (with your prompts)
- The Bot Developer (with your API key and conversation history)
That third point is the most unpredictable vulnerability.
My solution was to design a Zero-Knowledge Architecture to remove myself from the trust equation.
- All your data—including your API key and chat history—is encrypted with a master password that only you know.
- The decryption key is generated on-the-fly in memory from your password and your personal salt. It disappears when your session expires. As the admin, I never see it and don't have it.
- The Result: It is cryptographically impossible for me to read your conversations or access your API key. If you forget your password, your data is gone forever because no one can recover it. It's a trade-off: replacing trust in a person with a mathematical guarantee.
3. Personalization and Convenience
On top of memory and security, you get a stable, turnkey platform. You don't have to deal with servers, databases, or maintenance. You save dozens of hours on technical chores and just use the product.
The Three Paths — The BYOK Philosophy Lives On
I believe in freedom of choice, so the ecosystem offers three paths, all built on the BYOK principle:
🚀 Hosted Service (Paid): MyGemini Zero
Use your API key and get all the advanced features (memory, encryption) without any technical overhead. (Subscription required).
🆓 Free BYOK Alternative: MyGemini (classic)
It's not going anywhere. Use your API key for a convenient interface to Gemini, but without the long-term memory and Zero-Knowledge features.
💻 Ultimate Privacy (BYOK + Self-Host): Source Code on GitHub
For developers and privacy enthusiasts. The full source code for MyGemini Zero is on GitHub. You can deploy it on your own server for free. This is the ultimate form of BYOK—you control both the key and the code.
What You Get with MyGemini Zero
- 🧠 Long-Term Memory: Remembers context across all your conversations and uploaded files (
/memorize
). - 🔐 Zero-Knowledge Architecture: Cryptographically secures your API key and data with a master password only you know.
- 🗂️ Multi-Context Dialogs: Create isolated chats for different topics so contexts don't get mixed up.
- 📄 Data Management: Archive old messages into summaries or completely wipe your memory.
- 🖼️ Image Analysis & 🌐 Web Search: All the powerful features of Google Gemini.
Under the Hood
The project is built on a modern async Python stack:
- Core:
Python 3.10+
,asyncio
,pyTelegramBotAPI (async)
- Security:
Cryptography
,bcrypt
,PBKDF2
for the Zero-Knowledge implementation. - Memory:
LangChain
&ChromaDB
for vector operations,SQLite
for storing encrypted data. - License: AGPLv3. This is an important distinction from the previous project's MIT license. The AGPL ensures that if someone uses this code to run a public service, they must also share their modifications. It keeps the project truly open and prevents it from being absorbed into closed-source commercial products.
Conclusion
MyGemini Zero was the logical next step for me. It's an attempt to build not just another AI interface, but a truly personal and private assistant where trust in the developer is replaced by cryptography.
I'd be thrilled if you gave it a try. Any feedback, ideas, and of course, stars on GitHub are the best reward for the work I've put in.
Thanks for reading!
Top comments (0)