1. सीखें
  2. /
  3. पाठ्यक्रम
  4. /
  5. Working with the OpenAI Responses API

Connected

अभ्यास

Using Items for Custom Handling

You're building a chatbot that needs to provide detailed logging for debugging purposes. The chatbot uses a reasoning-enabled model, and you want to create custom output messages that clearly distinguish between reasoning summaries and assistant responses. You have a response object from a previous API call that contains multiple output items.

निर्देश

100 XP
  • Loop through each item in response.output.
  • Check if the item type is 'reasoning' and print a formatted message showing the reasoning summary if it exists.
  • Check if the item type is 'message' and print a formatted message with the assistant's text output.