In Local Means Local: Test Firebase AI Logic Fallback Before Dispatch, Raju Dandigam uses a TypeScript example to test whether a web app honors a user's choice about where a prompt can be processed. The example draws a concrete distinction between a button that promises local inference and a setting that starts locally but allows a cloud fallback.
Decide whether the prompt may leave the device
Firebase AI Logic's ONLY_ON_DEVICE mode raises an error when local inference is unavailable. In PREFER_ON_DEVICE, the SDK may fall back to a cloud-hosted model. A browser availability check can help the app explain what is likely to happen. The inference mode still matters because availability can change between that check and the call.
Dandigam's example requires a current grant before it hands a cloud-capable request to the provider adapter. The grant is tied to the input text and expires. If someone edits their prompt after granting permission, the app asks for a new decision before sending it through a cloud-capable route. A failure in local-only mode returns to the user without an automatic cloud retry.
Check the decision and the actual route separately
The author's fixture replaces the provider with a function that counts calls. Missing, expired, or mismatched permission should leave that count at zero for a cloud-capable request. The fixture also checks that a local-only failure does not trigger a second call. These checks cover the app's request logic. Dandigam reports no live routing or latency results from them.
A browser test can then cover a device with a usable model, a device without one, and a disconnected session. Record the requested mode and the response's reported inferenceSource when available. If the response does not report a source, leave it unknown. The Firebase web setup guide describes the supported single-turn operations. Model downloads and unrelated network requests need their own checks before an app makes broader claims about privacy.