liveBook · Manning

Finish reason

A finish reason is a response field indicating why a model stopped generating output or otherwise ended its response.

How 2 Manning books explain it

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.

Read how Designing AI Systems explains finish reason →

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.

Read how Generative AI in Action explains finish reason →

Also covered in

What to know first

Related concepts

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.