TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: If you are building OpenAI apps, how do you store user's API key?

7 pointsby huydotnetalmost 2 years ago
This question has been around my mind lately.<p>The context is, if you are building a web application that allows user to use their own OpenAI API key to interact with OpenAI, how would you store their API key?<p>1. Local storage, let them send your API key through your server<p>2. Local storage, and the API key is called right from the user&#x27;s browser<p>3. On your server??? How to store it securely? Using a vault manager?<p>#2 seems like a good choice, but in case you need to secure your prompt, then this is not feasible.<p>I&#x27;ve been struggling to find a good way to handle this situation.<p>Anyone have any idea or best practice on how to go about this scenario?

3 comments

cddotdotslashalmost 2 years ago
It’s technically prohibited by OpenAI’s ToS to share your key with any third party, so presumably options 1 and 3 could get your users’ accounts banned. That being said, until OpenAI releases some kind of OAuth, there isn’t a great option unless your app is entirely client side.
评论 #36302669 未加载
sharemywinalmost 2 years ago
Why not use your own api key and collect payment from your customers?<p>or add advertising and make sure you use 3.5
评论 #36301167 未加载
revskillalmost 2 years ago
Definitely local storage.