The model stream stops generating output mid-sentence.
Why this happens
A null finish reason is normal on intermediate streaming chunks. Check the final finish reason before diagnosing truncation: length signals an output limit. A dropped stream or client cancellation needs separate investigation.
Answer 1: Raise the output token budget
from openai import OpenAI
client = OpenAI()
stream = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Write a story"}],
max_tokens=2048,
stream=True
)
Reference: OpenAI streaming response fields.
