The Response Object
Response anatomy
Part of: Reading Model Outputs
A model API does not hand you a bare sentence. It hands you a structured object, and the text you want sits several layers down, under choices, then message, then content. Once you know that shape, pulling the answer out is a one-liner. Until you do, it is easy to reach for the wrong key. What it is A model API does not return a bare string. It returns a response object : a structured bundle (JSON over the wire, a dict in your code) that carries the generated text along with metadata about the call. The metadata tells you why generation stopped, how many tokens you spent, and which model answered. The generated text itself lives in a predictable nested path. For a chat-style API it's: the response has a list called choices , each choice has a message , and the message has the content string. That nesting exists because the API can return more than one candidate answer, and each answer is a structured message, not just raw text. How it works Think of the response as a series of doors you open to reach the text: Read that path left to right: choices (the list of answers) → [0] (the first answer) → message (the structured reply) → content (the actual string). Almost every chat API you
Challenge: Best-Candidate Response Router