diff --git a/pydantic_ai_slim/pydantic_ai/models/openai.py b/pydantic_ai_slim/pydantic_ai/models/openai.py index 7ff5b2f7f9..e5ca4325e5 100644 --- a/pydantic_ai_slim/pydantic_ai/models/openai.py +++ b/pydantic_ai_slim/pydantic_ai/models/openai.py @@ -1172,8 +1172,7 @@ async def _get_event_iterator(self) -> AsyncIterator[ModelResponseStreamEvent]: continue # Handle the text part of the response - content = choice.delta.content - if content is not None: + if (delta := choice.delta) is not None and (content := delta.content) is not None: maybe_event = self._parts_manager.handle_text_delta( vendor_part_id='content', content=content,