# OnDeviceExtension


```
@PublicPreviewAPI
class OnDeviceExtension
```

<br />

*** ** * ** ***

Extension class for performing on-device operations.

## Summary

| ### Public functions |
|---|---|
| `suspend https://firebase.google.com/docs/reference/kotlin/com/google/firebase/ai/OnDeviceModelStatus` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/ai/OnDeviceExtension#checkStatus()()` Checks the current status / availability of the on-device AI model. |
| `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<https://firebase.google.com/docs/reference/kotlin/com/google/firebase/ai/DownloadStatus>` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/ai/OnDeviceExtension#download()()` Initiates the download of the on-device AI model. |
| `suspend https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/ai/OnDeviceExtension#getModelName()()` Returns the name of the on-device model. |
| `suspend https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/ai/OnDeviceExtension#warmUp()()` 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 |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/ai/OnDeviceModelStatus` | An `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/ai/OnDeviceModelStatus` object indicating the current state of the model. |

### download

```
fun download(): Flow<DownloadStatus>
```

Initiates the download of the on-device AI model.

| Returns |
|---|---|
| `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<https://firebase.google.com/docs/reference/kotlin/com/google/firebase/ai/DownloadStatus>` | A `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html` of `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/ai/DownloadStatus` objects representing the download lifecycle. |

### getModelName

```
suspend fun getModelName(): String
```

Returns the name of the on-device model.

### warmUp

```
suspend fun warmUp(): Unit
```

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

| Throws |
|---|---|
| `com.google.firebase.ai.type.FirebaseAIException: https://firebase.google.com/docs/reference/kotlin/com/google/firebase/ai/type/FirebaseAIException` | if the warmup failed. |