Read results and events
For a simple integration, periodically read the run resource. Terminal states are completed, failed and cancelled. The answer is in final_message.text when a final message exists. Check status and errors as well. Having answer text alone does not establish success.
Use SSE for live updates:
sh
curl -N "http://localhost:8000/api/v1/sessions/$SESSION_ID/events/stream" \
-H "Authorization: Bearer $ORPHEUS_API_KEY"Recover after disconnects
- Fetch history and retain
event_cursor. - Open the stream with that cursor as
after. - Store processed event IDs.
- Reconnect with the last ID in
Last-Event-ID. This header takes precedence overafter. - If the cursor is invalid, fetch a new history snapshot.
History includes messages and tool calls. Follow next_cursor to read it completely. Events also support ordinary HTTP requests.
SSE delivers updates promptly. Current-state checks and delivery tracking are needed independently of the connection. Use a separate HTTP client without a short request timeout for streaming.