Run generative AI models directly on Android devices — no cloud, no cost per request, fully private.
Quick Start • Examples • Docs
Preview: Foundry Local for Android is under active development. APIs, capabilities, and behavior may change between preview releases. Review the release notes and validate your app before upgrading.
suspend fun runChat(context: Context, modelAlias: String) {
val config = Configuration(appName = "my-app")
val manager = FoundryLocalManager.create(context, config)
val model = manager.getCatalog().getModel(modelAlias)
model.download(progress = { progress -> Log.d("DL", "$progress%") })
model.load()
val chat = model.createChatClient()
chat.completeChatStreaming(
ChatCompletionRequest(messages = listOf(ChatMessage.user("Hello!")))
).collect { chunk ->
print(chunk.delta)
}
}That's it — model downloaded, loaded, and generating text on-device.
The application supplies modelAlias from its model selection or configuration.
Running on Windows or macOS? See Foundry Local.
Foundry Local runs AI models on the Android device. Choose one deployment mode:
- IPC mode — Your app includes a thin SDK library (no native code). Inference runs in the Foundry Local service app, a separate process. This mode keeps your APK small, provided the Foundry Local App has been downloaded. Preferred if you have strict APK size limitations.
- Embedded mode — Your app bundles the full inference engine including native libraries. No Foundry Local service app needed. Fully self-contained. Preferred if your app must work without depending on other installed apps
Both modes expose the same Kotlin API. Their installation, packaging, process, storage, and lifecycle behavior differ.
Foundry Local distributes each deployment mode as a separate AAR. Add exactly one to your application.
-
Download
foundry-local-ipc-sdk-<version>.aarfrom the matching release. -
Place it in your app module's
libs/directory. -
Add the required dependencies:
// app/build.gradle.kts dependencies { implementation(files("libs/foundry-local-ipc-sdk-<version>.aar")) implementation("androidx.core:core-ktx:1.12.0") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:<coroutines-version>") }
AndroidX Core supplies the notification and foreground-service classes used during model downloads; those classes are not packaged in the IPC AAR.
-
Add internet permission for catalog access and model downloads:
<uses-permission android:name="android.permission.INTERNET" />
-
Install the Foundry Local App on the device.
-
Download
foundry-local-embedded-sdk-<version>.aarfrom the matching release. -
Place it in your app module's
libs/directory. -
Add the dependency:
// app/build.gradle.kts dependencies { implementation(files("libs/foundry-local-embedded-sdk-<version>.aar")) implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:<coroutines-version>") }
-
Add the same internet permission used for catalog access and model downloads.
No service app is required. Inference runs in your application process.
For detailed setup instructions, see the Integration Guide.
- Chat completions with streaming support
- Audio transcription for files and live audio
- Multi-turn conversations
- Model download, load, unload, and cache management
- Download progress and coroutine cancellation
- Optional chat request controls, including temperature, top-k, top-p, and maximum tokens
- ApiExplorerAppIPC — connection, catalog, model lifecycle, chat, streaming, reconnection, and cache removal using the shared API
- ChatAppIPC — streaming chat and live voice input through the service app
- AudioTranscriptionAppIPC — file, streaming, and live audio transcription through the service app
- ChatAppEmbedded — chat, streaming responses, and live voice input
- AudioTranscriptionAppEmbedded — file, streaming, and live audio transcription
Build any sample from the repository root after placing the matching release AAR in its libs/
directory:
./gradlew :ApiExplorerAppIPC:assembleDebug
./gradlew :ChatAppIPC:assembleDebug
./gradlew :AudioTranscriptionAppIPC:assembleDebug
./gradlew :ChatAppEmbedded:assembleDebug
./gradlew :AudioTranscriptionAppEmbedded:assembleDebug- Integration Guide — Step-by-step setup and first inference
- API Reference — Classes, methods, and data types
- IPC and embedded deployment modes — Compare how each mode operates
- Best Practices — Coroutines, lifecycle, memory, and cleanup
- Troubleshooting — Common integration and runtime problems
Download the versioned AAR for your deployment mode from GitHub Releases:
foundry-local-ipc-sdk-<version>.aarfoundry-local-embedded-sdk-<version>.aar
Verify the artifact SHA-256 published with the release before adding it to your application.
The repository's MIT license covers its documentation, sample applications, and repository tooling. The SDK AARs are distributed under the license and notices included with those artifacts and are not granted under the repository's MIT license.
The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described below. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft's privacy statement. Our privacy statement is available at Microsoft Privacy Statement.
val config = Configuration(appName = "my-app", disableTelemetry = true)This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Third-party trademarks and logos are subject to their respective policies.