Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.streamstraight.com/llms.txt

Use this file to discover all available pages before exploring further.

In some instances, you may want to simultaneously processes the LLM stream while also passing a version of it to Streamstraight. Because streams can only be consumed once, you’ll need to duplicate the stream and consume each separately. You can do so via the tee method on the ReadableStream object.
const [stream1, stream2] = llmResponseStream.tee();

const ssServer = await streamstraightServer(
  { apiKey: process.env.STREAMSTRAIGHT_API_KEY },
  { streamId: messageId },
);

// Stream to Streamstraight in the background asynchronously,
// so you don't block the rest of this method.
void ssServer.stream(stream2);

// Process the stream synchronously
for await (const chunk of stream1) {
  // ...
}