Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inquiry about the 'Accept' header #375

Open
1 task done
MartialBE opened this issue Oct 13, 2023 · 1 comment
Open
1 task done

Inquiry about the 'Accept' header #375

MartialBE opened this issue Oct 13, 2023 · 1 comment

Comments

@MartialBE
Copy link

Confirm this is a feature request for the Node library and not the underlying OpenAI API.

  • This is a feature request for the Node library

Describe the feature or improvement you're requesting

Hello,

I am currently using the openai-node package for my project, and I have a question regarding the 'Accept' header in the request made at this specific code snippet: core.ts.

In the mentioned code, the 'Accept' header is set to "application/json". However, when the 'stream' option is set to true, the response I receive is in the format of "text/event-stream".

I am using a unified API platform that converts API interfaces from different platforms to OPENAI format. Due to some platforms validating the 'Accept' header value, I am facing issues with the API requests failing.

Could you please confirm if setting the 'Accept' header to "application/json" in the mentioned code is compliant with the specifications? if it should be modified based on the expected response type?

Thank you for your assistance.

Additional context

No response

@rattrayalex
Copy link
Collaborator

Hi, thanks for your request here. You're correct that the server responds with Content-Type: text/event-stream, so that'd likely be a more appropriate Accept: header to send. We'll look into fixing this; in the meantime, you can send Accept manually yourself like so:

  const stream = await openai.chat.completions.create(
    {
      model: 'gpt-4',
      messages: [{ role: 'user', content: 'Say this is a test' }],
      stream: true,
    },
    { headers: { Accept: 'text/event-stream' } },
  );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants