createImageVariation method

Future<ImagesResponse?> createImageVariation(
  1. MultipartFile image, {
  2. int? n,
  3. String? size,
  4. String? responseFormat,
  5. String? user,
})

Creates a variation of a given image.

Parameters:

  • MultipartFile image (required): The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.

  • 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, or 1024x1024.

  • String responseFormat: The format in which the generated images are returned. Must be one of url or b64_json.

  • String user: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.

Implementation

Future<ImagesResponse?> createImageVariation(MultipartFile image, { int? n, String? size, String? responseFormat, String? user, }) async {
  final response = await createImageVariationWithHttpInfo(image,  n: n, size: size, responseFormat: responseFormat, user: user, );
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
    return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ImagesResponse',) as ImagesResponse;

  }
  return null;
}