ai-for-java / openai4j

Java client library for OpenAI API
Apache License 2.0
85 stars 34 forks source link

Image content from ByteArray or Stream #28

Open maximehamm opened 5 months ago

maximehamm commented 5 months ago

There is no documentation about ho to send Image from ByteArray or Stream... It is possible to send by url or "text"... what is a text image ?? Thank you for this great API

langchain4j commented 5 months ago

Hi, OpenAI accepts images only by URL.

Content content = Content.builder()
                .type(IMAGE_URL)
                .imageUrl(ImageUrl.builder()
                        .url("http://image.url")
                        .detail(LOW)
                        .build())
                .build();

Then you can put Content into UserMessage:

UserMessage userMessage = UserMessage.builder()
                        .content(content)
                        .build();