Streaming intermediary agent step via an api

I would like to show to the user behind the API what are the actions the agents are doing. How can I stream the intermediary steps via an API? (FastAPI or Flask)