public final class ImagePart
- Object
- MessagePart
- ImagePart
Image content within a multimodal
ChatMessage. An image is either
inline encoded bytes with a MIME type or a provider-accessible URL. Inline
bytes are copied on construction and access so later caller mutations
cannot change a request that already contains this part.Constructors
public ImagePart(byte[] data, String mimeType) | Creates an inline image part. |
public ImagePart(String url) | Remote image by URL. |
Methods
public byte[] getData() | |
public String getMimeType() | |
public String getUrl() | |
public boolean isUrl() |
Inherited methods
Constructor details
ImagePart
public ImagePart(byte[] data, String mimeType)Creates an inline image part. The media type must describe the encoded
bytes, for example
image/png or image/jpeg; providers
reject inline images without a type.Parameters
databyte[]- encoded image bytes, defensively copied
mimeTypeString- media type such as
image/png
ImagePart
public ImagePart(String url)Remote image by URL. Only HTTPS is portable across providers.
Creates a remotely addressed image part.
Parameters
urlString- provider-accessible HTTPS or data URL
Method details
getData
public byte[] getData()Returns
a defensive copy of inline bytes, or
null for a URL imagegetMimeType
public String getMimeType()Returns
MIME type of inline bytes, or
null for a URL imagegetUrl
public String getUrl()Returns
provider-accessible URL, or
null for an inline imageisUrl
public boolean isUrl()Returns
true when this part references a URL instead of bytes