Skip to content

Send a message and wait for the turn result in one request

Callers that want a result instead of an event stream can now wait for it.

In the API: POST /v1/sessions/{id}/messages?wait=true returns 200 with the turn result when the turn completes or fails, or 202 with partial messages when timeout_ms (default 120 s, at most 600 s) expires. Without wait it still returns 201 immediately, so existing clients are unaffected.

In code: RunOptions::timeout bounds Session::run_with; when it expires the in-process turn is cancelled and its outcome returned.

See Sessions and Stream events. #3541