Yesterday, I added support for Online Generative AI Services to my iOS app, PocketMind, allowing users to connect using their own API keys. Along the way, I built three Swift classes to integrate directly with:
✅ OpenAI
✅ Anthropic
✅ Google Gemini
Here’s how they rank in terms of integration ease:
1️⃣ OpenAI: Straightforward and well-documented. Streaming responses were a breeze!
2️⃣ Anthropic: Also easy, with clear docs for streaming responses.
3️⃣ Google Gemini: Documentation was decent, but I struggled to parse streaming responses. Had to disable streaming to get it working. Planning to review the official generative-ai-swift library from Google to debug further.
Why Build from Scratch?
While there are libraries available, implementing the APIs manually allowed me to standardize everything for seamless integration into PocketMind.
Shoutout to xAI for their OpenAI-compatible endpoints that worked flawlessly. In contrast, Google’s beta endpoints didn’t align with my standard OpenAI class due to a non-standard input format.
What’s Next?
• Add file attachment support for compatible models
• Enable image generation for supported online services
Update Pending Review: Once the new PocketMind version goes live, I’d love your feedback!