OpenAI-Wrapper-SwiftUI: The iPhone AI app that never ships your API key
A SwiftUI vision wrapper built around a proxy-first trust boundary, automatic camera prompting, and a deliberately boring backend that makes mobile AI safer to ship.
- This repo treats mobile AI as a trust-boundary problem, not just a UI problem.
- Its camera-first flow turns OpenAI into a point-and-ask tool instead of a generic chat box.
- The engineering choices are practical, from image resizing to background persistence to proxy-side key control.
- Its real competition is not another chat demo, but broader Swift SDKs that leave the security architecture to you.
The hidden product is the trust boundary
The obvious label for this repo is wrong. It is not just a SwiftUI wrapper around OpenAI, it is a small argument about where trust should live on a phone. The app keeps the camera and chat on device, but pushes the secret across a proxy boundary, which is exactly where a mobile API key should live.
AIWrapper-SwiftUI is a SwiftUI-based wrapper designed to leverage AI for vision-related tasks. This wrapper interacts with an OpenAI proxy script to secure API communications and protect your API key
That is the cleanest way to read the project. On iOS, binaries are easy to inspect and secrets are hard to hide, so the safest move is often to remove the secret from the client entirely. Adam Lyttle’s repo is interesting because it treats the backend as the lock, not the UI as the fence.
From camera to question, in one motion
The app does not begin with a blank composer. It begins with `CameraView`, which wraps `AVCaptureSession`, captures an image, and hands that image straight into the chat flow. That matters because the first interaction is not typing, it is asking the model to interpret what the camera already saw.
The repo’s point is not that the phone can talk to a model. Plenty of wrappers do that. The point is sequencing. The camera makes the app feel like a tool with intent, and the automatic prompt turns vision into the default mode instead of an edge case.
Update the Proxy Script Location:In the Models >> ChatModel class, update the location property with the URL of your OpenAI proxy script. The source code for the openai_proxy.php script used in the demo is available at:https://github.com/adamlyttleapps/OpenAI-Proxy-PHP.
How the proxy-first pipeline works
The architecture is simple on purpose. The phone captures, resizes, and encodes the image, then sends a request to a PHP proxy, which validates the shared-secret logic and forwards the call to OpenAI. The response comes back through the same boundary, so the client never needs to know the API key at all.
if let image = self.image,
let resizedImage = self.resizedImage(image),
let resizedImageData = resizedImage.jpegData(compressionQuality: 0.4) {
// build and send the proxy payload
}
That is the real engineering choice here. The repo uses a shared-secret style check, and the research notes that the hash is MD5, which is not strong cryptography but is enough to act as a lightweight gate in front of the proxy. The important part is not pretending this is airtight security. The important part is refusing to ship the actual OpenAI key inside the app.
Why the UI stays fast enough to feel native
The same practical mindset shows up in the client code. `ScrollViewReader` keeps the conversation pinned where it should be, `UserDefaults` stores lightweight history metadata, `FileManager` handles the heavier image assets, and background writes keep the interface from stuttering after a send. None of that is glamorous, but it is the difference between a demo and something people can actually use.
That storage split is easy to overlook, but it is one reason the wrapper feels product-shaped. The app is not just moving pixels around. It is keeping the conversation, the camera output, and the saved history in different places so the UI can stay responsive while the model work happens elsewhere.
The comparison that explains the design
| Project | API key handling | Primary use case | Proxy required? | Vision-first? | Best for |
|---|---|---|---|---|---|
| OpenAI-Wrapper-SwiftUI | Key stays off-device and lives behind a proxy | Camera-driven SwiftUI vision apps | Yes | Yes | Teams that want a secure mobile pattern |
| OpenAISwift | Developer manages the key in the app or backend setup | General OpenAI client access | No built-in proxy | No | Apps that want a broad Swift client |
| MacPaw/OpenAI | Developer manages the key in the app or backend setup | General-purpose OpenAI integration | No built-in proxy | No | Teams that want a maintained SDK |
That table is the whole argument in miniature. The broader clients are useful if you want a general SDK, but they do not give you this repo’s opinionated security shape. OpenAI-Wrapper-SwiftUI is narrower on purpose, and that narrowness is what makes it valuable.
What this repo is really teaching
The lesson here is bigger than SwiftUI and bigger than OpenAI. Once AI moves onto the phone, architecture becomes part of the user experience, because the place you store a key determines how safely you can ship the feature at all. This repo is a compact pattern for secretless mobile AI: camera on device, intelligence in the cloud, and the secret parked behind a boring intermediary that does its job without being seen.
That is why the project feels more useful than a typical wrapper. It is not trying to win on breadth, or out-feature a general SDK, or invent a new chat metaphor. It is showing one clean way to build an iPhone AI app that can see, talk, and stay secretless at the same time.