Skip to content

Add support for streaming #100

Open

Description

@felixarntz

See #8: A crucial piece of functionality still missing in our SDK is response streaming - a quite complex piece of functionality to get right, especially with the incomplete documentation of how different providers implement it. But we need it, that's for sure.

What we'll need to do is:

  • Implement the primitives needed for streaming (likely some kind of stream response class, potentially a new stream method on HttpTransporter).
  • Implement actual streaming for the three providers (which can fortunately be centralized in the OpenAI API compatible implementation for now).

Putting here some references for inspiration in how I implemented streaming (still with some limitations) in the AI Services plugin for WordPress:

There's definitely things to improve there which we should do here, but it's a decent starting point to review this and come up with effectively a v2 of that implementation.

Activity

  1. added this to the 0.3.0 milestone on Sep 24, 2025
  2. modified the milestones: 0.3.0, 0.4.0, 0.5.0 on Nov 26, 2025
  3. modified the milestones: 0.5.0, 0.6.0 on Feb 6, 2026
  4. thelovekesh commented on Jun 18, 2026

    @thelovekesh
    Member

    I'm picking this up. Before implementing this, here's what I'm planning:

    1. Extend the HTTP DTOs
      • Add a stream option to RequestOptions to request a streamed response.
      • Extend the Response DTO to expose the body as a stream.
    2. Extend the HttpTransporter to support streaming when sending the request and building the Response.
    3. Add an SSE-spec-compliant parser behind an EventStreamParserInterface, so providers can plug in their own parser or fall back to the default.
    4. Add a GenerativeAiResultChunk DTO and a StreamingTextGenerationModelInterface so models can expose streaming text generation and yield result chunks (which can be aggregated back into a final GenerativeAiResult).
    5. Extend the PromptBuilder (and the AiClient facade) with streaming entry points.
    6. Dispatch before/after events for streaming, mirroring the current before/after response events where the "after" firing happens once the stream completes, with the aggregated result.

    I think this is sufficient within the scope of this SDK; individual providers can extend it based on their own SSE specifics.

  5. modified the milestones: 1.4.0, 1.5.0 on Aug 13, 2026
  6. modified the milestones: 1.5.0, 1.6.0, 1.6.0 on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[Feature]New feature to highlight in changelogs.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions