Skip to content

Commit

Permalink
Added Image generation example (TheoKanning#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
Firahs authored Feb 13, 2023
1 parent 1a463b6 commit 32b4c98
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions example/src/main/java/example/OpenAiApiExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.theokanning.openai.OpenAiService;
import com.theokanning.openai.completion.CompletionRequest;
import com.theokanning.openai.image.CreateImageRequest;

class OpenAiApiExample {
public static void main(String... args) {
Expand All @@ -16,5 +17,13 @@ public static void main(String... args) {
.user("testing")
.build();
service.createCompletion(completionRequest).getChoices().forEach(System.out::println);

System.out.println("\nCreating Image...");
CreateImageRequest request = CreateImageRequest.builder()
.prompt("A cow breakdancing with a turtle")
.build();

System.out.println("\nImage is located at:");
System.out.println(service.createImage(request).getData().get(0).getUrl());
}
}

0 comments on commit 32b4c98

Please sign in to comment.