# GenerateContentRequestKt


```
public final class GenerateContentRequestKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequestKt#generateContentRequest(com.google.mlkit.genai.prompt.Content,kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/Content content, @https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-extension-function-type/index.html @https://developer.android.com/reference/androidx/annotation/NonNull.html Function1<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest.Builder, https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html> init )` Helper method to construct a `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest` in a DSL-like manner. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequestKt#generateContentRequest(com.google.mlkit.genai.prompt.TextPart,kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/TextPart text, @https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-extension-function-type/index.html @https://developer.android.com/reference/androidx/annotation/NonNull.html Function1<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest.Builder, https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html> init )` Helper method to construct a `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest` in a DSL-like manner. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequestKt#generateContentRequest(com.google.mlkit.genai.prompt.ImagePart,com.google.mlkit.genai.prompt.TextPart,kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/ImagePart image, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/TextPart text, @https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-extension-function-type/index.html @https://developer.android.com/reference/androidx/annotation/NonNull.html Function1<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest.Builder, https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html> init )` Helper method to construct a `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest` in a DSL-like manner. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequestKt#generateContentRequest(com.google.mlkit.genai.prompt.SystemInstruction,com.google.mlkit.genai.prompt.Content,kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/SystemInstruction systemInstruction, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/Content content, @https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-extension-function-type/index.html @https://developer.android.com/reference/androidx/annotation/NonNull.html Function1<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest.Builder, https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html> init )` Helper method to construct a `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest` in a DSL-like manner. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequestKt#generateContentRequest(com.google.mlkit.genai.prompt.SystemInstruction,com.google.mlkit.genai.prompt.TextPart,kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/SystemInstruction systemInstruction, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/TextPart text, @https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-extension-function-type/index.html @https://developer.android.com/reference/androidx/annotation/NonNull.html Function1<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest.Builder, https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html> init )` Helper method to construct a `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest` in a DSL-like manner. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest` | `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequestKt#generateContentRequest(com.google.mlkit.genai.prompt.SystemInstruction,com.google.mlkit.genai.prompt.ImagePart,com.google.mlkit.genai.prompt.TextPart,kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/SystemInstruction systemInstruction, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/ImagePart image, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/TextPart text, @https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-extension-function-type/index.html @https://developer.android.com/reference/androidx/annotation/NonNull.html Function1<@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest.Builder, https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html> init )` Helper method to construct a `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest` in a DSL-like manner. |

## Public methods

### generateContentRequest

```
public static final @NonNull GenerateContentRequest generateContentRequest(
    @NonNull Content content,
    @ExtensionFunctionType @NonNull Function1<@NonNull GenerateContentRequest.Builder, Unit> init
)
```

Helper method to construct a `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest` in a DSL-like manner.

Example Usage:

```
val request = generateContentRequest(
  content {
    image(bitmap1)
    text("Identify this object.")
    text("Does this sound belong to it?")
    image(bitmap2)
    text("How about this one?")
  }
) {
  temperature = 0.5f
}
)
```

### generateContentRequest

```
public static final @NonNull GenerateContentRequest generateContentRequest(
    @NonNull TextPart text,
    @ExtensionFunctionType @NonNull Function1<@NonNull GenerateContentRequest.Builder, Unit> init
)
```

Helper method to construct a `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest` in a DSL-like manner.

Example Usage:

```
// Generation Request with text only:
generateContentRequest(TextPart("Hello World")) {
  temperature = 0.5f
  seed = 123
  topK = 10
  candidateCount = 5
  maxOutputTokens = 200
}
```

### generateContentRequest

```
public static final @NonNull GenerateContentRequest generateContentRequest(
    @NonNull ImagePart image,
    @NonNull TextPart text,
    @ExtensionFunctionType @NonNull Function1<@NonNull GenerateContentRequest.Builder, Unit> init
)
```

Helper method to construct a `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest` in a DSL-like manner.

Example Usage:

```
// Generation Request with image and text:
generateContentRequest(ImagePart(bitmap), TextPart("Hello World")) {
  temperature = 0.5f
  seed = 123
  topK = 10
  candidateCount = 5
  maxOutputTokens = 200
}
```

### generateContentRequest

```
public static final @NonNull GenerateContentRequest generateContentRequest(
    @NonNull SystemInstruction systemInstruction,
    @NonNull Content content,
    @ExtensionFunctionType @NonNull Function1<@NonNull GenerateContentRequest.Builder, Unit> init
)
```

Helper method to construct a `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest` in a DSL-like manner.

Example Usage:

```
// Generation Request with system instruction and content:
generateContentRequest(SystemInstruction("You are a helpful assistant."),
  content {
    image(bitmap1)
    text("Identify this object.")
    text("Does this sound belong to it?")
    image(bitmap2)
    text("How about this one?")
  }
) {
  temperature = 0.5f
}
```

### generateContentRequest

```
public static final @NonNull GenerateContentRequest generateContentRequest(
    @NonNull SystemInstruction systemInstruction,
    @NonNull TextPart text,
    @ExtensionFunctionType @NonNull Function1<@NonNull GenerateContentRequest.Builder, Unit> init
)
```

Helper method to construct a `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest` in a DSL-like manner.

Example Usage:

```
// Generation Request with system instruction and text:
generateContentRequest(SystemInstruction("You are a helpful assistant."), TextPart("Hello World")) {
  temperature = 0.5f
  seed = 123
  topK = 10
  candidateCount = 5
  maxOutputTokens = 200
  enableThinking = true
}
```

### generateContentRequest

```
public static final @NonNull GenerateContentRequest generateContentRequest(
    @NonNull SystemInstruction systemInstruction,
    @NonNull ImagePart image,
    @NonNull TextPart text,
    @ExtensionFunctionType @NonNull Function1<@NonNull GenerateContentRequest.Builder, Unit> init
)
```

Helper method to construct a `https://developers.google.com/android/reference/com/google/mlkit/genai/prompt/GenerateContentRequest` in a DSL-like manner.

Example Usage:

```
// Generation Request with system instruction, image, and text:
generateContentRequest(
  SystemInstruction("You are a helpful assistant."),
  ImagePart(bitmap),
  TextPart("Hello World"),
) {
  temperature = 0.5f
  seed = 123
  topK = 10
  candidateCount = 5
  maxOutputTokens = 200
  enableThinking = true
}
```