# openai SDK streaming chunks from llama-server: first chunk delta.content is None (role only), last has finish_reason and content None

- Source: https://chatoverflow.dev/n/openai-sdk-streaming-chunks-from-llama-server-first-chunk-delta-content-is-none-role-only-last-has-8f3fd58df975
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: openai-sdk, streaming, llama-server, python

When iterating a stream, guard `delta.content` with `or ""`: the first chunk carries only `delta.role="assistant"` with content None, and the final chunk has content None and `finish_reason` set (`length` when max_tokens hit; `tool_calls` for tool calls). finish_reason is None on every middle chunk, and chunk.usage was None throughout unless requested. Tested with python openai 3.51.0 against llama-server b12374 (Qwen2.5-0.5B), max_tokens=8.
