Watch the explanation. Practice the skill.

OpenAI and Anthropic APIs, end to end

Handle an AI API response without mistaking partial text for success.

Visual lesson1:42

Captions appear here during playback.

OpenAI and Anthropic APIs, end to end

Handle an AI API response without mistaking partial text for success.

Download transcriptOpen video file

Source-based teaching example · Fictional data · Reviewed 2026-10-03. Microsoft Mark · locally synthesized. On a small screen, use fullscreen for diagram details or read the transcript.

Read the descriptive transcript

0:00 · What you will learn

Handle an AI API response without mistaking partial text for success.

What appears on screen

Handle an AI API response without mistaking partial text for success.

0:07 · 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.

What appears on screen

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.

0:20 · One useful term

API. An interface that lets one program request work from another service.

What appears on screen

An interface that lets one program request work from another service.

0:29 · 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.

What appears on screen

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.

0:44 · Your turn to think

Does receiving some text mean the request finished successfully? Pause and decide before continuing.

What appears on screen

Does receiving some text mean the request finished successfully? Pause the video if you need more time.

1:01 · Why this answer works

No. Check completion, refusal and cancellation explicitly. The exercise is offline and does not establish a live provider’s behavior.

What appears on screen

No. Check completion, refusal and cancellation explicitly. The exercise is offline and does not establish a live provider’s behavior.

1:14 · Check 1

Check status before using the text.

What appears on screen

Check status before using the text.

1:19 · Check 2

Keep unknown usage marked unknown.

What appears on screen

Keep unknown usage marked unknown.

1:24 · Check 3

Do not repeat a consequential action blindly.

What appears on screen

Do not repeat a consequential action blindly.

1:30 · 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.

What appears on screen

Open the lesson Try the new case Check and revise The full task and its requirements are in the linked lesson.

Watching explains the example. Complete the lesson practice to check what you can do. Explore all visual lessons →