Skip to content

Add fromReadableStream or similar to the ResponseStream class #1376

@MarkMurphy

Description

@MarkMurphy

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

Both the ChatCompletionStream and AssistantStream classes have a fromReadableStream method that the new ResponseStream class is missing.

I'm looking for something similar to allow my client side web application to request a response stream from my server and convert that to a ResponseStream instance.

For example:

const sendMessage = async (input) => {
    controller.current = new AbortController();
    const response = await fetch(`${API_URL}/responses`, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        input,
      }),
      signal: controller.current.signal,
    })
    const stream = ResponseStream.fromReadableStream(response.body)
    handleReadableStream(stream)
  };

Also open to alternative recommendations if this is not the pattern to use moving forward. There is currently a lack of guidance in the docs on how to integrate with the new responses API when it comes to frontend applications.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions