# PromptPrefix


```
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/kotlin/com/google/mlkit/genai/prompt/PromptPrefix` for the static part of your prompt and `https://developers.google.com/android/reference/kotlin/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/kotlin/com/google/mlkit/genai/prompt/PromptPrefix#PromptPrefix(kotlin.String)(textString: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` |

| ### Public functions |
|---|---|
| `operator https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/PromptPrefix#component1()()` Kotlin destructuring operator returning `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/PromptPrefix#textString()`. |
| `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/PromptPrefix` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/PromptPrefix#copy(kotlin.String)(textString: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Creates a copy of this `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/PromptPrefix` with an updated `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/PromptPrefix#copy(kotlin.String)`, preserving internal prefix caching configuration. |
| `open operator https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/PromptPrefix#equals(kotlin.Any)(other: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html?)` |
| `open https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/PromptPrefix#hashCode()()` |
| `open https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/PromptPrefix#toString()()` |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/PromptPrefix#textString()` The static text prefix to cache. |

## Public constructors

### PromptPrefix

```
PromptPrefix(textString: String)
```

| Parameters |
|---|---|
| `textString: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | The static text prefix to cache. |

## Public functions

### component1

```
operator fun component1(): String
```

Kotlin destructuring operator returning `https://developers.google.com/android/reference/kotlin/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/kotlin/com/google/mlkit/genai/prompt/PromptPrefix`.

### copy

```
fun copy(textString: String = this.textString): PromptPrefix
```

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

### equals

```
open operator fun equals(other: Any?): Boolean
```

### hashCode

```
open fun hashCode(): Int
```

### toString

```
open fun toString(): String
```

## Public properties

### textString

```
val textString: String
```

The static text prefix to cache.