ModelContent
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct ModelContent : Equatable, Sendable
extension ModelContent: Codable
A type describing data in media formats interpretable by an AI model. Each generative AI
request or response contains an Array
of ModelContent
s, and each ModelContent
value
may comprise multiple heterogeneous Part
s.
-
The role of the entity creating the
ModelContent
. For user-generated client requests, for example, the role isuser
.Declaration
Swift
public let role: String?
-
The data parts comprising this
ModelContent
value.Declaration
Swift
public var parts: [any Part] { get }
-
Creates a new value from any data interpretable as a
Part
. SeePartsRepresentable
for types that can be interpreted asPart
s.Declaration
Swift
public init(role: String? = "user", parts: any PartsRepresentable...)