teacher
Sign in

LLM APIs and Structured Output

Call a hosted model from code, handle failures and cost, and turn free-form text into validated data your program can trust.

35 min4 interactive

What an LLM API call is

A hosted model is an HTTP service. You send a request with messages and settings; you get back text and usage numbers. Providers differ in names and extras, but the shape is the same.

Request fieldMeaning
modelWhich model to run; price and quality differ
messagesSystem, user and assistant turns (see the prompting lesson)
temperatureRandomness of sampling
max tokensHard limit on output length
stop sequencesStrings that end generation
tools / schemaOptional: tool definitions or an output format (provider specific)
Response fieldWhy you care
textThe answer, as a string
usageInput and output token counts, which set the bill
finish reasonStopped naturally, hit max tokens (output may be cut off), or other
1 of 8