Reading the Reply's Content Blocks
parsing the model's response
Part of: Screenshot Describer
You sent the image. Something came back. Now you need the description out of it, in a way that won't break the moment the reply isn't perfectly simple. The smallest thing that works For most calls, the answer is one line you've probably seen before: That's a working screenshot describer already: image in, one paragraph out. Shipping something small is a fine first milestone. But content is a list, not a string resp.content is not text. It's a list of content blocks , and [0].text only works because the first block usually is the reply text. A vision reply can include more than one block, for instance the model reasoning in one block before answering in another. Grabbing only content[0] silently drops anything after it. The safer version loops over every block and keeps only the text ones: This never assumes the reply is exactly one block. It filters by type and stitches whatever text blocks exist, in order, into one string. A non-text block (a future tool call, an image the model returned) gets skipped instead of crashing the code. Why bother when [0].text "works" It works until the day it doesn't: some input, some model version, some case where the API adds a block you didn't expe
Challenge: Stitch the Text Blocks