LLM Hub Studio · Blog

Building an AI Sleep Coach That Runs on a Phone

A sleep coach that runs entirely on the phone needs no wearable, no server and no account. Here is how on-device sleep tracking and a local AI coach work in practice.

Building an AI Sleep Coach That Runs on a Phone

Most sleep apps are cloud apps in disguise. They record your nights, send the data to a server, run the analysis somewhere else, and show you the result the next morning. That works, but it asks you to hand over some of the most personal data you have — when you sleep, how you sleep, what your bedroom sounds like — to a company you will never meet.

There is another way to build it. A sleep coach can run entirely on the phone: tracking with the phone's own sensors, coaching with a language model that lives on the device, and syncing with the health apps the user already has. No wearable, no server, no account. This is how OpenSleep, one of LLM Hub Studio's apps, is built — and this guide explains the thinking behind it, for anyone building or choosing a sleep app.

Why sleep coaching belongs on the phone

Sleep is the most private thing a phone can measure. A step count is one thing; a recording of your bedroom at 3am is another. Most people would not hand a stranger a microphone in their bedroom. Yet that is effectively what a cloud sleep app asks for, every night.

Running the whole thing on-device changes the trust equation. When the model and the data never leave the phone, there is nothing to leak, nothing to breach, and nothing to sell. The privacy claim is not a policy page — it is an architecture. The user can verify it the same way they verify anything else about an offline app: turn on airplane mode and watch it keep working.

There is a practical reason too. The bedroom is where phones go on airplane mode, where Wi-Fi drops, where people deliberately disconnect. A sleep coach that needs a server stops working on exactly the nights it is supposed to help. An on-device coach works in a cabin, on a plane, in a house with a dead router. The phone is already there, charging on the bedside table, and that is all the hardware the job needs.

Tracking sleep without a wearable

The obvious objection is that a phone is not a wearable. It cannot measure heart rate from the wrist, and it cannot feel a pulse. That is true, and an honest sleep app should say so. But a phone is not blind. It has an accelerometer, a microphone, and a clock, and together those are enough to build a useful picture of a night.

OpenSleep tracks sleep using motion and sound, analysed in 30-second epochs — short windows of time, each one classified from what the sensors picked up. The accelerometer registers movement: tossing, turning, getting up. The microphone registers sound: snoring, a restless room, an alarm. Epoch by epoch, the night becomes a pattern — periods of stillness, periods of movement, times when the sleeper was awake.

This is not a medical measurement. It cannot diagnose a sleep disorder, and it should never pretend to. What it can do is show a person their own patterns: what time they actually fall asleep, how often they wake, whether their nights are getting shorter over the week. For most people, that pattern is the useful part. They do not need a clinical reading; they need to see, in plain terms, what their nights look like.

The coach: a language model on the phone

Tracking produces data. Coaching turns data into something a person can act on. That is where the on-device language model comes in.

In OpenSleep, the coach is a Gemma model running on LiteRT-LM, the runtime for running language models on phones. Gemma is Google's open model family, and LiteRT-LM is the on-device runtime that lets it run on a phone's CPU, GPU or NPU. The model reads the sleep data the phone collected, looks for patterns, and talks to the user about them in plain language — not a chart, but a conversation.

The important design choice is what the coach is allowed to say. A good on-device sleep coach gives general wellness information: your bedtime has drifted later this week; your nights are shorter on Sundays; your sleep is most broken in the first hour. It can suggest general sleep habits — a consistent bedtime, less screen time before bed, a cooler, darker room. What it must not do is diagnose. It cannot tell a user they have sleep apnoea, insomnia, or any other condition. That line matters, and an app that crosses it is not being helpful — it is being reckless.

Running the coach on-device has a second benefit that is easy to miss: the conversation is private in the same way the data is. The user can ask the coach about their sleep, honestly, without wondering who is reading the transcript. A sleep coach people trust is a coach they will actually talk to.

The engineering: models, battery and thermals

Building this is not a matter of dropping a model into an app and hoping for the best. A phone is a small, hot, battery-powered computer, and a language model is a demanding guest. The work is in making the two get along.

The first decision is the model itself. A sleep coach does not need the largest model available. It needs a model small enough to run quickly on a phone, with good enough language ability to hold a useful conversation about a person's sleep. Quantized models — models compressed so their weights take up less memory — are what make this possible. The trade-off is real: a smaller model is faster and kinder to the battery, but less capable. Picking the right size is the central engineering judgement of the whole app, and it is a judgement that has to be tested on real phones, not just in a simulator.

The second decision is when the model runs. A sleep coach does not need to think all night. The sensible design is to do the heavy work at the moment the user asks — when they open the app in the morning and want to know how they slept — and to keep the overnight work light: sensor recording, epoch classification, and nothing more. That is how the app keeps the phone's battery intact through the night, which is the one thing a sleep app must never fail at. Nobody forgives an app that drains their alarm clock.

The third decision is how the app handles the differences between phones. Android phones and iPhones have different chips, different neural engines, and different thermal limits. A model that runs well on a flagship can struggle on a three-year-old mid-range phone. Testing on real devices — different models, different ages, different states of battery health — is the only way to know. A sleep coach that overheats a phone at 2am is a bug, not a feature.

Syncing without a server

A phone-only app still needs to play well with the rest of a person's health data. OpenSleep syncs with Apple Health and Google Health Connect, so the sleep data it records sits alongside everything else the user tracks — steps, workouts, heart rate from other sources — in the health app they already use.

The sync happens on the device. The app writes its sleep records into the platform health store, and reads back what the user has allowed it to read. There is no OpenSleep server in the middle, because there is no OpenSleep server at all. That is the point: syncing with the platform's health system is a way to be useful without building a cloud, and without asking the user to trust one.

What to look for — as a user, or as a builder

If you are choosing a sleep app, the questions are simple. Where does your data go? If the answer is "nowhere — it stays on your phone," that is the strongest privacy claim an app can make, and it is verifiable. Does it need extra hardware? A phone-only tracker works with the device you already own and charge every night. And is the coaching honest about its limits? General guidance about sleep habits is useful. Claims to detect or diagnose conditions are a red flag.

If you are building one, the same questions apply, in reverse. Can you make the privacy claim an architectural fact rather than a policy promise? Can you pick a model small enough to run well on the phones your users actually own? Can you keep the overnight work light enough that the phone survives the night? And can you draw the line, clearly, between wellness guidance and medical advice — and stay on the right side of it?

The answers to those questions are what make a sleep coach worth building on the phone. The technology — quantized models, on-device runtimes, the phone's own sensors — is ready. The hard part is the discipline: building something that helps people sleep better without asking them to trust a server with their nights.

That is what we set out to do with OpenSleep, and it is the same approach we take with LLM Hub, our on-device AI app that runs 15+ AI models entirely on the phone — chat, image generation, music, code, translator and transcriber — with no accounts and no tracking. If you are building an on-device AI app of your own, or you want a studio that has shipped this kind of thing to the App Store and Google Play, we would like to hear from you: timmy@llmhub.com.au.

on-device AIsleep trackingAI sleep coachmobile AIapp development

Questions

Can a phone track sleep without a wearable?

Yes. A phone can track sleep using its own sensors: the accelerometer picks up movement through the night, and the microphone picks up sound, such as snoring or a restless room. OpenSleep, for example, uses motion plus sound in 30-second epochs to build a picture of the night, with no wearable and no server involved. A phone is not a medical device, so the results are a useful guide to sleep patterns, not a diagnosis.

How does an on-device AI sleep coach work?

The coach is a language model running on the phone itself. In OpenSleep it is a Gemma model running on LiteRT-LM, the on-device runtime for phones. It reads the sleep data the phone collected, looks for patterns — late bedtimes, short nights, restless periods — and talks to the user about them in plain language. Because the model runs locally, the conversation never leaves the device.

Does an on-device sleep coach need the internet?

No. Once the app and its model are on the phone, tracking and coaching work with no signal at all. That is the point of building it on-device: the bedroom is exactly the place where people put their phones on airplane mode, and a sleep coach that stops working when the Wi-Fi drops is a coach that fails on the nights it matters most.

Is a sleep coach app medical advice?

No — and any honest app should say so clearly. An on-device sleep coach gives general wellness information: patterns in your own sleep data, and general guidance about sleep habits. It cannot diagnose a sleep disorder, and it should not try. If your sleep is seriously disrupted, or you suspect a condition such as sleep apnoea, the right next step is a clinician, not an app.

What should I look for in a sleep tracking app?

Three things. First, where your data goes: an app that tracks sleep on the phone and sends nothing to a server keeps the most personal data you have — your nights — off the internet. Second, whether it needs extra hardware: a phone-only tracker works with the device you already own. Third, whether the coaching is honest about its limits: general guidance about sleep habits is useful; claims to detect or diagnose conditions are not.

Can a sleep app sync with Apple Health or Google Health Connect?

Yes. OpenSleep syncs with Apple Health and Google Health Connect, so sleep data recorded on the phone can sit alongside the rest of a person's health data. The sync happens on the device, and it does not require the app to run its own servers.