ContentPart

@Serializable
sealed interface ContentPart

One element of a UserMessage's multimodal content array.

A user message carries either plain text or a list of these parts. The concrete subtypes — TextPart, ImageUrlPart, FilePart — are distinguished on the wire by the type discriminator.

Both models the API serves read images, so no separate vision model is needed. A model that cannot replace them with a placeholder text rather than failing. The API rejects image parts in system and assistant messages, which is why parts are only available on UserMessage.

Prefer the user { ... } DSL over instantiating parts directly:

client.chat {
user {
text("What is in this image?")
image("https://example.com/cat.jpg", ImageDetail.LOW)
}
}

See also

Inheritors