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

Connected

Exercise

Streaming with Function Calls

You've seen already how many use cases are unlocked with function-calling LLMs, which have their own event types. This is useful for providing real-time feedback to users when the model is preparing to call a tool, or for logging to track tool usage.

The convert_timezone() function you defined earlier to convert datetimes between timezones, and a tools list containing the function definition for the Responses API have been defined for you.

Instructions

100 XP
  • Complete the streaming context manager by calling client.responses.create() with the model "gpt-5-mini", the prompt, and the tools list.
  • Inside the loop, check if the "function_call_arguments.delta" events.
  • Add a condition to check for "function_call_arguments.done" events.
  • Add a final condition to check if the event type is "response.completed" and print a final completion message.