OpenAI FilesFiles 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.
Assistants API Fine-tuning API Batch API
Supports files up to 2 million tokens and of specific file types.
Only supports .jsonl
file.
The input also has certain required formats for fine-tuning chat or completions models.
Only supports .jsonl
file.
The input also has a specific required format .
C# Python (Official SDK)
Copy 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);
Copy from openai import OpenAI
client = OpenAI()
client.files.create(
file=open("mydata.jsonl", "rb"),
purpose="fine-tune"
)
Returns a list of files that belong to the user's organization.
C# Python (Official SDK)
Copy var fileList = await OpenAI.DefaultInstance.Files.List();
foreach (var fileData in fileList)
{
Debug.Log(fileData.Id);
Debug.Log(fileData.CreatedAt);
Debug.Log(fileData.Purpose);
}
Copy from openai import OpenAI
client = OpenAI()
client.files.list()
Returns information about a specific file.
C# Python (Official SDK)
Copy var fileData = await OpenAI.DefaultInstance.Files.Retrieve("file-abc123");
Debug.Log(fileData.Id);
Copy from openai import OpenAI
client = OpenAI()
client.files.retrieve("file-abc123")
Delete a file.
C# Python (Official SDK)
Copy bool deleted = await OpenAI.DefaultInstance.Files.Delete("file-abc123");
if (deleted)
{
Debug.Log("File deleted successfully");
}
Copy from openai import OpenAI
client = OpenAI()
client.files.delete("file-abc123")
Returns the contents of the specified file.
C# Python (Official SDK)
Copy var content = await OpenAI.DefaultInstance.Files.RetrieveFileContent("file-abc123");
Debug.Log(content);
Copy from openai import OpenAI
client = OpenAI()
content = client.files.content("file-abc123")
Last updated 9 months ago