# GenerativeModelFutures


```
public abstract class GenerativeModelFutures
```

<br />

*** ** * ** ***

A Java-friendly wrapper for the `https://developers.google.com/android/reference/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 methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developers.google.com/android/reference/com/google/mlkit/genai/common/FeatureStatus @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/Integer.html>` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#checkStatus()()` Checks the current availability status of the content generation feature. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/Void.html>` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#clearImplicitCaches()()` Clears all caches created by implicit prefix caching. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/CountTokensResponse>` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#countTokens(com.google.mlkit.genai.prompt.GenerateContentRequest)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest request)` Counts the number of tokens in the request. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/Void.html>` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#download(com.google.mlkit.genai.common.DownloadCallback)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/common/DownloadCallback callback)` Downloads the required model assets for the content generation feature if they are not already available. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/GenerativeModelFutures` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#from(com.google.mlkit.genai.prompt.GenerativeModel)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerativeModel generativeModel)` |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentResponse>` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#generateContent(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html prompt)` Runs a non-streaming inference call to the model for the provided prompt. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentResponse>` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#generateContent(com.google.mlkit.genai.prompt.GenerateContentRequest)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest request)` Runs a non-streaming inference call to the model for the provided `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest`. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentResponse>` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#generateContent(kotlin.String,com.google.mlkit.genai.common.StreamingCallback)( @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html prompt, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/common/StreamingCallback callback )` Runs a streaming inference call to the model for the provided prompt. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentResponse>` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#generateContent(com.google.mlkit.genai.prompt.GenerateContentRequest,com.google.mlkit.genai.common.StreamingCallback)( @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest request, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/common/StreamingCallback callback )` Runs a streaming inference call to the model for the provided `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest`. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/Integer.html>>` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#getAvailableFeatures()()` Returns the list of features (capabilities) available for this model. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html>` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#getBaseModelName()()` Returns the name of the base model used by this generator instance. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerativeModel` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#getGenerativeModel()()` Returns the underlying `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerativeModel` instance that was used to create this object. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/Integer.html>` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#getTokenLimit()()` Returns total token limit for the API including both input and output tokens. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/Boolean.html>` | `[isSystemPromptAvailable](https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#isSystemPromptAvailable())()` **This method is deprecated.** Use getAvailableFeatures() instead. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/Boolean.html>` | `[isThinkingModeAvailable](https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#isThinkingModeAvailable())()` **This method is deprecated.** Use getAvailableFeatures() instead. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/Void.html>` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#warmup()()` Warms up the inference engine for use by loading necessary models. |

## Public methods

### checkStatus

```
public abstract @NonNull ListenableFuture<@FeatureStatus @NonNull Integer> checkStatus()
```

Checks the current availability status of the content generation feature.

### clearImplicitCaches

```
public abstract @NonNull ListenableFuture<@NonNull Void> clearImplicitCaches()
```

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/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

```
public abstract @NonNull ListenableFuture<@NonNull CountTokensResponse> countTokens(@NonNull GenerateContentRequest request)
```

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/com/google/mlkit/genai/prompt/java/GenerativeModelFutures#getTokenLimit()` to check if the request is within the token limit.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest request` | a non-null `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest` containing input content. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/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/com/google/mlkit/genai/prompt/CountTokensResponse`. |

### download

```
public abstract @NonNull ListenableFuture<@NonNull Void> download(@NonNull DownloadCallback callback)
```

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

### from

```
public static final @NonNull GenerativeModelFutures from(@NonNull GenerativeModel generativeModel)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerativeModel generativeModel` | the `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerativeModel` instance to wrap. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/GenerativeModelFutures` | a `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/java/GenerativeModelFutures` created around the provided `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerativeModel` instance. |

### generateContent

```
public abstract @NonNull ListenableFuture<@NonNull GenerateContentResponse> generateContent(@NonNull String prompt)
```

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

### generateContent

```
public abstract @NonNull ListenableFuture<@NonNull GenerateContentResponse> generateContent(@NonNull GenerateContentRequest request)
```

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

### generateContent

```
public abstract @NonNull ListenableFuture<@NonNull GenerateContentResponse> generateContent(
    @NonNull String prompt,
    @NonNull StreamingCallback callback
)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html prompt` | the input prompt text. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/common/StreamingCallback callback` | the callback to receive streaming results. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/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/com/google/mlkit/genai/prompt/GenerateContentResponse`. |

### generateContent

```
public abstract @NonNull ListenableFuture<@NonNull GenerateContentResponse> generateContent(
    @NonNull GenerateContentRequest request,
    @NonNull StreamingCallback callback
)
```

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

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

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/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/com/google/mlkit/genai/prompt/GenerateContentResponse`. |

### getAvailableFeatures

```
public abstract @NonNull ListenableFuture<@NonNull List<@NonNull Integer>> getAvailableFeatures()
```

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

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/Integer.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

```
public abstract @NonNull ListenableFuture<@NonNull String> getBaseModelName()
```

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

### getGenerativeModel

```
public abstract @NonNull GenerativeModel getGenerativeModel()
```

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

### getTokenLimit

```
public abstract @NonNull ListenableFuture<@NonNull Integer> getTokenLimit()
```

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/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/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/com/google/mlkit/genai/prompt/GenerateContentRequest#maxOutputTokens()` should be no larger than the limit returned by this method.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/Integer.html>` | a `https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html` resolving to the token limit. |

### isSystemPromptAvailable

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

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

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

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/Boolean.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

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

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

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

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://guava.dev/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/Boolean.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

```
public abstract @NonNull ListenableFuture<@NonNull Void> warmup()
```

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