Skip to content

Function: parseSimpleTextStream()

@providerprotocol/ai


@providerprotocol/ai / http / parseSimpleTextStream

parseSimpleTextStream(body): AsyncGenerator<string, void, unknown>

Defined in: src/http/sse.ts:173

Parses a simple text stream without SSE formatting.

This is a simpler alternative to parseSSEStream for providers that stream raw text deltas without SSE event wrappers. Each chunk from the response body is decoded and yielded as-is.

Use this for:

  • Plain text streaming responses
  • Providers with custom streaming formats
  • Testing and debugging stream handling

ReadableStream<Uint8Array<ArrayBufferLike>>

ReadableStream from fetch response body

AsyncGenerator<string, void, unknown>

Decoded text strings from each stream chunk

const response = await doStreamFetch(url, init, config, 'custom', 'llm');
for await (const text of parseSimpleTextStream(response.body!)) {
process.stdout.write(text);
}