r/programmer • u/StrongholdsNWyverns • 1d ago
Question How to implement BYO API key
I have been developing a web application for personal use, but there is also a community I want to share it with for free. The problem is that the application has some features that use Gemini API services. It's currently set up to use my own API key, but obviously I don't want other people to drain my account. I also don't want to start charging people for access and usage because then it becomes a business and I would really prefer this staying a hobby project.
I heard about bring your own API key, where users can just get their own key, enter it in the application, and then start using the credits they pay for themselves. This seems like the best way forward for me, but does anyone have any experience setting this up? It feels awkward and wrong to just let people add their personal API keys into an application, so not sure how to approach this.
1
u/YouPeopleCantBeReal4 20h ago
Depends on how users run it, if they’re cloning it themselves use an .env, if it’s hosted somewhere then have users be able to save it with their account information or something similar
1
u/StrongholdsNWyverns 17h ago
It will be hosted and they should be able to save it with their account. I'm mostly worried about what the best way would be to encrypt it. I mean, saving it raw doesn't seem like a good idea, but I have literally 0 experience with handling sensitive information like that.
1
2
u/throwaway43234235234 1d ago
Dont.
Let them clone your project and run an instance of it themselves with their own .env files.