I’m getting a “‘file’ is a required property” error when trying to create a file. After looking at several posts that seem to have have resolved it, I’m still getting the same error.
Here is the error:
{
error: {
message: "'file' is a required property",
type: 'invalid_request_error',
param: null,
code: null
}
}
Here is the code.
const formData = new FormData();
let file = new Blob(["a string"], {
type: "text/plain; charset=utf8",
});
formData.append("purpose", "fine-tune");
formData.append("file", file, "file.jsonl");
// Define the endpoint URL for creating files in OpenAI
const url = "https://api.openai.com/v1/files";
// Define the options for the fetch request, including method, headers, and body
const fetchOptions: RequestInit = {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
},
body: formData,
};
// Make the POST request to OpenAI
const response = await fetch(url, fetchOptions);