Skip to main content

Session send() and on()

sendAndWait() is easy to reason about because it returns the response right away, but you only receive the final assistant message.
To also receive intermediate messages, register an event listener with on().
Because this is awkward in PHP, we recommend combining on() with sendAndWait().

Specifying a particular event type with on()

Pass a SessionEventType enum or string to subscribe to a specific event only.

Subscribing to every event type

Omit the event type to subscribe to everything.
For the latest updates, see the GitHub repository.
Last modified on August 2, 2026