Content

public final 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

public final classContent.Builder

Builder class to facilitate constructing complexContent objects.

Public fields

final @NonNullList<@NonNullPart>

An ordered list ofPart that constitute this content.

finalString

The producer of the content.

Public constructors

Public methods

final @NonNullContent
copy(String role, @NonNullList<@NonNullPart> parts)

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

Public fields

parts

public final @NonNullList<@NonNullPartparts

An ordered list ofPart that constitute this content.

role

public final String role

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

Public constructors

Content

public Content(String role, @NonNullList<@NonNullPart> parts)
Parameters
String role

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

@NonNullList<@NonNullPart> parts

An ordered list ofPart that constitute this content.

Public methods

copy

public final @NonNullContent copy(String role, @NonNullList<@NonNullPart> parts)

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

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.