Skip to content

[Feature Request] Add streaming support for structured generation #1842

@rehan243

Description

@rehan243

Feature Description

Enable streaming output while maintaining JSON schema enforcement, yielding valid partial JSON as it's generated.

Motivation

For UX-sensitive applications (chatbots, real-time dashboards), streaming responses while maintaining structure would improve perceived latency.

Current Limitation

Structured generation currently requires waiting for the full output before validation/delivery.

Proposed Approach

Stream tokens while maintaining a running FSM state, yielding complete sub-objects as they become valid.

This would combine the best of structured output guarantees with the UX benefits of streaming. Great project!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions