Understanding the response object is crucial for production code. Here's a detailed breakdown of what you get back from a Chat Completions call:
finish_reason Values
| Value | Meaning |
|---|---|
stop | Natural end of generation or stop sequence hit |
length | Hit max_completion_tokens or context window |
tool_calls | Model wants to call one or more tools |
content_filter | Stopped by content policy |
The usage object now includes detailed breakdowns: prompt_tokens_details.cached_tokens shows cache hits, and completion_tokens_details.reasoning_tokens shows invisible chain-of-thought tokens (billed as output).