Building with AILesson 6 of 80

Module 1 · The call underneath everything

Every field in the response, and the two that catch bugs

In this lesson

  • 8 min read
  • 6 reading sections
  • Knowledge check
  • Lesson 6 of 10 in this chapter

This chapter’s goalSend the same request to a hosted model and to a model running on your own machine, read every field of the response including token counts and stop reason, and predict within a factor of two what a proposed feature will cost per thousand users before you write it.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 7Free · no account needed
Lesson steps

Most people read one field

Reading only the visible text loses information about how generation ended and what the request consumed. Inspect the schema for the chosen API. The examples below use Claude Messages responses.

Here is what comes back, and what each part is for.

id identifies the message. Log it with your own trace ID and the HTTP request ID. The Python SDK exposes the latter as _request_id on a response. These identifiers help correlate failures and support investigations. SDK request IDs.

model: the model that actually served the request, which is not always the string you sent. Ask for an alias like latest and you get whatever the provider is currently pointing that alias at. Log the returned value, not the requested one. The morning your outputs shift for no reason you changed, this field is the evidence.

role is assistant on this Messages response.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the Python, from Zero, for AI exam.

Stuck on something?Ask Sayali, your AI tutor

How to cite: Addaly (2026) ‘Every field in the response, and the two that catch bugs’, in Building with AI. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/building-with-ai/reading-the-response (Accessed: 29 November 2026).