Unable to Create File from R2 to Openai

Following these directions, I'm not able to get create file to work. https://developers.cloudflare.com/workers/tutorials/create-finetuned-chatgpt-ai-models-with-r2/ I'm getting "400 'file' is a required property". Here is my code:
await env.DOC_BUCKET.put(id, trainingStr);

const obj = await env.DOC_BUCKET.get(id);

const blob = await obj.blob();
const file = await toFile(blob, obj.key);

const fileCreationResponse = await openai.files.create({
file,
purpose: "fine-tune",
});
await env.DOC_BUCKET.put(id, trainingStr);

const obj = await env.DOC_BUCKET.get(id);

const blob = await obj.blob();
const file = await toFile(blob, obj.key);

const fileCreationResponse = await openai.files.create({
file,
purpose: "fine-tune",
});
Cloudflare Docs
Create a fine-tuned OpenAI model with R2 · Cloudflare Workers docs
In this tutorial, you will use the OpenAI API and Cloudflare R2 to create a fine-tuned model . This feature in OpenAI’s API allows you to derive a …
1 Reply
EvanPiro
EvanPiro6mo ago
Has anyone run into this error i.e uploading files to openai from a worker environment? Following up on this. This appears to be an issue with the Cloudflare runtime. Can't do multipart uploads with files
Want results from more Discord servers?
Add your server