Replies: 4 comments 16 replies
-
I imagine the optimal use of this library is for swift server development to create an api proxy. Not sure how one would use it securely on the client side. |
Beta Was this translation helpful? Give feedback.
-
Please suggest language for an informative disclaimer and links to relevant documentation in a pull❣️ |
Beta Was this translation helpful? Give feedback.
-
I wanted to start a new discussion, but the I found this one. Of course I am not alone.... I still deployed my app without a proxy and used the openai API directly in my app. After few days in the AppStore my API key got compromised and was used for by Chatgpt4 request. Luckily I had a set a limit and learned a lesson. I wanted to start a discussion about what best solution for the recommended server-side communication between Openai exists, so your API key doesn't get exposed to the client. Some solutions using Firebase / Google Cloud Functions are very safe but cannot stream back the results word by word, which is a UX problem for my app. Setting up for own server with node.js or python could be a solution but adds another layer of complexity to the stack I was even thinking of putting the macpaw client on a server-side swift app with vapor, but that is probably a wild idea. |
Beta Was this translation helpful? Give feedback.
-
Ok, here's what you and everyone else need to do. You need a server. A Lambda, Google/Firebase Function, Vercel ServerActions (easy-mode function). Now, you still have security problem. Because your Server API is unsecured. How do you secure your client->server? And even after attesting the app, a crafting pen tester can still subvert that, so you need to rate limit your API, and then also rate limit your server->OpenAI. If you just want a solution that works, just do the following.
So essentially you get iOS->Server API security, API rate limiting, OpenAI rate limiting. You lose streaming, but...you can go through the pain in the ass of setting up your API to be streaming and then forward the stream to client. Figure out how to do with that a Function. Also, you can swap our Firebase for Vercel, but then you lose the easy login and app check features( have to handroll), or you can go AWS Amplify (and you lose the app check and easy firestore/storage...etc). Or host your own Express server on Railway and then you go through a different nightmare. Pick your nightmare. The reality is the amount of setup you have to do to make this secure means if you are handrolling this yourself (passing JWTS) and what not, god bless you, you don't need to read anything I am writing because you are a better dev than me. There is a LOT of work to be done to use OpenAI securely from an iOS app. I understand why the authors decided to leave the documentation section regarding security architecture empty. Unfortunately, I don't have the time to do a full PR and contribute, I only have the time to give you this little snippet to help you along the way. |
Beta Was this translation helpful? Give feedback.
-
Will this package work with an api proxy to protect the api key, or is the warning more of an”don’t use this package with a shipping app” warning?
Beta Was this translation helpful? Give feedback.
All reactions