# GenerativeModelFutures


```
abstract class GenerativeModelFutures
```

<br />

*** ** * ** ***

A Java-friendly wrapper for the `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerativeModel` class, providing `https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html` for asynchronous operations.

## Summary

| ### Public companion functions |
|---|---|
| `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#from(com.google.mlkit.genai.prompt.GenerativeModel)(generativeModel: https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerativeModel)` |

| ### Public functions |
|---|---|
| `abstract https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html>` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#checkStatus()()` Checks the current availability status of the content generation feature. |
| `abstract https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/java/lang/Void.html>` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#clearImplicitCaches()()` Clears all caches created by implicit prefix caching. |
| `abstract https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/CountTokensResponse>` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#countTokens(com.google.mlkit.genai.prompt.GenerateContentRequest)(request: https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerateContentRequest)` Counts the number of tokens in the request. |
| `abstract https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/java/lang/Void.html>` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#download(com.google.mlkit.genai.common.DownloadCallback)(callback: https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/common/DownloadCallback)` Downloads the required model assets for the content generation feature if they are not already available. |
| `abstract https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerateContentResponse>` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#generateContent(kotlin.String)(prompt: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Runs a non-streaming inference call to the model for the provided prompt. |
| `abstract https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerateContentResponse>` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#generateContent(com.google.mlkit.genai.prompt.GenerateContentRequest)(request: https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerateContentRequest)` Runs a non-streaming inference call to the model for the provided `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerateContentRequest`. |
| `abstract https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerateContentResponse>` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#generateContent(kotlin.String,com.google.mlkit.genai.common.StreamingCallback)(prompt: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, callback: https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/common/StreamingCallback)` Runs a streaming inference call to the model for the provided prompt. |
| `abstract https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerateContentResponse>` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#generateContent(com.google.mlkit.genai.prompt.GenerateContentRequest,com.google.mlkit.genai.common.StreamingCallback)( request: https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerateContentRequest, callback: https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/common/StreamingCallback )` Runs a streaming inference call to the model for the provided `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerateContentRequest`. |
| `abstract https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html>>` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#getAvailableFeatures()()` Returns the list of features (capabilities) available for this model. |
| `abstract https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#getBaseModelName()()` Returns the name of the base model used by this generator instance. |
| `abstract https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerativeModel` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#getGenerativeModel()()` Returns the underlying `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerativeModel` instance that was used to create this object. |
| `abstract https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html>` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#getTokenLimit()()` Returns total token limit for the API including both input and output tokens. |
| `abstract https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html>` | `[isSystemPromptAvailable](https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#isSystemPromptAvailable())()` **This function is deprecated.** Use getAvailableFeatures() instead. |
| `abstract https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html>` | `[isThinkingModeAvailable](https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#isThinkingModeAvailable())()` **This function is deprecated.** Use getAvailableFeatures() instead. |
| `abstract https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/java/lang/Void.html>` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#warmup()()` Warms up the inference engine for use by loading necessary models. |

## Public companion functions

### from

```
fun from(generativeModel: GenerativeModel): GenerativeModelFutures
```

| Parameters |
|---|---|
| `generativeModel: https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerativeModel` | the `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerativeModel` instance to wrap. |

| Returns |
|---|---|
| `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures` | a `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures` created around the provided `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerativeModel` instance. |

## Public functions

### checkStatus

```
abstract fun checkStatus(): ListenableFuture<Int>
```

Checks the current availability status of the content generation feature.

### clearImplicitCaches

```
abstract fun clearImplicitCaches(): ListenableFuture<Void>
```

Clears all caches created by implicit prefix caching.

This experimental method clears all caches created by implicit prefix caching. When `promptPrefix` is provided in `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerateContentRequest`, the system caches its processing implicitly to reduce inference time for subsequent requests sharing the same prefix. This method clears all such created caches.

### countTokens

```
abstract fun countTokens(request: GenerateContentRequest): ListenableFuture<CountTokensResponse>
```

Counts the number of tokens in the request.

The number of tokens counted includes input and output tokens. The result can be compared with `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#getTokenLimit()` to check if the request is within the token limit.

| Parameters |
|---|---|
| `request: https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerateContentRequest` | a non-null `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerateContentRequest` containing input content. |

| Returns |
|---|---|
| `https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/CountTokensResponse>` | a `https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html` resolving to a `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/CountTokensResponse`. |

### download

```
abstract fun download(callback: DownloadCallback): ListenableFuture<Void>
```

Downloads the required model assets for the content generation feature if they are not already available.

### generateContent

```
abstract fun generateContent(prompt: String): ListenableFuture<GenerateContentResponse>
```

Runs a non-streaming inference call to the model for the provided prompt.

### generateContent

```
abstract fun generateContent(request: GenerateContentRequest): ListenableFuture<GenerateContentResponse>
```

Runs a non-streaming inference call to the model for the provided `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerateContentRequest`.

### generateContent

```
abstract fun generateContent(prompt: String, callback: StreamingCallback): ListenableFuture<GenerateContentResponse>
```

Runs a streaming inference call to the model for the provided prompt.

| Parameters |
|---|---|
| `prompt: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | the input prompt text. |
| `callback: https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/common/StreamingCallback` | the callback to receive streaming results. |

| Returns |
|---|---|
| `https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerateContentResponse>` | a `https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html` that completes with the final `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerateContentResponse`. |

### generateContent

```
abstract fun generateContent(
    request: GenerateContentRequest,
    callback: StreamingCallback
): ListenableFuture<GenerateContentResponse>
```

Runs a streaming inference call to the model for the provided `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerateContentRequest`.

| Parameters |
|---|---|
| `request: https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerateContentRequest` | the request containing the prompt of text and images. |
| `callback: https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/common/StreamingCallback` | the callback to receive streaming results. |

| Returns |
|---|---|
| `https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerateContentResponse>` | A `https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html` that completes with the final `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerateContentResponse`. |

### getAvailableFeatures

```
abstract fun getAvailableFeatures(): ListenableFuture<List<Int>>
```

Returns the list of features (capabilities) available for this model.

| Returns |
|---|---|
| `https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html>>` | a `https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html` resolving to the list of available features. |

### getBaseModelName

```
abstract fun getBaseModelName(): ListenableFuture<String>
```

Returns the name of the base model used by this generator instance.

### getGenerativeModel

```
abstract fun getGenerativeModel(): GenerativeModel
```

Returns the underlying `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerativeModel` instance that was used to create this object.

### getTokenLimit

```
abstract fun getTokenLimit(): ListenableFuture<Int>
```

Returns total token limit for the API including both input and output tokens.

This limit can be used with `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#countTokens(com.google.mlkit.genai.prompt.GenerateContentRequest)` to check if a request is within limits before running inference. The input size returned by `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#countTokens(com.google.mlkit.genai.prompt.GenerateContentRequest)` plusing the output size specified by `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/GenerateContentRequest#maxOutputTokens()` should be no larger than the limit returned by this method.

| Returns |
|---|---|
| `https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html>` | a `https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html` resolving to the token limit. |

### isSystemPromptAvailable

```
abstract fun [isSystemPromptAvailable](https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#isSystemPromptAvailable())(): ListenableFuture<Boolean>
```

> [!CAUTION]
> **This function is deprecated.**   
> Use getAvailableFeatures() instead.

Checks if the system prompt feature is supported on the device.

| Returns |
|---|---|
| `https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html>` | a `https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html` resolving to `true` if the system prompt feature is available, `false` otherwise. |

### isThinkingModeAvailable

```
abstract fun [isThinkingModeAvailable](https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#isThinkingModeAvailable())(): ListenableFuture<Boolean>
```

> [!CAUTION]
> **This function is deprecated.**   
> Use getAvailableFeatures() instead.

Checks if the thinking mode feature is supported on the device.

| Returns |
|---|---|
| `https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html>` | a `https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html` resolving to `true` if the thinking mode feature is available, `false` otherwise. |

### warmup

```
abstract fun warmup(): ListenableFuture<Void>
```

Warms up the inference engine for use by loading necessary models.