Skip to content

Conversation

@boboldehampsink
Copy link
Contributor

@boboldehampsink boboldehampsink commented Nov 11, 2025

What:

  • Bug Fix
  • New Feature

Description:

Adds ability to resume a background stream from a response id and cursor:

$stream = OpenAI::responses()->retrieveStreamed($rid, [
  'starting_after' => $cursor,
]);

Related:

https://platform.openai.com/docs/guides/background#streaming-a-background-response

@iBotPeaches
Copy link
Collaborator

With a new method like this - I don't exactly remember it all by heart but you'll need to touch the interface, the mock and a simple test to keep the coverage.

@boboldehampsink
Copy link
Contributor Author

Yes this is more of a working draft now. To have discussion over I guess.

@iBotPeaches iBotPeaches marked this pull request as draft November 11, 2025 13:34
@boboldehampsink boboldehampsink marked this pull request as ready for review November 13, 2025 09:00
@boboldehampsink
Copy link
Contributor Author

@iBotPeaches improved code, added interface methods, docs and tests.

@iBotPeaches
Copy link
Collaborator

Do you have any further context on the string true? I read the docs and it seems its a regular bool like the other stream endpoints. Rest looks solid - just trying to understand the string/true.

@boboldehampsink
Copy link
Contributor Author

Do you have any further context on the string true? I read the docs and it seems its a regular bool like the other stream endpoints. Rest looks solid - just trying to understand the string/true.

When we use the boolean it is being used as ?stream=1 instead of ?stream=true. This is because retrieve is a GET request. Apparently the OpenAI API wants this to be "true" instead of "1". It fails when passing 1 with an error message (out of the top of my head) of "cannot parse stream as boolean"

@boboldehampsink
Copy link
Contributor Author

We could also adjust the Payload::toRequest method to handle this, but I'm not sure if it applies to every endpoint.

@boboldehampsink
Copy link
Contributor Author

@iBotPeaches
Copy link
Collaborator

Ahh interesting. Thanks for all the info. Let me mess with this a bit (see impact on other endpoints, etc) and see.

@iBotPeaches iBotPeaches merged commit 38e6493 into openai-php:main Nov 14, 2025
12 checks passed
@iBotPeaches
Copy link
Collaborator

thanks!

@iBotPeaches iBotPeaches added this to the v0.19.0 milestone Nov 14, 2025
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