Most LLM providers, and many company gateways, speak the same chat API, so the official openai Python SDK works against all of them. In this lesson the SDK points at the practice bot: the lesson runner sets OPENAI_BASE_URL and OPENAI_API_KEY, which the SDK reads on its own.
The script works, but its client uses the SDK's defaults, which wait up to ten minutes for a reply. A support chatbot that makes a customer wait that long has failed, and a test harness that hangs that long is useless.
Your task
- Create the client with a 2 second timeout and 3 retries.
- If the request still times out, print exactly
{"error": "timeout"}as one line of JSON instead of crashing. - Keep printing the content and total tokens as one line of JSON when the call succeeds.
On submit, the script runs against a normal bot, a bot that refuses the first request with 429 (rate limited), and a bot that takes four seconds to answer.