Class ImagePart

java.lang.Object
com.codename1.ai.MessagePart
com.codename1.ai.ImagePart

public final class ImagePart extends MessagePart
An image attachment for a multi-modal ChatMessage. Construct from raw bytes (the provider encodes them as base64 inline data) or from a publicly-reachable URL -- both modes are accepted by OpenAI, Anthropic, and Gemini.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ImagePart(byte[] data, String mimeType)
    Inline image bytes.
    Remote image by URL.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
     
     
     
    boolean
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ImagePart

      public ImagePart(byte[] data, String mimeType)
      Inline image bytes. mimeType must be set (e.g. "image/png", "image/jpeg"); the providers reject inline images without it.
    • ImagePart

      public ImagePart(String url)
      Remote image by URL. Only HTTPS is portable across providers.
  • Method Details

    • getData

      public byte[] getData()
    • getMimeType

      public String getMimeType()
    • getUrl

      public String getUrl()
    • isUrl

      public boolean isUrl()