Member-only story
7 Things an AI API Response Tells You That Most Code Throws Away
One line reads the text. The finish reason, the refusal, the tool call ids, the token bill and the headers go in the bin with the box.
Ferid Brković
10 min read12 hours ago
--
Press enter or click to view image in full size
You order a mug. The box arrives, you lift the mug out, and the packing slip, the receipt and the warranty card go in the bin with the cardboard. Most code treats the reply of an AI API the same way: one line takes the text, and everything else that came in the box is thrown out.
This is the line:
// The line almost every tutorial ends with.
export function naiveReply(data) {
return data.choices[0].message.content;
}
And this is what it returns for five different sample responses:
== A.…