# PromptPrefix


```
public final class PromptPrefix
```

<br />

*** ** * ** ***

Represents a prompt prefix for on-device prompt caching.

By providing the shared prefix, the system can cache the processing of this prefix on supported devices, potentially reducing inference time. To enable prefix caching, use `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/PromptPrefix` for the static part of your prompt and `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/TextPart` for the dynamic part.

Note: Pre-processing the prefix may introduce a small amount of one-time latency. It's recommended to only use this for prefixes that are expected to be used multiple times.

## Summary

| ### Public constructors |
|---|
| `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/PromptPrefix#PromptPrefix(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html textString)` |

| ### Public methods |
|---|---|
| `final @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/PromptPrefix#component1()()` Kotlin destructuring operator returning `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/PromptPrefix#textString()`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/PromptPrefix` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/PromptPrefix#copy(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html textString)` Creates a copy of this `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/PromptPrefix` with an updated `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/PromptPrefix#copy(kotlin.String)`, preserving internal prefix caching configuration. |
| `boolean` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/PromptPrefix#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final @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/PromptPrefix#getTextString()()` The static text prefix to cache. |
| `int` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/PromptPrefix#hashCode()()` |
| `@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/PromptPrefix#toString()()` |

## Public constructors

### PromptPrefix

```
public PromptPrefix(@NonNull String textString)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html textString` | The static text prefix to cache. |

## Public methods

### component1

```
public final @NonNull String component1()
```

Kotlin destructuring operator returning `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/PromptPrefix#textString()`.

Retained for binary backwards compatibility with the previous `data class` definition of `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/PromptPrefix`.

### copy

```
public final @NonNull PromptPrefix copy(@NonNull String textString)
```

Creates a copy of this `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/PromptPrefix` with an updated `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/PromptPrefix#copy(kotlin.String)`, preserving internal prefix caching configuration.

### equals

```
public boolean equals(Object other)
```

### getTextString

```
public final @NonNull String getTextString()
```

The static text prefix to cache.

### hashCode

```
public int hashCode()
```

### toString

```
public @NonNull String toString()
```