Implementation:Openai Openai python Response Content Part Done Event
| Knowledge Sources | |
|---|---|
| Domains | API_Types, Responses_API |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete streaming event type emitted when a content part within a response output item is done, provided by the openai-python SDK.
Description
ResponseContentPartDoneEvent is a Pydantic model representing a streaming event emitted when a content part finishes. It includes content_index (the position of the completed content part), item_id (the ID of the parent output item), output_index (position of the output item), a part field containing the finished content (which can be ResponseOutputText, ResponseOutputRefusal, or PartReasoningText), a sequence_number for ordering, and a fixed type of "response.content_part.done". The Part type alias is a discriminated union keyed on type. This type is auto-generated from the OpenAI OpenAPI specification by Stainless.
Usage
Import ResponseContentPartDoneEvent when handling streaming events and you need to detect that a specific content part (text, refusal, or reasoning text) has finished streaming.
Code Reference
Source Location
- Repository: openai-python
- File: src/openai/types/responses/response_content_part_done_event.py
Signature
class ResponseContentPartDoneEvent(BaseModel):
"""Emitted when a content part is done."""
content_index: int
item_id: str
output_index: int
part: Part
sequence_number: int
type: Literal["response.content_part.done"]
Import
from openai.types.responses import ResponseContentPartDoneEvent
I/O Contract
Fields
| Name | Type | Required | Description |
|---|---|---|---|
| content_index | int |
Yes | The index of the content part that is done. |
| item_id | str |
Yes | The ID of the output item that the content part was added to. |
| output_index | int |
Yes | The index of the output item that the content part was added to. |
| part | Part |
Yes | The content part that is done. One of ResponseOutputText, ResponseOutputRefusal, or PartReasoningText.
|
| sequence_number | int |
Yes | The sequence number of this event. |
| type | Literal["response.content_part.done"] |
Yes | The type of the event. Always "response.content_part.done".
|
Part Sub-Types
| Type | Discriminator Value | Description |
|---|---|---|
| ResponseOutputText | "output_text" |
Completed text output from the model. |
| ResponseOutputRefusal | "refusal" |
A refusal response from the model. |
| PartReasoningText | "reasoning_text" |
Reasoning text from the model. |
Usage Examples
from openai.types.responses import ResponseContentPartDoneEvent
# Processing streaming events
for event in stream:
if isinstance(event, ResponseContentPartDoneEvent):
print(f"Content part {event.content_index} done for item {event.item_id}")
if event.part.type == "output_text":
print(f"Text: {event.part.text}")
elif event.part.type == "refusal":
print(f"Refusal: {event.part.refusal}")