How to integrate an ML model into your app: seven steps from use case to retraining

The roadmap meeting ends with "Add AI to the app" scrawled on the whiteboard. Six weeks later, there's a chatbot demo that works on the CEO's phone and nowhere else.
This guide covers how to integrate an ML model into your app in seven steps, using the iOS and Android options current in October 2026. The model call is a few lines of code. Most of the work sits around it: where the model runs, what data it may see and who keeps it accurate once real users arrive. A phone adds limits a web app can mostly ignore, too. Memory and battery are tight, connectivity drops and every release goes through app store review.
User expectations have moved fast. Sensor Tower's State of Mobile 2026 report found that generative AI app downloads doubled in 2025 to 3.8 billion across iOS and Google Play. In-app purchase revenue for those apps nearly tripled to more than $5 billion. AI in mobile app development is now something buyers compare apps on.
Before you start
Have these in place, or the steps below will stall halfway:
- A baseline number. Today's search success rate, ticket volume or conversion for the screen you want to change. Without it, you can't prove the model helped.
- Data you're allowed to use. Apple's App Review Guideline 5.1.1 requires consent for collecting user or usage data. US state laws such as the CCPA add notice-at-collection and opt-out duties.
- A backend you control. Cloud model calls should go through it, never straight from the app.
- Real test devices, including the oldest phone you still support.
- A named owner for the model after launch, the way someone owns the payments integration.
One check comes before all of it. If the logic is already known, such as tax rates, shipping cutoffs or eligibility rules, write it in code. It'll be exact and auditable, and no model will beat it. The same goes for a decision that can't tolerate a wrong answer when you have no way to add human review.
Step 1: Write the problem as a sentence with a number in it
"Shoppers abandon search after 2 failed queries" is a requirement. "Make the app smarter" isn't.
Then ask what a wrong answer costs. A bad product suggestion costs a scroll. A wrong dosage reminder or refund amount costs far more, and those features need a person in the loop or a rules-based fallback.
Last, try the dumb version on paper. If a lookup table or a simple filter gets you most of the way, ship that first. You'll learn what the model really has to do, and you'll have a baseline to beat.
Step 2: Audit the data the model will learn from or read
Mobile apps throw off plenty of data: taps, searches, purchases, locations, photos. Most of it is noisy, unlabeled or collected for some other purpose. Go through your sources one at a time and check four things.
Coverage. Is there enough training data for the outcome you want to predict, including the rare cases? A smaller dataset can still work if you adapt an existing model instead of training from scratch.
Labels. Does anyone know which past answers were right? Without labels, you can't train a classifier or measure a generative feature.
Consent. Was the data collected for this use? If not, you can't train on it, whatever the volume.
Freshness. Does it reflect how people use the app today, or how they used it two redesigns ago?
When the model needs real-time data
Real-time (live) data access changes what an AI feature can do. A model fed last night's batch knows what a user liked yesterday. A model fed live events can react to the item they just viewed, the delivery that's running late or the payment that looks odd.
That speed costs engineering effort. You'll need event streaming, a feature store or cache the model can read in milliseconds, and monitoring for gaps in the feed. The upside for analytics teams is that dashboards and models finally read the same numbers at the same moment. That alone settles a lot of arguments about whose report is right.
Step 3: Decide where the model runs
Settle this before you look at vendors. It fixes your cost, privacy story, latency and the set of models you can even use.
| Factor | On-device | Cloud | Hybrid |
|---|---|---|---|
| Latency | Fast, no network round trip | Depends on connection | Fast path on device, cloud for hard cases |
| Works offline | Yes | No | Partly |
| Privacy | Data stays on the phone | Data leaves the phone; needs disclosure | Sensitive steps stay local |
| Model size and quality | Smaller models | Largest, most capable models | Both |
| Cost per call | No server or token cost | Pay per request or per token | Mixed |
| Device coverage | Limited to supported hardware | Any device with a connection | Broadest |
| Updating the model | Ship a new model to devices | Update on the server | Both paths |
In practice, most teams land on hybrid. Short, private or offline tasks run on the phone. Long documents, complex reasoning and anything that needs fresh company data go to the cloud, whether that's AWS, Google Cloud, Azure or a model provider's own API.
On iPhone and iPad
Apple's Foundation Models framework gives your app direct access to the on-device model behind Apple Intelligence. It also reaches larger Apple models running in Private Cloud Compute. Features include guided generation, tool calling, image understanding and Dynamic Profiles, and Apple says the on-device model works without internet connectivity.
Two planning details are easy to miss. Developers in the App Store Small Business Program with fewer than 2 million first-time App Store downloads can use the Private Cloud Compute models at no cloud API cost. Some server-side features have daily limits. Separately, any provider can ship a Swift package that conforms to the framework's Language Model protocol, and Apple lists Claude and Gemini among the supported third-party models.
To bring your own model, Apple's machine learning page points to Core AI for LLMs and other generative models. Core ML remains the choice for traditional models such as tree ensembles and regression. The Vision framework handles OCR, barcode scanning and image analysis on the device.
On Android
Google's Android AI page sets out three on-device routes and one cloud route.
ML Kit GenAI APIs run Gemini Nano through AICore, an Android system service, so input and output stay on the device. Summarization, proofreading, rewriting, image description and a Prompt API are in beta; speech recognition is in alpha. Only phones on a published list are supported, so build the fallback now.
Plain ML Kit covers common jobs such as text recognition and barcode scanning, with built-in models and no ML expertise required.
LiteRT, built on the TensorFlow Lite foundation, runs custom models. It exports and quantizes models from PyTorch, TensorFlow and JAX into the .tflite format, with CPU, GPU or NPU acceleration. It also runs on iOS, the web and desktop.
Cross-platform, and the cloud route
Firebase AI Logic, which Google renamed from Vertex AI in Firebase, lets Swift, Kotlin, Java, web, Flutter and Unity apps call Gemini models through a proxy. App Check and per-user rate limits protect the endpoint, and the Gemini API key stays on the server. Several of its SDKs support hybrid inference: on-device when the model is available, cloud when it isn't.
Whatever the stack, a custom model must be converted to a format the runtime understands, such as .tflite, Core ML or ONNX. Quantization stores the weights at lower precision. It cuts file size and inference time, usually at a small cost in accuracy, so measure that cost in step 6.
React Native teams have their own libraries, covered in React Native AI: how to add AI to your app.
Step 4: Pick the cheapest model that clears your accuracy bar
There are three realistic options, and the first one that meets the bar from step 1 wins.
| Option | What it means | Good for | Watch out for |
|---|---|---|---|
| Ready-made API | Call a prebuilt capability for specific tasks such as OCR, translation or summarization | Common tasks, fast launch | Limited control over behavior |
| Foundation model with prompts | Use a general model and shape it with instructions, examples and tools | Gen AI features: assistants, summaries, drafting | Output varies; needs evaluation and guardrails |
| Custom-trained model | Pick a model architecture, then train or fine-tune it on your own data | Domain predictions: churn, demand, defect detection | Needs labeled data, MLOps and an owner |
For gen AI in app development, two features take out most of the risk. Guided generation makes the model return a structured object your code can check, not free text. Tool calling lets the model ask your app for a fact, such as an order status, instead of guessing. Answers grounded in your own verified data are the ones users can trust.
An in-app support assistant shows both at work. It looks up the order through a tool, replies in a fixed format and hands off to a person when it's unsure. It's the same pattern behind conversational AI for customer contact, in an app or a call center.
If you're building an adaptive app
Adaptive apps change what they show based on who's using them, when and how. A retail app that reorders its home screen for a repeat buyer is one. So is a field-service app that pre-fills a work order from a photo of the equipment plate.
That behavior usually comes from one of three model types. Recommendation and ranking models decide what goes first. Classification and prediction models flag churn risk, fraud or a likely next action, and image recognition sits here too. Generative and natural language processing models summarize, rewrite or answer in plain language.
It's only worth it when one screen serves people with very different goals. If nearly every user does the same three things, a cleaner static flow will beat a model.
Note that Google's adaptive apps guidance on Android means something different. It covers layouts that fit phones, tablets, foldables and cars. A serious product usually needs both kinds.
Step 5: Integrate the ML model into your app behind a proper layer
The call itself is short. What surrounds it decides whether the feature survives real users.
Start with secrets. A cloud model API key inside the app binary can be extracted by anyone, who can then run up your bill. Route every call through your own backend or a proxy like Firebase AI Logic. Verify the app with App Check or your own attestation, and set per-user limits. For a custom model, the backend is often a small prediction API built with FastAPI or Flask.
Then design for answers that are slow, wrong or missing:
- Validate input before it reaches the model and output before it reaches the screen.
- Run the same preprocessing the model saw in training. Skip it and predictions go quietly wrong.
- Give each feature a latency budget, and stream partial output when you'll blow through it.
- Keep the app working without the smart part when the device lacks the on-device model or the network drops.
- Let users see the source of an answer, edit a generated draft or undo an automatic action.
- Put a thumbs up or down in the flow. Those taps become labeled data for step 7.
Both stores now address AI directly, so build compliance into the screens. Apple's Guideline 5.1.2(i) says you must clearly disclose where personal data will be shared with third parties, "including with third-party AI," and get explicit permission first. Google explained its Play policy on AI-generated content in the Android Developers Blog (June 2024). Apps that generate content must let users report or flag offensive output and must prevent restricted content. A consent screen designed in from day one is far quicker than one added after a rejection.
Step 6: Test against an evaluation set, not just a test plan
Classic QA checks that a button does the same thing every time. AI output varies, so you need a second kind of testing on top.
Build an evaluation set first. Collect a few hundred real prompts or inputs, each paired with a ground-truth answer you'd accept. Run every model or prompt change against it before release. For classifiers, track precision and recall rather than overall accuracy alone. Apple now ships an Evaluations framework alongside Foundation Models for exactly this job.
Next, go after the edges: empty inputs, other languages, very long text, blurry photos, rude prompts and attempts to make the model ignore its instructions. Run all of it on real hardware. On-device models behave differently across chips and memory sizes, and the oldest supported phone is where problems show first.
Write down what you tested. Google recommends documenting AI testing, and the record helps when a store reviewer or your own legal team comes asking.
Step 7: Deploy, monitor and retrain
Ship only after the model passes the evaluation set. Decide whether it serves real-time predictions or batch jobs, and whether it lives in a fully managed service or on infrastructure you run.
Then plan for model drift. The world changes and the model doesn't: new products, new slang, a new user segment, a seasonal spike. Input data slides away from what the model learned, and performance drops without a single error in your logs.
Four things should exist before launch:
- Monitoring in production for input patterns, output quality, latency and cost per user.
- A retraining or re-prompting trigger tied to a metric threshold, not a calendar date. Retrain on new data, rerun the evaluation set, then deploy.
- Versioning, so you know which model and prompt produced each answer and can roll back.
- The owner you named before step 1.
That loop is what people mean by MLOps. If it's new to your team, our AI and machine learning services team can build the evaluation set and production monitoring with you before launch.
How the steps map to the AI development lifecycle
US enterprise teams often need to show this work in a recognized framework. The NIST AI Risk Management Framework (AI RMF 1.0, released January 26, 2023) groups AI risk work into four functions: Govern, Map, Measure and Manage. NIST added a Generative AI Profile (NIST AI 600-1) on July 26, 2024. The framework is voluntary, but the seven steps line up with it neatly.
| Lifecycle stage | Steps in this guide | NIST AI RMF function |
|---|---|---|
| Set policy, owners and risk limits | Before you start, step 1 | Govern |
| Frame the use case and its context | Steps 1–2 | Map |
| Build and integrate | Steps 3–5 | Map and Manage |
| Evaluate before release | Step 6 | Measure |
| Monitor and improve after launch | Step 7 | Measure and Manage |
Troubleshooting
Most problems after launch trace back to a skipped step. Start here.
| Symptom | Likely cause | Fix |
|---|---|---|
| AI feature works on new phones only | On-device model isn't supported on older hardware | Add a cloud or no-AI fallback; test on the oldest supported device |
| Predictions look plausible but wrong | Input preprocessing differs from training | Reuse the training pipeline's preprocessing in the app or backend |
| Cloud bill spikes overnight | API key shipped in the app, or no per-user limits | Move calls behind a proxy with App Check and rate limits |
| Assistant invents order details | Model answers from memory | Add tool calling and ground answers in your own data |
| Responses feel slow | Model too large or network round trip | Quantize, move short tasks on-device or stream partial output |
| App rejected in review | No disclosure or consent for third-party AI | Add the consent screen and a report option for generated content |
| Accuracy slides months after launch | Model drift | Monitor input patterns and retrain on a metric trigger |
FAQ
Can you add AI to an existing mobile app without rebuilding it?
Yes. Most teams add AI to an existing app one feature at a time, through an API call or an on-device framework, without touching the rest of the codebase. The main work is the integration layer: consent screens, fallbacks, a backend proxy and monitoring. A rebuild only makes sense if the architecture can't support those pieces.
Which AI model is best for mobile app development?
No single model is best; the right one depends on the task, the device and your data rules. For short, private or offline tasks, start with Apple's Foundation Models framework or Gemini Nano through ML Kit GenAI APIs. Use a larger cloud model for complex reasoning or long documents, and a custom-trained model for predictions specific to your business.
Is there an AI that can build a mobile app?
Yes, for prototypes. No-code and low-code builders such as Bubble and Microsoft Power Apps can generate an app from a plain-language description, which is handy for testing an idea. A production app that handles customer data still needs engineers to own the integration layer, store compliance, security and monitoring.
Your next step
Go back to the whiteboard and replace "Add AI to the app" with a sentence you can measure. Something like "cut failed searches in half, on-device where we can, with a fallback and an owner" will do. Our mobile app development and generative AI teams can take that sentence and run the data audit in step 2 with you.
Related reading
Also serving Southeast Asia: Mobile App Development Company Singapore and Mobile App Development in Thailand.