Skip to content

Expose typed AI response parts #610

@leoafarias

Description

@leoafarias

From discussion #599

Is your feature request related to a problem? Please describe.
The current ContentGenerator interface returns Stream<String> for AI responses, which discards rich typed data provided by the AI SDK. This means consumers cannot access message parts like MessagePart, TextPart, ToolCallPart, ThinkingPart, images or multimodal parts, finish reasons, token usage, safety ratings, citations, etc.

Describe the solution you'd like
Provide a new API that exposes the full typed AI response to consumers. This could be achieved by converting the existing Stream<String> to a Stream<Part> or by adding an alternate method that returns a stream of typed parts. This would allow applications to access thinking blocks, tool calls, results, and other metadata.

Describe alternatives you've considered
Currently, we can only see tool calls in logs and lose other important information. There isn't a clean way to access this data through the existing interface.

Additional context
The flutter/ai package also recreates these parts; there may be overlap between the implementations in flutter/ai and genui. Consolidating the primitives into a separate shared package could be considered.

Metadata

Metadata

Assignees

No one assigned

    Labels

    front-line-handledCan wait until the second-line triage. The front-line triage already checked if it's a P0.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions