Skip to content
This repository was archived by the owner on Jun 6, 2024. It is now read-only.

Commit 32b4c98

Browse files
author
Firahs
authored
Added Image generation example (#87)
1 parent 1a463b6 commit 32b4c98

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

example/src/main/java/example/OpenAiApiExample.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.theokanning.openai.OpenAiService;
44
import com.theokanning.openai.completion.CompletionRequest;
5+
import com.theokanning.openai.image.CreateImageRequest;
56

67
class OpenAiApiExample {
78
public static void main(String... args) {
@@ -16,5 +17,13 @@ public static void main(String... args) {
1617
.user("testing")
1718
.build();
1819
service.createCompletion(completionRequest).getChoices().forEach(System.out::println);
20+
21+
System.out.println("\nCreating Image...");
22+
CreateImageRequest request = CreateImageRequest.builder()
23+
.prompt("A cow breakdancing with a turtle")
24+
.build();
25+
26+
System.out.println("\nImage is located at:");
27+
System.out.println(service.createImage(request).getData().get(0).getUrl());
1928
}
2029
}

0 commit comments

Comments
 (0)