Finish reason
A finish reason is a response field indicating why a model stopped generating output or otherwise ended its response.
Designing AI Systems
A finish reason is a response field indicating why a model stopped generating output, such as natural completion, a limit, a tool call, filtering, or an error.
- How it is used
- Signals why model generation ended so clients can process completion, limits, tool requests, filtering, and streaming failures.
- How deep it goes
- Defines termination values and final-chunk behavior, then addresses partial output and fallback limits without implementing provider-specific adapters.
- Examples
- Uses ChatChunk and ChatResponse schemas plus partial-output handling for mid-stream errors.
- What you can do after
- Diagnose completed and failed generations by inspecting finish_reason and preserving valid partial output during streaming.
Generative AI in Action
A finish reason is an API response field indicating why model generation ended or why the API returned the output it did.
- How it is used
- Uses finish reasons to validate outputs, debug API behavior, manage incomplete responses, and handle content-filter events.
- How deep it goes
- Defines four principal values and explains streaming nulls, but defers detailed content-safety treatment.
- Examples
- Uses pet-salon completion JSON, filtered empty output, and streamed token messages ending with stop.
- What you can do after
- Diagnose/debug with it by distinguishing normal, truncated, filtered, function-calling, and still-streaming responses.
Also covered in
What to know first
- tokenA token is a discrete unit of text, such as a word, subword, punctuation mark, or symbol, produced by tokenization and processed by a language model.
- GPT-4oGPT-4o is an OpenAI multimodal generative model in the GPT family that processes and generates text and other supported modalities.
- language modelA language model is a computational model that represents patterns in linguistic sequences to assign probabilities, predict, generate, or evaluate language.
Related concepts
- token limitconfigured by · A token limit is a configured upper bound on the number of tokens accepted, processed, or generated in a model operation or sequence.
- contractproduced by · A contract is an agreed specification of the conditions, expectations, rights, or obligations that govern behavior or interactions between parties or software components.
- content filteringproduced by · Content filtering is the screening of content against defined criteria to determine whether it should be allowed, restricted, modified, flagged, or removed.
- callproduced by · A call is an invocation that requests execution of a function, routine, command, or tool, optionally supplying arguments.
- stream processingpart of · Stream processing is the incremental processing of data items as they become available, without requiring the complete dataset to be present first.
Questions about finish reason
What is finish reason?
A finish reason is a response field indicating why a model stopped generating output or otherwise ended its response.
Which Manning books explain finish reason?
Designing AI Systems and Generative AI in Action.
What should I know before learning finish reason?
Manning books that teach finish reason usually introduce token, GPT-4o and language model first.
What is finish reason part of?
Finish reason is part of stream processing. Stream processing is the incremental processing of data items as they become available, without requiring the complete dataset to be present first.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

