💾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.
Supports files up to 2 million tokens and of specific file types.
See the Assistants Tools guide for details.
Only supports
.jsonlfile.The input also has certain required formats for fine-tuning chat or completions models.
Only supports
.jsonlfile.Up to 100 MB in size.
The input also has a specific required format.
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);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.
var fileList = await OpenAI.DefaultInstance.Files.List();
foreach (var fileData in fileList)
{
Debug.Log(fileData.Id);
Debug.Log(fileData.CreatedAt);
Debug.Log(fileData.Purpose);
}from openai import OpenAI
client = OpenAI()
client.files.list()Returns information about a specific file.
var fileData = await OpenAI.DefaultInstance.Files.Retrieve("file-abc123");
Debug.Log(fileData.Id);from openai import OpenAI
client = OpenAI()
client.files.retrieve("file-abc123")Delete a file.
bool deleted = await OpenAI.DefaultInstance.Files.Delete("file-abc123");
if (deleted)
{
Debug.Log("File deleted successfully");
}from openai import OpenAI
client = OpenAI()
client.files.delete("file-abc123")Returns the contents of the specified file.
var content = await OpenAI.DefaultInstance.Files.RetrieveFileContent("file-abc123");
Debug.Log(content);from openai import OpenAI
client = OpenAI()
content = client.files.content("file-abc123")Last updated