
Mobile-first SDK for building AI-driven mobile apps: streaming chat, RAG retrieval, durable autonomous agents with checkpointed workflows, multi-agent orchestration, provider-agnostic models, lifecycle-aware execution, human-in-the-loop.
Build AI-powered Android & iOS apps in Kotlin — chat, agents, RAG, and more.
MobileGraph is an open-source Kotlin Multiplatform SDK that lets you add AI capabilities to your Android and iOS apps — from a simple chatbot to a full autonomous agent — without worrying about process death, lifecycle, or provider lock-in.
Think of it as "LangChain / LangGraph, but built for mobile."
val session = MobileGraph.instance.createSession()
session.stream("Plan a 3-day trip to Tokyo").collect { chunk ->
print(chunk.text) // ← streams to your UI in real time
}| Capability | What it means |
|---|---|
| 💬 AI Chat | Streaming conversations with OpenAI, Gemini, Claude, or any provider — swap with one line |
| 📄 RAG (search your docs) | Load PDFs or text on-device, embed them, and let the LLM answer questions from your data |
| 🤖 Autonomous Agents | LLMs that decide when to call your Kotlin functions (weather, calculator, APIs…) |
| 🔀 Multi-Agent Workflows | Run agents in parallel, chain them, or build manager → worker hierarchies |
| 💾 Survives Process Death | Checkpoints state automatically — your AI workflow resumes exactly where it left off |
| 🧑💻 Human-in-the-Loop | Pause any workflow to ask for user approval, then continue |
| 📱 Truly Mobile-First | Lifecycle-aware, offline-capable, battery-conscious — not just an API wrapper |
MobileGraph is inspired by the architectural ideas pioneered by LangChain and LangGraph, which introduced modular LLM orchestration, retrieval pipelines, tool integration, and stateful workflow execution.
Instead of replicating those frameworks, MobileGraph reimagines these concepts for the Kotlin ecosystem by combining:
Our goal is to provide Kotlin developers with a modern AI framework that feels as natural as Ktor for networking and Jetpack Compose for UI development while embracing the best architectural ideas from today's AI ecosystem.
MobileGraph is built with respect for the open-source community, and we are grateful to the projects whose ideas continue to inspire modern AI development.
The rapid evolution of Large Language Models has transformed how developers build intelligent applications. Frameworks such as LangChain and LangGraph have demonstrated the power of modular prompts, retrieval pipelines, tools, memory, and agent orchestration.
However, most AI frameworks have been designed primarily for server-side applications.
Mobile applications operate in a fundamentally different environment.
Applications can be:
These challenges require more than simply wrapping an LLM API.
MobileGraph was created to address these challenges by providing a mobile-first AI runtime built specifically for the Kotlin ecosystem.
Instead of treating mobile devices as thin clients, MobileGraph provides the infrastructure needed to build resilient, stateful, and production-ready AI applications that feel native to Android, iOS, and Kotlin Multiplatform.
MobileGraph is built around a small set of architectural principles that guide every module in the framework.
Unlike traditional AI frameworks, MobileGraph embraces the realities of mobile computing.
The runtime is designed to support:
Applications should not depend on a specific AI provider.
MobileGraph provides a unified abstraction layer that allows developers to integrate multiple AI providers through a consistent API.
Supported providers include:
with additional providers planned for future releases.
Changing providers should require little or no application code changes.
Every capability within MobileGraph is implemented as an independent module.
Developers only include the functionality they need.
Examples include:
This modular architecture keeps applications lightweight while remaining highly extensible.
MobileGraph embraces Kotlin's type system.
Instead of relying on loosely typed maps or dynamic JSON structures, the framework encourages:
This leads to safer, more maintainable applications.
MobileGraph is built using Kotlin Multiplatform from the ground up.
Business logic is shared across platforms while preserving native user experiences.
Supported platforms include:
The framework is built around Kotlin Coroutines and Flow.
This provides:
Developers work with familiar Kotlin APIs without introducing additional reactive frameworks.
Modern AI applications require more than simple prompt-response interactions.
MobileGraph provides the building blocks for intelligent systems through:
These capabilities enable developers to build applications that can reason, plan, and execute complex workflows.
MobileGraph aims to provide a developer experience that is:
The framework is designed to grow with your application—from a single prompt to sophisticated multi-agent systems—without requiring fundamental architectural changes.
MobileGraph is being developed in incremental phases, with each phase building on a stable, modular, and extensible architecture.
Our mission is to become the Kotlin-first AI framework for the Android ecosystem and Kotlin Multiplatform, enabling developers to build everything from simple AI assistants to enterprise-grade, autonomous agentic applications. See Roadmap Guide
| Phase | Status | Focus |
|---|---|---|
| ✅ Phase 1 | Completed | Core Runtime & Lifecycle |
| ✅ Phase 2 | Completed | Knowledge Layer (RAG) |
| ✅ Phase 3 | Completed | Multi-Agent Orchestration |
| ✅ Phase 4 | Completed | Multi-Model Cloud Ecosystem |
| 🚧 Phase 5 | In Progress | Model Context Protocol (MCP) |
| 🔜 Phase 6 | Planned | Local AI & Edge Inference |
| 🔮 Phase 7 | Future | Android Ecosystem |
| 🚀 Phase 8 | Vision | MobileGraph Studio |
We welcome community contributions, ideas, and feedback as we continue building the future of AI development for the Android ecosystem.
To ensure stability and compatibility, verify your project meets these requirements:
Add the SDK to your project via Maven Central. Since MobileGraph is engine-agnostic, you must also provide a Ktor HTTP engine (e.g., OkHttp for Android).
repositories {
mavenCentral()
}
dependencies {
implementation("io.github.mobilegraph:mobilegraph-sdk:0.5.0-alpha")
// Required: Choose a Ktor engine
implementation("io.ktor:ktor-client-okhttp:3.5.1")
}Initialize within a CoroutineScope (like lifecycleScope or viewModelScope) to ensure the registry is ready:
lifecycleScope.launch {
MobileGraph.initialize {
withModels {
openai(apiKey = "sk-...") { isDefault = true }
gemini(apiKey = "...")
claude(apiKey = "...")
}
}
}Start a resilient, stateful interaction with just a few lines:
val session = MobileGraph.instance.createSession()
// Resilient, streaming interaction
session.stream("Plan a 3-day trip to Tokyo").collect { chunk ->
print(chunk.text)
}If you are building a release version, add these rules to your proguard-rules.pro to prevent runtime crashes:
# Ktor & Serialization
-keepattributes Signature, *Annotation*, InnerClasses
-keep class io.ktor.** { *; }
-keep class kotlinx.serialization.json.** { *; }
# MobileGraph Models
-keep class io.mobilegraph.models.** { *; }
-keepclassmembers class * {
@kotlinx.serialization.SerialName <fields>;
}
For more details on Setup see Setup Guide
Define and execute complex workflows with just a few lines:
val agent = MyResearchAgent(mobileGraph.models.chat())
val workflow = stateGraph {
start("research")
node(AgentNode("research", agent, runtime))
node(EndNode("finish"))
edge("research", "finish")
}
// Run the agentic workflow with automatic checkpointing
val result = runtime.run(workflow, initialState)For more details on Agents see Agent Guide
For a detailed module dependency graph and architecture diagrams, see the Architecture Overview.
mobilegraph-core: The backbone. Handles execution context, lifecycle, events, and component registry.mobilegraph-checkpoint: Infrastructure for state persistence and durable execution.mobilegraph-state: Core interfaces for immutable graph state and variable management.mobilegraph-agents: Orchestration logic for multi-agent workflows, parallel execution, and hierarchical delegation.mobilegraph-graph: Graph-based state machine engine with support for Fan-out/in and breakpoints.mobilegraph-models: Adapters for major LLM providers (OpenAI, Gemini, etc.) and capability orchestration.mobilegraph-tools: Infrastructure for function calling, tool registration, and semantic tool selection.mobilegraph-parsers: Type-safe structured data extraction (JSON-to-Kotlin objects) with prose extraction.mobilegraph-prompts: A type-safe DSL for building token-aware, structured prompts.mobilegraph-rag: High-level orchestration for retrieval-augmented generation pipelines.mobilegraph-documents: Document ingestion and processing (PDF, Text, Markdown).mobilegraph-embeddings: Interfaces and adapters for vector embedding models.mobilegraph-vectorstores: On-device and remote vector storage (e.g., SQLite-based vector search).mobilegraph-retrieval: Semantic search logic and context retrieval strategies.The project includes a comprehensive reference implementation for Android that demonstrates the following core patterns:
local.properties in the root folder:
open_ai_api=sk-your-key-here:androidApp configuration. The Master Screen provides a dashboard to launch each of these specific demos.Detailed guides for building agentic workflows with MobileGraph:
| Group | Features | Guide |
|---|---|---|
| Core & Setup | AI Framework Initialization, Interaction Patterns, Model Registry | Read Guide |
| Intelligence | Prompt Composer DSL, Structured Parsers, Vision (Vision) | Read Guide |
| Multi-Model | OpenAI, Gemini, Claude, OpenRouter Integration | Read Guide |
| Agent Framework | Multi-Agent Orchestration, Parallel Execution, Hierarchical | Read Guide |
| Persistence & State | Graph State, Checkpointing, Durable Execution, Resumption | Read Guide |
| Tools & Agents | Function Calling, Semantic Tool Selection, Vector Caching | Read Guide |
| Resilience & Memory | Chat Memory, Sliding Windows, Local-First Sync | Read Guide |
| Observability | Middleware Pipeline, Event Streams, Custom Logging | Read Guide |
| RAG: Document Ingestion | Document Ingestion, Vector Embedding, Similarity Search, Event Streams | Read Guide |
| RAG: Retrieval and LLM Generation | Document Retrieval, RAG Pipeline, Event Streams | Read Guide |
Contributions are welcome.
If you'd like to contribute:
Check out our CONTRIBUTING.md to join us.
MobileGraph is licensed under the Apache License 2.0. See the LICENSE file for more info.
Build AI-powered Android & iOS apps in Kotlin — chat, agents, RAG, and more.
MobileGraph is an open-source Kotlin Multiplatform SDK that lets you add AI capabilities to your Android and iOS apps — from a simple chatbot to a full autonomous agent — without worrying about process death, lifecycle, or provider lock-in.
Think of it as "LangChain / LangGraph, but built for mobile."
val session = MobileGraph.instance.createSession()
session.stream("Plan a 3-day trip to Tokyo").collect { chunk ->
print(chunk.text) // ← streams to your UI in real time
}| Capability | What it means |
|---|---|
| 💬 AI Chat | Streaming conversations with OpenAI, Gemini, Claude, or any provider — swap with one line |
| 📄 RAG (search your docs) | Load PDFs or text on-device, embed them, and let the LLM answer questions from your data |
| 🤖 Autonomous Agents | LLMs that decide when to call your Kotlin functions (weather, calculator, APIs…) |
| 🔀 Multi-Agent Workflows | Run agents in parallel, chain them, or build manager → worker hierarchies |
| 💾 Survives Process Death | Checkpoints state automatically — your AI workflow resumes exactly where it left off |
| 🧑💻 Human-in-the-Loop | Pause any workflow to ask for user approval, then continue |
| 📱 Truly Mobile-First | Lifecycle-aware, offline-capable, battery-conscious — not just an API wrapper |
MobileGraph is inspired by the architectural ideas pioneered by LangChain and LangGraph, which introduced modular LLM orchestration, retrieval pipelines, tool integration, and stateful workflow execution.
Instead of replicating those frameworks, MobileGraph reimagines these concepts for the Kotlin ecosystem by combining:
Our goal is to provide Kotlin developers with a modern AI framework that feels as natural as Ktor for networking and Jetpack Compose for UI development while embracing the best architectural ideas from today's AI ecosystem.
MobileGraph is built with respect for the open-source community, and we are grateful to the projects whose ideas continue to inspire modern AI development.
The rapid evolution of Large Language Models has transformed how developers build intelligent applications. Frameworks such as LangChain and LangGraph have demonstrated the power of modular prompts, retrieval pipelines, tools, memory, and agent orchestration.
However, most AI frameworks have been designed primarily for server-side applications.
Mobile applications operate in a fundamentally different environment.
Applications can be:
These challenges require more than simply wrapping an LLM API.
MobileGraph was created to address these challenges by providing a mobile-first AI runtime built specifically for the Kotlin ecosystem.
Instead of treating mobile devices as thin clients, MobileGraph provides the infrastructure needed to build resilient, stateful, and production-ready AI applications that feel native to Android, iOS, and Kotlin Multiplatform.
MobileGraph is built around a small set of architectural principles that guide every module in the framework.
Unlike traditional AI frameworks, MobileGraph embraces the realities of mobile computing.
The runtime is designed to support:
Applications should not depend on a specific AI provider.
MobileGraph provides a unified abstraction layer that allows developers to integrate multiple AI providers through a consistent API.
Supported providers include:
with additional providers planned for future releases.
Changing providers should require little or no application code changes.
Every capability within MobileGraph is implemented as an independent module.
Developers only include the functionality they need.
Examples include:
This modular architecture keeps applications lightweight while remaining highly extensible.
MobileGraph embraces Kotlin's type system.
Instead of relying on loosely typed maps or dynamic JSON structures, the framework encourages:
This leads to safer, more maintainable applications.
MobileGraph is built using Kotlin Multiplatform from the ground up.
Business logic is shared across platforms while preserving native user experiences.
Supported platforms include:
The framework is built around Kotlin Coroutines and Flow.
This provides:
Developers work with familiar Kotlin APIs without introducing additional reactive frameworks.
Modern AI applications require more than simple prompt-response interactions.
MobileGraph provides the building blocks for intelligent systems through:
These capabilities enable developers to build applications that can reason, plan, and execute complex workflows.
MobileGraph aims to provide a developer experience that is:
The framework is designed to grow with your application—from a single prompt to sophisticated multi-agent systems—without requiring fundamental architectural changes.
MobileGraph is being developed in incremental phases, with each phase building on a stable, modular, and extensible architecture.
Our mission is to become the Kotlin-first AI framework for the Android ecosystem and Kotlin Multiplatform, enabling developers to build everything from simple AI assistants to enterprise-grade, autonomous agentic applications. See Roadmap Guide
| Phase | Status | Focus |
|---|---|---|
| ✅ Phase 1 | Completed | Core Runtime & Lifecycle |
| ✅ Phase 2 | Completed | Knowledge Layer (RAG) |
| ✅ Phase 3 | Completed | Multi-Agent Orchestration |
| ✅ Phase 4 | Completed | Multi-Model Cloud Ecosystem |
| 🚧 Phase 5 | In Progress | Model Context Protocol (MCP) |
| 🔜 Phase 6 | Planned | Local AI & Edge Inference |
| 🔮 Phase 7 | Future | Android Ecosystem |
| 🚀 Phase 8 | Vision | MobileGraph Studio |
We welcome community contributions, ideas, and feedback as we continue building the future of AI development for the Android ecosystem.
To ensure stability and compatibility, verify your project meets these requirements:
Add the SDK to your project via Maven Central. Since MobileGraph is engine-agnostic, you must also provide a Ktor HTTP engine (e.g., OkHttp for Android).
repositories {
mavenCentral()
}
dependencies {
implementation("io.github.mobilegraph:mobilegraph-sdk:0.5.0-alpha")
// Required: Choose a Ktor engine
implementation("io.ktor:ktor-client-okhttp:3.5.1")
}Initialize within a CoroutineScope (like lifecycleScope or viewModelScope) to ensure the registry is ready:
lifecycleScope.launch {
MobileGraph.initialize {
withModels {
openai(apiKey = "sk-...") { isDefault = true }
gemini(apiKey = "...")
claude(apiKey = "...")
}
}
}Start a resilient, stateful interaction with just a few lines:
val session = MobileGraph.instance.createSession()
// Resilient, streaming interaction
session.stream("Plan a 3-day trip to Tokyo").collect { chunk ->
print(chunk.text)
}If you are building a release version, add these rules to your proguard-rules.pro to prevent runtime crashes:
# Ktor & Serialization
-keepattributes Signature, *Annotation*, InnerClasses
-keep class io.ktor.** { *; }
-keep class kotlinx.serialization.json.** { *; }
# MobileGraph Models
-keep class io.mobilegraph.models.** { *; }
-keepclassmembers class * {
@kotlinx.serialization.SerialName <fields>;
}
For more details on Setup see Setup Guide
Define and execute complex workflows with just a few lines:
val agent = MyResearchAgent(mobileGraph.models.chat())
val workflow = stateGraph {
start("research")
node(AgentNode("research", agent, runtime))
node(EndNode("finish"))
edge("research", "finish")
}
// Run the agentic workflow with automatic checkpointing
val result = runtime.run(workflow, initialState)For more details on Agents see Agent Guide
For a detailed module dependency graph and architecture diagrams, see the Architecture Overview.
mobilegraph-core: The backbone. Handles execution context, lifecycle, events, and component registry.mobilegraph-checkpoint: Infrastructure for state persistence and durable execution.mobilegraph-state: Core interfaces for immutable graph state and variable management.mobilegraph-agents: Orchestration logic for multi-agent workflows, parallel execution, and hierarchical delegation.mobilegraph-graph: Graph-based state machine engine with support for Fan-out/in and breakpoints.mobilegraph-models: Adapters for major LLM providers (OpenAI, Gemini, etc.) and capability orchestration.mobilegraph-tools: Infrastructure for function calling, tool registration, and semantic tool selection.mobilegraph-parsers: Type-safe structured data extraction (JSON-to-Kotlin objects) with prose extraction.mobilegraph-prompts: A type-safe DSL for building token-aware, structured prompts.mobilegraph-rag: High-level orchestration for retrieval-augmented generation pipelines.mobilegraph-documents: Document ingestion and processing (PDF, Text, Markdown).mobilegraph-embeddings: Interfaces and adapters for vector embedding models.mobilegraph-vectorstores: On-device and remote vector storage (e.g., SQLite-based vector search).mobilegraph-retrieval: Semantic search logic and context retrieval strategies.The project includes a comprehensive reference implementation for Android that demonstrates the following core patterns:
local.properties in the root folder:
open_ai_api=sk-your-key-here:androidApp configuration. The Master Screen provides a dashboard to launch each of these specific demos.Detailed guides for building agentic workflows with MobileGraph:
| Group | Features | Guide |
|---|---|---|
| Core & Setup | AI Framework Initialization, Interaction Patterns, Model Registry | Read Guide |
| Intelligence | Prompt Composer DSL, Structured Parsers, Vision (Vision) | Read Guide |
| Multi-Model | OpenAI, Gemini, Claude, OpenRouter Integration | Read Guide |
| Agent Framework | Multi-Agent Orchestration, Parallel Execution, Hierarchical | Read Guide |
| Persistence & State | Graph State, Checkpointing, Durable Execution, Resumption | Read Guide |
| Tools & Agents | Function Calling, Semantic Tool Selection, Vector Caching | Read Guide |
| Resilience & Memory | Chat Memory, Sliding Windows, Local-First Sync | Read Guide |
| Observability | Middleware Pipeline, Event Streams, Custom Logging | Read Guide |
| RAG: Document Ingestion | Document Ingestion, Vector Embedding, Similarity Search, Event Streams | Read Guide |
| RAG: Retrieval and LLM Generation | Document Retrieval, RAG Pipeline, Event Streams | Read Guide |
Contributions are welcome.
If you'd like to contribute:
Check out our CONTRIBUTING.md to join us.
MobileGraph is licensed under the Apache License 2.0. See the LICENSE file for more info.