createImageEditWithHttpInfo method
Creates an edited or extended image given an original image and a prompt.
Note: This method returns the HTTP Response.
Parameters:
-
MultipartFileimage (required): The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask. -
String prompt (required): A text description of the desired image(s). The maximum length is 1000 characters.
-
MultipartFilemask: An additional image whose fully transparent areas (e.g. where alpha is zero) indicate whereimageshould be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions asimage. -
int n: The number of images to generate. Must be between 1 and 10.
-
String size: The size of the generated images. Must be one of
256x256,512x512, or1024x1024. -
String responseFormat: The format in which the generated images are returned. Must be one of
urlorb64_json. -
String user: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.
Implementation
Future<Response> createImageEditWithHttpInfo(MultipartFile image, String prompt, { MultipartFile? mask, int? n, String? size, String? responseFormat, String? user, }) async {
// ignore: prefer_const_declarations
final path = r'/images/edits';
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
const contentTypes = <String>['multipart/form-data'];
bool hasFields = false;
final mp = MultipartRequest('POST', Uri.parse(path));
if (image != null) {
hasFields = true;
mp.fields[r'image'] = image.field;
mp.files.add(image);
}
if (mask != null) {
hasFields = true;
mp.fields[r'mask'] = mask.field;
mp.files.add(mask);
}
if (prompt != null) {
hasFields = true;
mp.fields[r'prompt'] = parameterToString(prompt);
}
if (n != null) {
hasFields = true;
mp.fields[r'n'] = parameterToString(n);
}
if (size != null) {
hasFields = true;
mp.fields[r'size'] = parameterToString(size);
}
if (responseFormat != null) {
hasFields = true;
mp.fields[r'response_format'] = parameterToString(responseFormat);
}
if (user != null) {
hasFields = true;
mp.fields[r'user'] = parameterToString(user);
}
if (hasFields) {
postBody = mp;
}
return apiClient.invokeAPI(
path,
'POST',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}