1. Learn
  2. /
  3. Courses
  4. /
  5. Working with the OpenAI Responses API

Connected

Exercise

Streaming Semantic Events

You're building a weather assistant that provides real-time forecasts. The OpenAI client has been initialized and configured to work with the Responses API. You'll stream semantic events to track when the response starts, when text blocks finish, and when the full response is complete. This creates a more engaging user experience by showing progress as the model generates the forecast.

Instructions

100 XP
  • Handle the "response.created" event by printing a start message.
  • Handle the "response.output_text.done" event by printing a completion message.
  • Handle the "response.completed" event by printing the full response text stored in current_text.