-
-
The giraffe, the name, the tagline, and the Today and Go down phone screens
-
30–40%, 75%, 72 deaths and 2,500 m, each with its source.
-
The web and mobile plan with callouts for the ascent rule, AI fill and the QR code.
-
The eval bars, 30/30 medicine questions, and 208 + 24 tests.
-
The saved map, the offline result, and the "Where AI ran" log.
-
Her Spanish quote and three screens (check, heel-to-toe walk, Spanish result).
-
The go-down, way-down and incident-log screens.
-
The family follow page, the agency report and the medicine answer.
-
The three lanes (Gemini Nano, fixed code, Gemini cloud)
-
The 6-step check pipeline.
Thin Air Buddy
Know when to go down, even with no signal.
Thin Air Buddy is an altitude-sickness buddy for anyone going high: trekkers, road trips over high passes, cable cars into thin air, solo or with a whole group. It checks everyone, in their own words and their own language, and says clearly when it's time to go down, even days from a road with no signal. Built on Firebase AI Logic hybrid inference: Gemini Nano on the phone when the job is private or offline, Gemini in the cloud when there is signal and the job is heavy, and published medical rules for every verdict. Android on the trail, the web at home.
Inspiration
The cure for altitude sickness is simple: go down.
Up to 30–40% of trekkers above 4,000 m get altitude sickness, and it can start at 2,500 m. On Kilimanjaro, 75% of one group got it, mostly from climbing too fast. Nepal counted 257 altitude-sickness incidents and 72 deaths in six years. And it isn't only trekkers: a jeep over a Ladakh pass or a cable car to 4,500 m puts people in the same thin air in hours.
The deaths happen in the gap between knowing and deciding. The decision comes at night, days from a road, with no signal, and the sick person is the last to notice, because brain swelling (HACE) causes confusion. Guides already check their clients twice a day, on paper. A group isn't safe by itself either: in a classic Nepal study, 8 of 10 altitude deaths happened in organized groups.
We wanted the guide's check, done the same way every time, for every person, in their own language, on the phone that's already in their pocket, and working in exactly the place where nothing else does.
What it does
| Thin Air Buddy | What it does | Why it matters |
|---|---|---|
| 1 · Plan any trip | Pick a route, type the days, or paste any itinerary in any words. Gemini fills every day, the app adds the altitudes, and the chart flags every night that climbs too fast. | Climbing too fast is the #1 cause. It's caught at home, before anyone leaves. |
| 2 · No plan? No problem. | Planning is optional. Open the app and go: Today is home. GPS records where you really sleep each night, tonight's altitude fills itself in on arrival, the ascent rules run on your real track, and anyone can be checked at any moment. A plan, if you make one, can be added any time, even mid-trip. | Real trips change, and plenty of people never plan at all. The safety net works either way. |
| 3 · Ready for no signal | One tap saves the places, the night temperatures and the map on the phone. With no signal, Gemini Nano fills plans on the device. | The app is built for exactly where the network ends. |
| 4 · GPS as evidence | GPS records the way up, the real sleeping altitude every night and where the signal worked, with no internet. When signal returns, the cloud re-checks the plan. | Sleeping altitude is what the rules count, and it's measured, not guessed. |
| 5 · Check anyone, offline | Sofia says how she feels, in Spanish. Gemini Nano reads her words on the phone into the four official Lake Louise symptoms; code scores them with a guided heel-to-toe walk; Nano explains the verdict in her language. | The sick person can't judge themselves, so anyone can check anyone, in under four seconds. |
| 6 · Go down now | A danger sign (confused, can't walk straight) switches the app into a descent guide: the way down on the saved map, oxygen time left, a timed incident log, a handover card for rescuers, and the nearest spot where data worked. | The right action, instantly, when the person in charge is scared and cold. |
| 7 · Evacuation first | At the first bar of signal, the outbox sends by itself, in order: evacuation request, checks, questions. | The message that saves a life never waits behind a photo upload. |
| 8 · Family and agency follow | Sofia's daughter reads an update in Spanish, written by Gemini in the cloud; the agency gets a cloud-drafted incident report to approve. | People at home know, and the evacuation has an honest record. |
| 9 · Proof of where AI ran | The Where AI ran panel logs every AI call: what, where, and how long. The eval page runs the same tests through both engines. | Hybrid you can see and check, not just claim. |
How we used Firebase AI Logic
The reason for hybrid comes from the user's situation: no signal up high, health data in every check, and heavy jobs that need the cloud. So every job has one right place, chosen by our own router from one shared policy, and every call goes through Firebase AI Logic with one model instance per mode:
| Job | Where | Mode | Why |
|---|---|---|---|
| Her words → 4 symptom scores, one follow-up, the plain-words explanation, incident-log events, the handover card | 🟢 Gemini Nano, on the phone | ONLY_ON_DEVICE + our own feature-detect guard |
Health words are private and there is no signal. No Nano → a 4-question tap form, never a silent cloud call |
| A plan from any text | 🔵 Cloud with signal · 🟢 Nano offline | PREFER_IN_CLOUD |
No health data; the AI names places, the gazetteer and elevation grid give the altitudes |
| Plan re-check, medicine questions, family updates in their language, trip review, incident report, itinerary photos | 🔵 Gemini 3.5 Flash-Lite / 3.8 Flash | ONLY_IN_CLOUD, automatically when signal returns |
Bigger model or live data; it receives codes, scores and places, never names, words or the trail |
| Lake Louise score, danger signs, walk and breath tests, ascent rules, sleeping altitude, oxygen time, descent ETA | ⚪ Fixed code | no AI | Published guidelines, the same golden tests on web and Android |
We never use PREFER_ON_DEVICE: its silent cloud fallback is exactly what health text must never get. The same JSON schema is used on both sides (responseConstraint on the device, responseJsonSchema in the cloud). App Check (reCAPTCHA Enterprise, Play Integrity), Cloud Firestore (offline outbox and follow page), Remote Config (thresholds, routing, prompts), Anonymous Auth and Hosting complete the Firebase side.
Every AI job in the app
Twelve jobs, each with its own mode, schema and fallback, all routed by one policy shared by Android and the web (shared/rules/defaults.json):
| # | Job | When it runs | Firebase AI Logic mode · model | Output (JSON schema) | If it can't run |
|---|---|---|---|---|---|
| 1 | Words → symptoms | Every check | ONLY_ON_DEVICE · Gemini Nano |
symptoms: 4 Lake Louise scores, hints, “unclear” |
4-question tap form |
| 2 | Follow-up question | Only when the words are unclear | ONLY_ON_DEVICE · Gemini Nano |
followup: which symptom, one question |
Tap form |
| 3 | Explain the result | After every verdict | ONLY_ON_DEVICE · Gemini Nano |
explain: title + plain words, in their language |
Fixed template text |
| 4 | Incident log | Spoken or typed notes during the descent | ONLY_ON_DEVICE · Gemini Nano |
incident: timed events (oxygen, medicine, notes); any number that wasn't said becomes “?” |
Note saved as typed |
| 5 | Handover card | For the clinic or helicopter crew | ONLY_ON_DEVICE · Gemini Nano |
explain: sentences from code facts only |
Fixed template card |
| 6 | Plan from text | Typed, spoken or pasted itinerary | PREFER_IN_CLOUD · 3.5 Flash-Lite, Gemini Nano offline (20 s budget) |
planFill: days, places, rest days |
Manual editor |
| 7 | Plan from a photo | A printed or handwritten itinerary | ONLY_IN_CLOUD · 3.5 Flash-Lite, image input |
planFill |
Waits for signal |
| 8 | Plan re-check | Automatically when signal returns | ONLY_IN_CLOUD · 3.8 Flash + Google Maps grounding, fed the plan, the code's rule warnings and ~150 tokens of track facts |
recheck: note + up to 3 code-validated fixes, one tap to apply |
Queued until signal |
| 9 | Medicine questions | “Can I take ibuprofen with my pill?” | ONLY_IN_CLOUD · 3.5 Flash-Lite + Google Search grounding |
medAnswer: answer + caution, in their language |
Queued, never answered offline |
| 10 | Family update | Each time new checks reach the cloud | ONLY_IN_CLOUD · 3.5 Flash-Lite |
summary: in the follower's language |
Codes and scores shown as they are |
| 11 | Trip review | For followers, per person | ONLY_IN_CLOUD · 3.5 Flash-Lite |
summary |
Scores shown as they are |
| 12 | Incident report draft | Automatically when an evacuation request syncs | ONLY_IN_CLOUD · 3.8 Flash |
report: summary + timeline, for the agency to approve |
A draft from the phone records, no AI |
What we built on top of the SDK
The SDK picks the engine only by availability. Our router (inferenceRouter.ts, FirebaseAiLogicInference.kt) adds the rest:
- Privacy guard, before and after. We check Nano is really on the device, and drop any on-device answer whose
inferenceSourceisn'tON_DEVICE. Health words never fall back to the cloud. - Routing by content. Prompts over ~1,000 tokens go to the cloud if they hold no health data; health prompts are trimmed and stay on the phone.
- Fallbacks both ways. Slow Nano → cloud, slow cloud → Nano, busy 3.8 Flash → 3.5 Flash-Lite, no signal → the outbox.
- One schema, both engines, validated before use. Maps and Search grounding with sources.
- Fast Nano: downloaded on a tap, warmed at app start, per-job timeouts.
- Visible: a device/cloud badge on every result, and every call logged in Where AI ran.
- Remote Config updates routing and prompts without a release; App Check guards every call.
One check, offline
- Listen. The person (or whoever is with them) speaks or types. The first question uses their last check: “At 12:20 you had a moderate headache. Better, same or worse?”
- Danger words first. Code scans for confusion, can't walk straight, breathless at rest, before any AI call.
- Words → symptoms. Gemini Nano,
ONLY_ON_DEVICE, returns the four Lake Louise symptoms as JSON. One follow-up only if unclear; every score can be corrected with a tap. - Score and tests. Code computes the 2018 Lake Louise score with the heel-to-toe walk and breath count.
- Verdict. OK · don't go higher (with a night re-check alarm) · go down now. The rule that fired is always shown.
- Explain. Gemini Nano writes plain words in her language, with an English line for the guide.
At most 3 Nano calls per check, prompts under ~1,000 tokens, and the GPS track reaches a model only as ~150 tokens of “track facts”.
Product walkthrough
![]() 1 · Plan at home. The chart flags the night that climbs too fast; Gemini fills any itinerary. |
![]() Ready for no signal. Map saved; offline, Gemini Nano gives the same result, and the app's log proves it. |
![]() 2 · On the phone. One QR scan, GPS records the way up, the cloud re-checks the plan. |
![]() 3 · Check everyone, offline. Her Spanish words → Gemini Nano → Lake Louise → don't go higher. |
![]() 4 · When it's serious. The way down, oxygen left, an incident log, a handover card. |
![]() 5 · Back in signal. The evacuation leaves first; the cloud answers, translates and drafts the report. |
| Today, on the trail | Check, in her language | Go down now | The way down |
|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
| Plan any trip (web) | Family follows, in Spanish (web) |
|---|---|
![]() |
![]() |
How we built it
| Technology | Role |
|---|---|
| Firebase AI Logic | All AI: Gemini Nano on the device (Chrome's built-in model on the web, on-device Gemini Nano on Android), Gemini 3.5 Flash-Lite and 3.8 Flash in the cloud. |
| App Check · Anonymous Auth | reCAPTCHA Enterprise and Play Integrity; no account, no email. |
| Cloud Firestore | The offline outbox (evacuation first) and the follow page. |
| Remote Config | Thresholds, routing policy and the prompt pack, so rules can be tuned without a release. |
| Firebase Hosting | The web app at thinairbuddy.web.app. |
| Android · Kotlin, Jetpack Compose | On the trail: GPS, barometer, signal log, ZXing QR pairing offline, re-check alarms. |
| Web · React 19.3, Vite 8.3 PWA, TypeScript | Plan at home, the follow page, the full check flow in Chrome, the eval page. |
| MapLibre · Protomaps · OpenFreeMap · Open-Meteo | Offline maps, place search, the elevation grid and night-low forecasts. |
shared/ |
One source of truth for both apps: rules, prompts, 12 JSON schemas, routes and an offline gazetteer, and the eval fixtures. |
Measured, not assumed. On the app's own eval page, the same 60 symptom descriptions (English + Spanish) went through both engines via Firebase AI Logic:
| 🟢 Gemini Nano · on the phone, offline | 🔵 Gemini · cloud, online | |
|---|---|---|
| All 4 symptoms exactly right | 70% | 71.7% |
| Symptom score within ±1 | 93.3% | 95% |
| Danger signs caught | 100% | 100% |
| Time per answer | 2.6 s | 1.2 s |
30 / 30 medicine questions went to the cloud and none were answered on the device. Our Gemini Nano benchmark (267 tokens in 0.8 s → 5,162 tokens in 9.8 s; 7.8 s for the first call) set the token budget, the warm-up at app start and the 3-call limit. 208 web tests and 24 Android tests run the same golden cases.
Challenges we ran into
- Keeping health words on the device, for sure.
ONLY_ON_DEVICEalone wasn't enough on the web, so we added our own feature-detect guard and a test, and moved every health job offPREFER_ON_DEVICE. No Nano means a tap form, never a quiet trip to the cloud. - A small model in a high-stakes job. We let Gemini Nano do what it's great at (understanding words, explaining in plain language) and kept every decision in fixed, tested code. Danger words are found by code before any AI call.
- Fitting Nano's budget. We measured latency against prompt size, then capped prompts at ~1,000 tokens, reused sessions, warmed the model at start, and summarized the GPS track into ~150 tokens of facts.
- Two platforms, one truth. Rules, prompts, schemas and test fixtures live once in
shared/, so Android and the web give the same verdict for the same person. - Signal that comes and goes. The outbox orders everything by priority and the evacuation request always leaves first. The app learns where the signal worked from the group's own track.
Accomplishments that we're proud of
- A complete product on two platforms, Android and the web, from planning at home to a descent at 3,770 m to a family update in Spanish.
- Gemini Nano offline scores almost as well as the cloud on our own eval set, and catches 100% of danger signs.
- Hybrid you can see: a badge on every AI result, and the Where AI ran log one tap away on every screen.
- An honest, timestamped incident record that a clinic or insurer can trust.
What we learned
The most useful thing AI can do at 4,000 m isn't to decide. It's to listen to a frightened, cold person in their own language, turn their words into something a rule can score, and explain the result kindly, all without a signal. The hard engineering lives in the boundaries: what may leave the phone, what must wait for signal, and what only fixed rules may say.
What's next
- More on-device languages as Gemini Nano adds them.
- Bluetooth phone-to-phone sync for the group, and readings from watches and pulse oximeters.
Built during #BuildHybridAI
Thin Air Buddy was designed and built during the submission period (Nov 11–30, 2026): the product, both apps, the shared rules, the eval sets and the film. A few low-level pieces (the Firebase AI Logic adapter, the inference router and the outbox pattern) are shared with our other #BuildHybridAI 2026 entry, Nobody Missing, and were adapted here.
Try it
- Live app: thinairbuddy.web.app in Chrome on a desktop or laptop. Open the Simulator rail on the right edge to plan a trip, add made-up people, walk the group up, lose the signal, and run a check; then Back home → Open the family view.
- Source: github.com/azharizz/ThinAirBuddy (Apache-2.0), with build steps for the web and Android apps.
Decision support from published guidelines (2018 Lake Louise AMS Score, WMS 2024); not a medical device: a guide or doctor decides. All people in the demo are made up.
Built With
- android
- chrome
- cloud-firestore
- firebase
- firebase-ai-logic
- firebase-app-check
- firebase-authentication
- firebase-hosting
- firebase-remote-config
- gemini
- gemini-nano
- jetpack-compose
- kotlin
- maplibre
- open-meteo
- openfreemap
- openstreetmap
- protomaps
- pwa
- react
- typescript
- vite
- vitest
- zxing












