πŸ’ΎFiles

Files are used to upload documents that can be used with features like Assistants, Fine-tuning, and Batch API.

Upload a file that can be used across various endpoints. Individual files can be up to 512 MB, and the size of all files uploaded by one organization can be up to 100 GB.

var file = new FormFile("path/to/mydata.jsonl");

var request = new FileUploadRequest.Builder()
    .SetFile(file)
    .SetPurpose(UploadPurpose.FineTune)
    .Build();

var result = await OpenAI.DefaultInstance.Files.Upload(request);

Debug.Log(result.Id);

Please contact OpenAI if you need to increase these storage limits.


Returns a list of files that belong to the user's organization.

var fileList = await OpenAI.DefaultInstance.Files.List();

foreach (var fileData in fileList)
{
    Debug.Log(fileData.Id);
    Debug.Log(fileData.CreatedAt);
    Debug.Log(fileData.Purpose);
}

Returns information about a specific file.

var fileData = await OpenAI.DefaultInstance.Files.Retrieve("file-abc123");

Debug.Log(fileData.Id);

Delete a file.

bool deleted = await OpenAI.DefaultInstance.Files.Delete("file-abc123");

if (deleted)
{
    Debug.Log("File deleted successfully");
}

Returns the contents of the specified file.

var content = await OpenAI.DefaultInstance.Files.RetrieveFileContent("file-abc123");

Debug.Log(content);

Last updated