#How do I get the raw response using the Node.js SDK?
1 messages · Page 1 of 1 (latest)
Code for reference
async function fileTest() {
const file = await openai.files.retrieveContent("file-CrEM19MAQeV2UqvCTCkgPN3w");
fs.writeFileSync("./test.png", Buffer.from(file));
}
Having the same problem here. Looks like the python client is more flexible 😦
Right now I'm just trying to find workarounds LOL
It's a pain but you gotta do what you gotta do
I think this is not the best way to do it but sort of figured it out ```const main = async () => {
const writeStream = createWriteStream(__dirname + "/myImage.png");
const response = await fetch(
"https://api.openai.com/v1/files/{file-id}/content",
{
headers: {
Authorization:
"Bearer {Your OpenAI key}",
},
}
).then((res) => res.blob());
response.arrayBuffer().then((buffer) => {
writeStream.write(Buffer.from(buffer));
});
};
main();
Let me know if that works or if you have a better way to do it 🙌
I think that's the only way to do it right now. Just gotta wait for OpenAI to come up with a fix because I don't wanna have to write that every time I have a project like this one.