openai-node icon indicating copy to clipboard operation
openai-node copied to clipboard

`openai.files.content` returns raw Response object

Open itta611 opened this issue 1 year ago • 1 comments

Confirm this is a Node library issue and not an underlying OpenAI API issue

  • [X] This is an issue with the Node library

Describe the bug

In the documentation, openai.files.content is described as returns content as string type. However, it returns raw Response type.

import OpenAI from "openai";

const openai = new OpenAI();

async function main() {
  const file = await openai.files.content("file-abc123");

  console.log(file); // Expected to show a string (ref. https://platform.openai.com/docs/api-reference/files/retrieve-contents)
}

main();

Output: Screenshot 2024-07-27 at 17 47 19

To Reproduce

  1. Write the code above (copy&pasted from https://platform.openai.com/docs/api-reference/files/retrieve-contents)
  2. It shows file is a Response object

Code snippets

No response

OS

macOS

Node version

Node v18.17.0

Library version

openai v4.53.1

itta611 avatar Jul 27 '24 08:07 itta611

I'd like to work on this documentation issue. I'll clarify the return type for openai.files.content and add an example showing how to properly consume the Response object. ETA: 1-2 hours.

dhofheinz avatar Oct 06 '25 04:10 dhofheinz