OnDeviceExtension

@PublicPreviewAPI
class OnDeviceExtension


Extension class for performing on-device operations.

Summary

Public functions

suspend OnDeviceModelStatus

Checks the current status / availability of the on-device AI model.

Flow<DownloadStatus>

Initiates the download of the on-device AI model.

suspend Unit

Warms up the model to reduce latency for the first request.

Public functions

checkStatus

suspend fun checkStatus(): OnDeviceModelStatus

Checks the current status / availability of the on-device AI model.

Returns
OnDeviceModelStatus

An OnDeviceModelStatus object indicating the current state of the model.

download

fun download(): Flow<DownloadStatus>

Initiates the download of the on-device AI model.

Returns
Flow<DownloadStatus>

A Flow of DownloadStatus objects representing the download lifecycle.

warmUp

suspend fun warmUp(): Unit

Warms up the model to reduce latency for the first request.

Throws
com.google.firebase.ai.type.FirebaseAIException: com.google.firebase.ai.type.FirebaseAIException

if the warmup failed.