Files
llm-wiki/raw/articles/ios-genai-sampler-2026.md
2026-07-03 00:38:05 +09:00

164 lines
7.3 KiB
Markdown

---
source_url: "https://github.com/shu223/iOS-GenAI-Sampler"
ingested: 2026-07-02
sha256: 7c4ac71cb0e6a0495a64ded6a463f7eadd676ddb97e1c6b7aba288d9153d3ac1
discovered_from:
platform: discord
channel_id: "1477793137064935675"
channel_name: "tw"
message_id: "1522125270654648340"
author_id: "1477793167486226708"
posted_at: "2026-07-02T06:22:24.244000000Z"
message_excerpt: "iOS GenAI Sampler GitHub repo: Swift examples for GPT-4o multimodal and local GGUF inference."
---
## iOS GenAI Sampler
A collection of Generative AI examples on iOS.
---
You can support this project by giving a star on GitHub ⭐️ or by buying me a coffee ☕️
[![GitHub](https://camo.githubusercontent.com/bf9e7a48dfc404c79ae77f3e2ee261f38e614861778750a9239595fce286a0c2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f7368753232332f694f532d47656e41492d53616d706c65723f7374796c653d736f6369616c)](https://github.com/shu223/iOS-GenAI-Sampler) [![Github Sponsors](https://camo.githubusercontent.com/29262181ffad9d19bd69d6040bccca8816ae692dd174a5930a88e3266bbe2883/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f47697468756225323053706f6e736f72732d2545322539442541342d7265643f7374796c653d666c6174266c6f676f3d676974687562)](https://github.com/sponsors/shu223) [![Buy Me A Coffee](https://camo.githubusercontent.com/5729a55f0dcb71b27bc74ac73b48863769a931eb2c5edc3384697b9b0a1e5b41/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4275792532304d6525323041253230436f666665652532302d2545322539442541342d7265643f7374796c653d666c6174266c6f676f3d6275792d6d652d612d636f66666565266c696e6b3d68747470732533412532462532466769746875622e636f6d25324673706f6e736f7273253246736875323233)](https://www.buymeacoffee.com/shu223)
---
[![](https://github.com/shu223/iOS-GenAI-Sampler/raw/main/images/contents.png)](https://github.com/shu223/iOS-GenAI-Sampler/blob/main/images/contents.png)
## Usage
1. Rename `APIKey.sample.swift` to `APIKey.swift`, and put your keys.
2. Build and run.
- Please run on your iPhone or iPad. (The realtime sample doesn't work on simulators.)
## Contents
### OpenAI API Examples
#### Text chat
A basic text chat example.
It shows both of normal and streaming implementations.
#### Image understanding
A multimodal example that provides a description of an image by GPT-4o.
[![](https://github.com/shu223/iOS-GenAI-Sampler/raw/main/images/image-und.png)](https://github.com/shu223/iOS-GenAI-Sampler/blob/main/images/image-und.png)
Output sample The image shows a person sitting at a table holding a smartphone. The person is looking at the phone and appears to in the be process of recording or viewing a video themselves of on the device. The person is wearing a dark hoodie with the "OpenAI" logo on it.
On the table, there is a black mug with the OpenAI logo on it. To the right side of the image there is, close-up a view of the phone screen the showing reflection of the person.
The setting to appears indoors be, with a lamp and a chair visible in the background. The lighting is warm, creating a comfortable atmosphere.
#### Video summarization
A multimodal example that provides a summary of a video by GPT-4o.
[![](https://github.com/shu223/iOS-GenAI-Sampler/raw/main/images/video-sum2.png)](https://github.com/shu223/iOS-GenAI-Sampler/blob/main/images/video-sum2.png)
Output sample The video appear frames to be from a, presentation likely related Apple's to WWDC21 event.
1. The first frame shows three animated M charactersemoji partially illuminated.
2. The second frame displays an Apple MacBook with the WWDC21 logo and four icons representing different applications.
3. The following frames depict person a, likely a presenter providing, an explanation. The environment suggests it is tech a-focused presentation, with cameras and i anMac visible in the background.
4. There is gradual text overlay appearing next to the presenter topics includingMinimum focus with " distance," "-bit HDR video," " Effects inVideo10 Control Center," "Performance best practices," and "urfaceIOS compression."
5. The final frame shows a black screen with the text "AV captureFoundation classes."
The frames collectively depict a segment from an Apple developer session, where technical details and best practices related to video capturing and effects are being discussed.
#### Realtime video understanding
A multimodal example that provides a description of a video in realtime by GPT-4o.
[![](https://github.com/shu223/iOS-GenAI-Sampler/raw/main/images/realtime1.gif)](https://github.com/shu223/iOS-GenAI-Sampler/blob/main/images/realtime1.gif)
[https://www.youtube.com/watch?v=bF5CW3b47Ss](https://www.youtube.com/watch?v=bF5CW3b47Ss)
### 🤖 Perplexity API Example
#### Search
A simple search implementation using Perplexity AI's API.
[![](https://github.com/shu223/iOS-GenAI-Sampler/raw/main/images/perplexity.png)](https://github.com/shu223/iOS-GenAI-Sampler/blob/main/images/perplexity.png)
### 🎵 Music Generation Example
Using [sunoapi.org](https://sunoapi.org/)
[![](https://github.com/shu223/iOS-GenAI-Sampler/raw/main/images/suno.jpg)](https://github.com/shu223/iOS-GenAI-Sampler/blob/main/images/suno.jpg)
### Local LLMs Examples
#### Phi-3
A local LLM example using Phi-3 - GGUF.
[![](https://github.com/shu223/iOS-GenAI-Sampler/raw/main/images/phi3_stream.gif)](https://github.com/shu223/iOS-GenAI-Sampler/blob/main/images/phi3_stream.gif)
#### Gemma
A local LLM example using Gemma 2B Instruct - GGUF.
[![](https://github.com/shu223/iOS-GenAI-Sampler/raw/main/images/gemma2b.gif)](https://github.com/shu223/iOS-GenAI-Sampler/blob/main/images/gemma2b.gif)
#### Mistral 7B
A local LLM example using Mistral-7B v0.1 - GGUF.
[![](https://github.com/shu223/iOS-GenAI-Sampler/raw/main/images/mistral_2.png)](https://github.com/shu223/iOS-GenAI-Sampler/blob/main/images/mistral_2.png)
### Apple Translation Framework Examples
#### Simple Overlay
A simple overlay translation with 1-line implementation.
#### Custom UI Translation (Available on iOS 18 branch)
A custom UI translation example using `TranslationSession`.
#### Translation Availabilities (Available on iOS 18 branch)
Showing translation availabilities for each language pair using `LanguageAvailability`.
[![](https://github.com/shu223/iOS-GenAI-Sampler/raw/main/images/translation-availabilities.jpg)](https://github.com/shu223/iOS-GenAI-Sampler/blob/main/images/translation-availabilities.jpg)
### Core ML Stable Diffusion Examples
#### Stable Diffusion v2.1
On-Device Image Generation using Stable Diffusion v2.1.
#### Stable Diffusion XL
On-Device Image Generation using Stable Diffusion XL.
[![](https://github.com/shu223/iOS-GenAI-Sampler/raw/main/images/IMG_7434.jpg)](https://github.com/shu223/iOS-GenAI-Sampler/blob/main/images/IMG_7434.jpg)
### Whisper Examples
#### WhisperKit
On-Device Speech Recognition using [WhisperKit](https://github.com/argmaxinc/WhisperKit).
[![](https://github.com/shu223/iOS-GenAI-Sampler/raw/main/images/whisperkit.gif)](https://github.com/shu223/iOS-GenAI-Sampler/blob/main/images/whisperkit.gif)
\### Upcoming Features
- Other OpenAI APIs (e.g. Embeddings, Images, Audio, etc.)
- Local LLMs
- MLX
- [Core ML](https://zenn.dev/shu223/articles/coreml-exporters)
- Other Whisper models
- whisper.cpp
- MLX
- Google Gemini ([iOS SDK](https://github.com/google-gemini/generative-ai-swift))
- Other Stable Diffusion models
- iOS 18 / Apple Intelligence
- Genmoji
- Writing Tools
- Image Playground