Skip to content

Conversation

@madskildegaard
Copy link
Contributor

What:

  • Bug Fix
  • New Feature

Description:

This pull request adds type to every streamed object in the Responses endpoint, as seen in the OpenAI API Reference.

The API Reference also shows that response.created, response.in_progress, response.completed, response.failed and response.incomplete has a type, response and sequence number. Currently only the response object is returned, which is made by the CreateResponse class. I've made it so that they now return a Response class, which has type: string, response: CreateResponseType and sequence_number: int.

This is a pretty big change, but I believe it is necessary in order to conform to the OpenAI spec more closely.

Signed-off-by: Mads Kildegård <mkildegaard99@gmail.com>
Signed-off-by: Mads Kildegård <mkildegaard99@gmail.com>
@madskildegaard madskildegaard force-pushed the feat-responses-streaming-types branch from 8708501 to 3330a3b Compare November 6, 2025 09:10
@iBotPeaches
Copy link
Collaborator

Is there something in specific you hit that required this? Since we switch off the type to build the sub streaming set, we technically know it. I'm guessing maybe the toArray() not returning it was a bug?

The missing types on response is a good call out. Some types we made fresh streaming classes for, others seemed like they reuse the main response class.

Copy link
Collaborator

@iBotPeaches iBotPeaches left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran it through my Response tests and all good. Confirmed the changes to Response makes sense. Don't love response->response, but I can't think of a better name.

Slight breaking change here, but since we aren't 1.0.0 yet - I believe thats alright.

@iBotPeaches iBotPeaches added this to the v0.19.0 milestone Nov 6, 2025
@iBotPeaches iBotPeaches merged commit 9eadda1 into openai-php:main Nov 6, 2025
12 checks passed
@madskildegaard
Copy link
Contributor Author

I'm guessing maybe the toArray() not returning it was a bug?

Exactly. I was running some tests using the client, that required the items to be the same as the OpenAI API Reference says, which is why I recognized the difference.

Don't love response->response, but I can't think of a better name.

I agree - don't like the naming either. Also, using the class CreateResponse inside the class Response also might be a bit confusing, but like you I couldn't come up with a better name for either of these things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants