Skip to content

Open WebUI Events Example

Send status updates and UI events to Open WebUI during streaming, and optionally intercept tool calls for richer feedback.

Where is the code?

Prerequisites

Clone the Hayhooks repository and run these commands from its root. Install hayhooks, set OPENAI_API_KEY in the server environment, and start hayhooks run in another terminal.

Deploy (example)

hayhooks pipeline deploy-files -n agent_events examples/pipeline_wrappers/open_webui_agent_events

Run

  • OpenAI-compatible chat (events stream to Open WebUI):
curl -N http://localhost:1416/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "agent_events",
    "stream": true,
    "messages": [{"role": "user", "content": "Tell me about machine learning"}]
  }'

Working with Events

  • Use helpers from hayhooks.open_webui: create_status_event, create_message_event, create_replace_event, create_source_event, create_notification_event, create_details_tag
  • Intercept tool calls via on_tool_call_start/on_tool_call_end with streaming_generator/async_streaming_generator
  • For recommended Open WebUI settings, see the Open WebUI Integration guide