Skip to main content

Cloudflare Workers AI

https://developers.cloudflare.com/workers-ai/

<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-workers-ai</artifactId>
<version>1.24.1-beta34</version>
</dependency>

APIs​

  • WorkersAiImageModel

WorkersAiImageModel edits images given as base64 data. Images given by URL are not supported. To edit a local image, create it from the content of the file:

Image image = Image.builder()
.base64Data(Base64.getEncoder().encodeToString(Files.readAllBytes(Path.of("/home/me/cat.png"))))
.mimeType("image/png")
.build();

The image and the mask are sent to Workers AI as the bytes of their files, so Workers AI checks their format and size.

Examples​