Skip to main content

Session send() and on()

sendAndWait() is easy to understand because it returns quickly, but you only receive the final assistant message.
If you also want intermediate messages, register an event listener with on().
In PHP, this can be hard to read, so combining on() with sendAndWait() is recommended.

Subscribe to a specific event type with on()

You can subscribe to only one event by passing a SessionEventType enum value or a string.

Subscribe to all event types

If you do not specify an event type, it subscribes to all events.
For the latest updates, see the GitHub repository.
Last modified on April 19, 2026