Package com.google.genai.types
Class Content
java.lang.Object
com.google.genai.JsonSerializable
com.google.genai.types.Content
Contains the multi-part content of a message.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Content.Builder
builder()
Instantiates a builder for Content.static Content
Deserializes a JSON string to a Content object.static Content
Constructs a Content from parts, assuming the role is "user".parts()
List of parts that constitute a single message.role()
Optional.@Nullable String
text()
Returns the concatenation of all text parts in this content.abstract Content.Builder
Creates a builder with the same values as this instance.Methods inherited from class com.google.genai.JsonSerializable
stringToJsonNode, toJson
-
Constructor Details
-
Content
public Content()
-
-
Method Details
-
parts
List of parts that constitute a single message. Each part may have a different IANA MIME type. -
role
Optional. The producer of the content. Must be either 'user' or 'model'. Useful to set for multi-turn conversations, otherwise can be empty. If role is not specified, SDK will determine the role. -
builder
Instantiates a builder for Content. -
toBuilder
Creates a builder with the same values as this instance. -
fromJson
Deserializes a JSON string to a Content object. -
fromParts
Constructs a Content from parts, assuming the role is "user". -
text
Returns the concatenation of all text parts in this content.Returns null if there are no parts in the content. Returns an empty string if parts exists but none of the parts contain text.
-