Skip to content

Support structured outputs when streaming #495

Open
@bkadatz

Description

@bkadatz

The docs at https://platform.openai.com/docs/guides/structured-outputs?api-mode=responses#streaming indicates that, when using the JavaScript library, one is able to specify a JSON schema via the text parameter and stream the responses.

However, when using the Java library this doesn't appear to be possible as .responses().createStreaming() only accepts ResponseCreateParams and using ResponseCreateParams.builder().text(...) changes the type to StructuredResponseCreateParams<T>.

Is there a way to stream structured outputs I haven't discovered yet, or is this a known limitation in the current version (2.3.0) of the library?

What I'm trying to achieve without having to manually parse streaming JSON (or JSONL) output is specify that the output is an array of some type T, then have a stream event where I check something like event.isOutputTextItem() where I can retrieve each item of type T individually from the event.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions