Content

classContent


Represents content sent to and received from the model.

Content is composed of a one or more heterogeneous parts that can be represent data in different formats, like text or images.

Summary

Nested types

Builder class to facilitate constructing complexContent objects.

Public constructors

Content(role: String?, parts: List<Part>)

Public functions

Content
copy(role: String?, parts: List<Part>)

Returns a copy of this object, with the provided parameters overwriting the originals.

Public properties

List<Part>

An ordered list ofPart that constitute this content.

String?

The producer of the content.

Public constructors

Content

Content(role: String? = "user", parts: List<Part>)
Parameters
role: String? = "user"

The producer of the content. Must be either"user" or"model". By default, it's"user".

parts: List<Part>

An ordered list ofPart that constitute this content.

Public functions

copy

fun copy(role: String? = this.role, parts: List<Part> = this.parts): Content

Returns a copy of this object, with the provided parameters overwriting the originals.

Public properties

parts

val partsList<Part>

An ordered list ofPart that constitute this content.

role

val roleString?

The producer of the content. Must be either"user" or"model". By default, it's"user".

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-21 UTC.