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

feat(image): new feature for dalle api. #393

Merged
merged 1 commit into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public class CreateImageEditRequest {
@NonNull
String prompt;

/**
* The model to use for image generation. Only dall-e-2 is supported at this time. Defaults to dall-e-2.
*/
String model;

/**
* The number of images to generate. Must be between 1 and 10. Defaults to 1.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,28 @@
public class CreateImageRequest {

/**
* A text description of the desired image(s). The maximum length in 1000 characters.
* A text description of the desired image(s). The maximum length is 1000 characters for dall-e-2 and 4000 characters for dall-e-3.
*/
@NonNull
String prompt;

/**
* The number of images to generate. Must be between 1 and 10. Defaults to 1.
* The model to use for image generation. Defaults to "dall-e-2".
*/
String model;

/**
* The number of images to generate. Must be between 1 and 10. For dall-e-3, only n=1 is supported. Defaults to 1.
*/
Integer n;

/**
* The size of the generated images. Must be one of "256x256", "512x512", or "1024x1024". Defaults to "1024x1024".
* The quality of the image that will be generated. "hd" creates images with finer details and greater consistency across the image. This param is only supported for dall-e-3. Defaults to "standard".
*/
String quality;

/**
* The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024 for dall-e-2. Must be one of 1024x1024, 1792x1024, or 1024x1792 for dall-e-3 models. Defaults to 1024x1024.
*/
String size;

Expand All @@ -38,6 +48,11 @@ public class CreateImageRequest {
@JsonProperty("response_format")
String responseFormat;

/**
* The style of the generated images. Must be one of vivid or natural. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images. This param is only supported for dall-e-3. Defaults to vivid.
*/
String style;

/**
* A unique identifier representing your end-user, which will help OpenAI to monitor and detect abuse.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public class CreateImageVariationRequest {
*/
Integer n;

/**
* The model to use for image generation. Only dall-e-2 is supported at this time. Defaults to dall-e-2.
*/
String model;

/**
* The size of the generated images. Must be one of "256x256", "512x512", or "1024x1024". Defaults to "1024x1024".
*/
Expand Down
6 changes: 6 additions & 0 deletions api/src/main/java/com/theokanning/openai/image/Image.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ public class Image {
*/
@JsonProperty("b64_json")
String b64Json;

/**
* The prompt that was used to generate the image, if there was any revision to the prompt.
*/
@JsonProperty("revised_prompt")
String revisedPrompt;
}
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ public ImageResult createImageEdit(CreateImageEditRequest request, java.io.File
.setType(MediaType.get("multipart/form-data"))
.addFormDataPart("prompt", request.getPrompt())
.addFormDataPart("size", request.getSize())
.addFormDataPart("model", request.getModel())
.addFormDataPart("response_format", request.getResponseFormat())
.addFormDataPart("image", "image", imageBody);

Expand All @@ -276,6 +277,7 @@ public ImageResult createImageVariation(CreateImageVariationRequest request, jav
MultipartBody.Builder builder = new MultipartBody.Builder()
.setType(MediaType.get("multipart/form-data"))
.addFormDataPart("size", request.getSize())
.addFormDataPart("model", request.getModel())
.addFormDataPart("response_format", request.getResponseFormat())
.addFormDataPart("image", "image", imageBody);

Expand Down