OnDeviceAI
A minimal Compose Multiplatform sample showing how to call on-device generative AI from shared Kotlin code, using Apple's Foundation Models framework on iOS and Google's ML Kit Prompt API on Android.
The sample defines a small PromptApi Kotlin interface shared across platforms, implemented by a Swift class on iOS that calls Apple's on-device LanguageModelSession, and by a Kotlin class on Android that calls ML Kit's on-device generation client. The shared Compose Multiplatform UI code calls this interface without knowing which platform implementation is behind it.
The project is split into a shared composeApp module holding the UI and the interface plus the Android implementation, an androidApp module for the Android application shell, and an iosApp Xcode project holding the Swift implementation, a structure required because the Android Gradle Plugin's application plugin is incompatible with the Kotlin Multiplatform plugin inside the same module.