OnDeviceExtension

@PublicPreviewAPI
public final class OnDeviceExtension


Extension class for performing on-device operations.

Summary

Public methods

final @NonNull OnDeviceModelStatus

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

final @NonNull Flow<@NonNull DownloadStatus>

Initiates the download of the on-device AI model.

final @NonNull String

Returns the name of the on-device model.

final void

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

Public methods

checkStatus

public final @NonNull OnDeviceModelStatus checkStatus()

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

Returns
@NonNull OnDeviceModelStatus

An OnDeviceModelStatus object indicating the current state of the model.

download

public final @NonNull Flow<@NonNull DownloadStatusdownload()

Initiates the download of the on-device AI model.

Returns
@NonNull Flow<@NonNull DownloadStatus>

A Flow of DownloadStatus objects representing the download lifecycle.

getModelName

public final @NonNull String getModelName()

Returns the name of the on-device model.

warmUp

public final void warmUp()

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.