"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from .openairesponsesannotation import (
    OpenAIResponsesAnnotation,
    OpenAIResponsesAnnotationTypedDict,
)
from .openairesponsesrefusalcontent import (
    OpenAIResponsesRefusalContent,
    OpenAIResponsesRefusalContentTypedDict,
)
from .openresponseserrorevent import (
    OpenResponsesErrorEvent,
    OpenResponsesErrorEventTypedDict,
)
from .openresponsesimagegencallcompleted import (
    OpenResponsesImageGenCallCompleted,
    OpenResponsesImageGenCallCompletedTypedDict,
)
from .openresponsesimagegencallgenerating import (
    OpenResponsesImageGenCallGenerating,
    OpenResponsesImageGenCallGeneratingTypedDict,
)
from .openresponsesimagegencallinprogress import (
    OpenResponsesImageGenCallInProgress,
    OpenResponsesImageGenCallInProgressTypedDict,
)
from .openresponsesimagegencallpartialimage import (
    OpenResponsesImageGenCallPartialImage,
    OpenResponsesImageGenCallPartialImageTypedDict,
)
from .openresponseslogprobs import OpenResponsesLogProbs, OpenResponsesLogProbsTypedDict
from .openresponsesnonstreamingresponse import (
    OpenResponsesNonStreamingResponse,
    OpenResponsesNonStreamingResponseTypedDict,
)
from .openresponsesreasoningdeltaevent import (
    OpenResponsesReasoningDeltaEvent,
    OpenResponsesReasoningDeltaEventTypedDict,
)
from .openresponsesreasoningdoneevent import (
    OpenResponsesReasoningDoneEvent,
    OpenResponsesReasoningDoneEventTypedDict,
)
from .openresponsesreasoningsummarypartaddedevent import (
    OpenResponsesReasoningSummaryPartAddedEvent,
    OpenResponsesReasoningSummaryPartAddedEventTypedDict,
)
from .openresponsesreasoningsummarytextdeltaevent import (
    OpenResponsesReasoningSummaryTextDeltaEvent,
    OpenResponsesReasoningSummaryTextDeltaEventTypedDict,
)
from .openresponsesreasoningsummarytextdoneevent import (
    OpenResponsesReasoningSummaryTextDoneEvent,
    OpenResponsesReasoningSummaryTextDoneEventTypedDict,
)
from .reasoningsummarytext import ReasoningSummaryText, ReasoningSummaryTextTypedDict
from .reasoningtextcontent import ReasoningTextContent, ReasoningTextContentTypedDict
from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict
from .responsesoutputitem import ResponsesOutputItem, ResponsesOutputItemTypedDict
from openrouter.types import BaseModel
from typing import List, Literal, Union
from typing_extensions import TypeAliasType, TypedDict


TypeResponseReasoningSummaryPartDone = Literal["response.reasoning_summary_part.done",]


class OpenResponsesStreamEventResponseReasoningSummaryPartDoneTypedDict(TypedDict):
    r"""Event emitted when a reasoning summary part is complete"""

    type: TypeResponseReasoningSummaryPartDone
    output_index: float
    item_id: str
    summary_index: float
    part: ReasoningSummaryTextTypedDict
    sequence_number: float


class OpenResponsesStreamEventResponseReasoningSummaryPartDone(BaseModel):
    r"""Event emitted when a reasoning summary part is complete"""

    type: TypeResponseReasoningSummaryPartDone

    output_index: float

    item_id: str

    summary_index: float

    part: ReasoningSummaryText

    sequence_number: float


TypeResponseFunctionCallArgumentsDone = Literal[
    "response.function_call_arguments.done",
]


class OpenResponsesStreamEventResponseFunctionCallArgumentsDoneTypedDict(TypedDict):
    r"""Event emitted when function call arguments streaming is complete"""

    type: TypeResponseFunctionCallArgumentsDone
    item_id: str
    output_index: float
    name: str
    arguments: str
    sequence_number: float


class OpenResponsesStreamEventResponseFunctionCallArgumentsDone(BaseModel):
    r"""Event emitted when function call arguments streaming is complete"""

    type: TypeResponseFunctionCallArgumentsDone

    item_id: str

    output_index: float

    name: str

    arguments: str

    sequence_number: float


TypeResponseFunctionCallArgumentsDelta = Literal[
    "response.function_call_arguments.delta",
]


class OpenResponsesStreamEventResponseFunctionCallArgumentsDeltaTypedDict(TypedDict):
    r"""Event emitted when function call arguments are being streamed"""

    type: TypeResponseFunctionCallArgumentsDelta
    item_id: str
    output_index: float
    delta: str
    sequence_number: float


class OpenResponsesStreamEventResponseFunctionCallArgumentsDelta(BaseModel):
    r"""Event emitted when function call arguments are being streamed"""

    type: TypeResponseFunctionCallArgumentsDelta

    item_id: str

    output_index: float

    delta: str

    sequence_number: float


TypeResponseOutputTextAnnotationAdded = Literal[
    "response.output_text.annotation.added",
]


class OpenResponsesStreamEventResponseOutputTextAnnotationAddedTypedDict(TypedDict):
    r"""Event emitted when a text annotation is added to output"""

    type: TypeResponseOutputTextAnnotationAdded
    output_index: float
    item_id: str
    content_index: float
    sequence_number: float
    annotation_index: float
    annotation: OpenAIResponsesAnnotationTypedDict


class OpenResponsesStreamEventResponseOutputTextAnnotationAdded(BaseModel):
    r"""Event emitted when a text annotation is added to output"""

    type: TypeResponseOutputTextAnnotationAdded

    output_index: float

    item_id: str

    content_index: float

    sequence_number: float

    annotation_index: float

    annotation: OpenAIResponsesAnnotation


TypeResponseRefusalDone = Literal["response.refusal.done",]


class OpenResponsesStreamEventResponseRefusalDoneTypedDict(TypedDict):
    r"""Event emitted when refusal streaming is complete"""

    type: TypeResponseRefusalDone
    output_index: float
    item_id: str
    content_index: float
    refusal: str
    sequence_number: float


class OpenResponsesStreamEventResponseRefusalDone(BaseModel):
    r"""Event emitted when refusal streaming is complete"""

    type: TypeResponseRefusalDone

    output_index: float

    item_id: str

    content_index: float

    refusal: str

    sequence_number: float


TypeResponseRefusalDelta = Literal["response.refusal.delta",]


class OpenResponsesStreamEventResponseRefusalDeltaTypedDict(TypedDict):
    r"""Event emitted when a refusal delta is streamed"""

    type: TypeResponseRefusalDelta
    output_index: float
    item_id: str
    content_index: float
    delta: str
    sequence_number: float


class OpenResponsesStreamEventResponseRefusalDelta(BaseModel):
    r"""Event emitted when a refusal delta is streamed"""

    type: TypeResponseRefusalDelta

    output_index: float

    item_id: str

    content_index: float

    delta: str

    sequence_number: float


TypeResponseOutputTextDone = Literal["response.output_text.done",]


class OpenResponsesStreamEventResponseOutputTextDoneTypedDict(TypedDict):
    r"""Event emitted when text streaming is complete"""

    type: TypeResponseOutputTextDone
    output_index: float
    item_id: str
    content_index: float
    text: str
    sequence_number: float
    logprobs: List[OpenResponsesLogProbsTypedDict]


class OpenResponsesStreamEventResponseOutputTextDone(BaseModel):
    r"""Event emitted when text streaming is complete"""

    type: TypeResponseOutputTextDone

    output_index: float

    item_id: str

    content_index: float

    text: str

    sequence_number: float

    logprobs: List[OpenResponsesLogProbs]


TypeResponseOutputTextDelta = Literal["response.output_text.delta",]


class OpenResponsesStreamEventResponseOutputTextDeltaTypedDict(TypedDict):
    r"""Event emitted when a text delta is streamed"""

    type: TypeResponseOutputTextDelta
    logprobs: List[OpenResponsesLogProbsTypedDict]
    output_index: float
    item_id: str
    content_index: float
    delta: str
    sequence_number: float


class OpenResponsesStreamEventResponseOutputTextDelta(BaseModel):
    r"""Event emitted when a text delta is streamed"""

    type: TypeResponseOutputTextDelta

    logprobs: List[OpenResponsesLogProbs]

    output_index: float

    item_id: str

    content_index: float

    delta: str

    sequence_number: float


TypeResponseContentPartDone = Literal["response.content_part.done",]


Part2TypedDict = TypeAliasType(
    "Part2TypedDict",
    Union[
        ReasoningTextContentTypedDict,
        OpenAIResponsesRefusalContentTypedDict,
        ResponseOutputTextTypedDict,
    ],
)


Part2 = TypeAliasType(
    "Part2",
    Union[ReasoningTextContent, OpenAIResponsesRefusalContent, ResponseOutputText],
)


class OpenResponsesStreamEventResponseContentPartDoneTypedDict(TypedDict):
    r"""Event emitted when a content part is complete"""

    type: TypeResponseContentPartDone
    output_index: float
    item_id: str
    content_index: float
    part: Part2TypedDict
    sequence_number: float


class OpenResponsesStreamEventResponseContentPartDone(BaseModel):
    r"""Event emitted when a content part is complete"""

    type: TypeResponseContentPartDone

    output_index: float

    item_id: str

    content_index: float

    part: Part2

    sequence_number: float


TypeResponseContentPartAdded = Literal["response.content_part.added",]


Part1TypedDict = TypeAliasType(
    "Part1TypedDict",
    Union[
        ReasoningTextContentTypedDict,
        OpenAIResponsesRefusalContentTypedDict,
        ResponseOutputTextTypedDict,
    ],
)


Part1 = TypeAliasType(
    "Part1",
    Union[ReasoningTextContent, OpenAIResponsesRefusalContent, ResponseOutputText],
)


class OpenResponsesStreamEventResponseContentPartAddedTypedDict(TypedDict):
    r"""Event emitted when a new content part is added to an output item"""

    type: TypeResponseContentPartAdded
    output_index: float
    item_id: str
    content_index: float
    part: Part1TypedDict
    sequence_number: float


class OpenResponsesStreamEventResponseContentPartAdded(BaseModel):
    r"""Event emitted when a new content part is added to an output item"""

    type: TypeResponseContentPartAdded

    output_index: float

    item_id: str

    content_index: float

    part: Part1

    sequence_number: float


TypeResponseOutputItemDone = Literal["response.output_item.done",]


class OpenResponsesStreamEventResponseOutputItemDoneTypedDict(TypedDict):
    r"""Event emitted when an output item is complete"""

    type: TypeResponseOutputItemDone
    output_index: float
    item: ResponsesOutputItemTypedDict
    r"""An output item from the response"""
    sequence_number: float


class OpenResponsesStreamEventResponseOutputItemDone(BaseModel):
    r"""Event emitted when an output item is complete"""

    type: TypeResponseOutputItemDone

    output_index: float

    item: ResponsesOutputItem
    r"""An output item from the response"""

    sequence_number: float


TypeResponseOutputItemAdded = Literal["response.output_item.added",]


class OpenResponsesStreamEventResponseOutputItemAddedTypedDict(TypedDict):
    r"""Event emitted when a new output item is added to the response"""

    type: TypeResponseOutputItemAdded
    output_index: float
    item: ResponsesOutputItemTypedDict
    r"""An output item from the response"""
    sequence_number: float


class OpenResponsesStreamEventResponseOutputItemAdded(BaseModel):
    r"""Event emitted when a new output item is added to the response"""

    type: TypeResponseOutputItemAdded

    output_index: float

    item: ResponsesOutputItem
    r"""An output item from the response"""

    sequence_number: float


TypeResponseFailed = Literal["response.failed",]


class OpenResponsesStreamEventResponseFailedTypedDict(TypedDict):
    r"""Event emitted when a response has failed"""

    type: TypeResponseFailed
    response: OpenResponsesNonStreamingResponseTypedDict
    r"""Complete non-streaming response from the Responses API"""
    sequence_number: float


class OpenResponsesStreamEventResponseFailed(BaseModel):
    r"""Event emitted when a response has failed"""

    type: TypeResponseFailed

    response: OpenResponsesNonStreamingResponse
    r"""Complete non-streaming response from the Responses API"""

    sequence_number: float


TypeResponseIncomplete = Literal["response.incomplete",]


class OpenResponsesStreamEventResponseIncompleteTypedDict(TypedDict):
    r"""Event emitted when a response is incomplete"""

    type: TypeResponseIncomplete
    response: OpenResponsesNonStreamingResponseTypedDict
    r"""Complete non-streaming response from the Responses API"""
    sequence_number: float


class OpenResponsesStreamEventResponseIncomplete(BaseModel):
    r"""Event emitted when a response is incomplete"""

    type: TypeResponseIncomplete

    response: OpenResponsesNonStreamingResponse
    r"""Complete non-streaming response from the Responses API"""

    sequence_number: float


TypeResponseCompleted = Literal["response.completed",]


class OpenResponsesStreamEventResponseCompletedTypedDict(TypedDict):
    r"""Event emitted when a response has completed successfully"""

    type: TypeResponseCompleted
    response: OpenResponsesNonStreamingResponseTypedDict
    r"""Complete non-streaming response from the Responses API"""
    sequence_number: float


class OpenResponsesStreamEventResponseCompleted(BaseModel):
    r"""Event emitted when a response has completed successfully"""

    type: TypeResponseCompleted

    response: OpenResponsesNonStreamingResponse
    r"""Complete non-streaming response from the Responses API"""

    sequence_number: float


TypeResponseInProgress = Literal["response.in_progress",]


class OpenResponsesStreamEventResponseInProgressTypedDict(TypedDict):
    r"""Event emitted when a response is in progress"""

    type: TypeResponseInProgress
    response: OpenResponsesNonStreamingResponseTypedDict
    r"""Complete non-streaming response from the Responses API"""
    sequence_number: float


class OpenResponsesStreamEventResponseInProgress(BaseModel):
    r"""Event emitted when a response is in progress"""

    type: TypeResponseInProgress

    response: OpenResponsesNonStreamingResponse
    r"""Complete non-streaming response from the Responses API"""

    sequence_number: float


TypeResponseCreated = Literal["response.created",]


class OpenResponsesStreamEventResponseCreatedTypedDict(TypedDict):
    r"""Event emitted when a response is created"""

    type: TypeResponseCreated
    response: OpenResponsesNonStreamingResponseTypedDict
    r"""Complete non-streaming response from the Responses API"""
    sequence_number: float


class OpenResponsesStreamEventResponseCreated(BaseModel):
    r"""Event emitted when a response is created"""

    type: TypeResponseCreated

    response: OpenResponsesNonStreamingResponse
    r"""Complete non-streaming response from the Responses API"""

    sequence_number: float


OpenResponsesStreamEventTypedDict = TypeAliasType(
    "OpenResponsesStreamEventTypedDict",
    Union[
        OpenResponsesStreamEventResponseCreatedTypedDict,
        OpenResponsesStreamEventResponseInProgressTypedDict,
        OpenResponsesStreamEventResponseCompletedTypedDict,
        OpenResponsesStreamEventResponseIncompleteTypedDict,
        OpenResponsesStreamEventResponseFailedTypedDict,
        OpenResponsesStreamEventResponseOutputItemAddedTypedDict,
        OpenResponsesStreamEventResponseOutputItemDoneTypedDict,
        OpenResponsesImageGenCallCompletedTypedDict,
        OpenResponsesImageGenCallGeneratingTypedDict,
        OpenResponsesImageGenCallInProgressTypedDict,
        OpenResponsesErrorEventTypedDict,
        OpenResponsesStreamEventResponseFunctionCallArgumentsDeltaTypedDict,
        OpenResponsesStreamEventResponseRefusalDeltaTypedDict,
        OpenResponsesReasoningSummaryPartAddedEventTypedDict,
        OpenResponsesStreamEventResponseContentPartAddedTypedDict,
        OpenResponsesImageGenCallPartialImageTypedDict,
        OpenResponsesStreamEventResponseFunctionCallArgumentsDoneTypedDict,
        OpenResponsesReasoningDeltaEventTypedDict,
        OpenResponsesReasoningDoneEventTypedDict,
        OpenResponsesStreamEventResponseRefusalDoneTypedDict,
        OpenResponsesStreamEventResponseReasoningSummaryPartDoneTypedDict,
        OpenResponsesReasoningSummaryTextDeltaEventTypedDict,
        OpenResponsesReasoningSummaryTextDoneEventTypedDict,
        OpenResponsesStreamEventResponseContentPartDoneTypedDict,
        OpenResponsesStreamEventResponseOutputTextDeltaTypedDict,
        OpenResponsesStreamEventResponseOutputTextDoneTypedDict,
        OpenResponsesStreamEventResponseOutputTextAnnotationAddedTypedDict,
    ],
)
r"""Union of all possible event types emitted during response streaming"""


OpenResponsesStreamEvent = TypeAliasType(
    "OpenResponsesStreamEvent",
    Union[
        OpenResponsesStreamEventResponseCreated,
        OpenResponsesStreamEventResponseInProgress,
        OpenResponsesStreamEventResponseCompleted,
        OpenResponsesStreamEventResponseIncomplete,
        OpenResponsesStreamEventResponseFailed,
        OpenResponsesStreamEventResponseOutputItemAdded,
        OpenResponsesStreamEventResponseOutputItemDone,
        OpenResponsesImageGenCallCompleted,
        OpenResponsesImageGenCallGenerating,
        OpenResponsesImageGenCallInProgress,
        OpenResponsesErrorEvent,
        OpenResponsesStreamEventResponseFunctionCallArgumentsDelta,
        OpenResponsesStreamEventResponseRefusalDelta,
        OpenResponsesReasoningSummaryPartAddedEvent,
        OpenResponsesStreamEventResponseContentPartAdded,
        OpenResponsesImageGenCallPartialImage,
        OpenResponsesStreamEventResponseFunctionCallArgumentsDone,
        OpenResponsesReasoningDeltaEvent,
        OpenResponsesReasoningDoneEvent,
        OpenResponsesStreamEventResponseRefusalDone,
        OpenResponsesStreamEventResponseReasoningSummaryPartDone,
        OpenResponsesReasoningSummaryTextDeltaEvent,
        OpenResponsesReasoningSummaryTextDoneEvent,
        OpenResponsesStreamEventResponseContentPartDone,
        OpenResponsesStreamEventResponseOutputTextDelta,
        OpenResponsesStreamEventResponseOutputTextDone,
        OpenResponsesStreamEventResponseOutputTextAnnotationAdded,
    ],
)
r"""Union of all possible event types emitted during response streaming"""
