OpenAI and Anthropic APIs, end to end Handle an AI API response without mistaking partial text for success. Reviewed: 2026-10-03 Source-based teaching example · Fictional data Narration: Microsoft Mark · locally synthesized 00:00:00.000 — What you will learn Handle an AI API response without mistaking partial text for success. Visual description: Handle an AI API response without mistaking partial text for success. 00:00:07.708 — The idea Check the response status as well as its text. A stream may stop before the answer is complete. Missing usage information means unknown, not zero. Visual description: Check the response status as well as its text. A stream may stop before the answer is complete. Missing usage information means unknown, not zero. 00:00:20.750 — One useful term API. An interface that lets one program request work from another service. Visual description: An interface that lets one program request work from another service. 00:00:29.125 — A worked example The mock service produces some text, then reports cancellation. Keep the request ID and mark the text as incomplete. Do not trigger a downstream action as if the response succeeded. Visual description: The mock service produces some text, then reports cancellation. Keep the request ID and mark the text as incomplete. Do not trigger a downstream action as if the response succeeded. 00:00:44.333 — Your turn to think Does receiving some text mean the request finished successfully? Pause and decide before continuing. Visual description: Does receiving some text mean the request finished successfully? Pause the video if you need more time. 00:01:01.708 — Why this answer works No. Check completion, refusal and cancellation explicitly. The exercise is offline and does not establish a live provider’s behavior. Visual description: No. Check completion, refusal and cancellation explicitly. The exercise is offline and does not establish a live provider’s behavior. 00:01:14.458 — Check 1 Check status before using the text. Visual description: Check status before using the text. 00:01:19.875 — Check 2 Keep unknown usage marked unknown. Visual description: Keep unknown usage marked unknown. 00:01:24.958 — Check 3 Do not repeat a consequential action blindly. Visual description: Do not repeat a consequential action blindly. 00:01:30.792 — Now try a different case Open the lesson and try its different practice case. Use every check in the full task. Watching alone does not mark the lesson complete. Visual description: Open the lesson Try the new case Check and revise The full task and its requirements are in the linked lesson.