createFile method

Future<OpenAIFile?> createFile(
  1. MultipartFile file,
  2. String purpose
)

Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit.

Parameters:

  • MultipartFile file (required): Name of the JSON Lines file to be uploaded. If the purpose is set to \"fine-tune\", each line is a JSON record with \"prompt\" and \"completion\" fields representing your training examples.

  • String purpose (required): The intended purpose of the uploaded documents. Use \"fine-tune\" for Fine-tuning. This allows us to validate the format of the uploaded file.

Implementation

Future<OpenAIFile?> createFile(MultipartFile file, String purpose,) async {
  final response = await createFileWithHttpInfo(file, purpose,);
  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), 'OpenAIFile',) as OpenAIFile;

  }
  return null;
}