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

from __future__ import annotations
from .imagegenerationresponse import ImageUsage, ImageUsageTypedDict
from r9s.types import BaseModel
from typing import Any, Dict, Optional
from typing_extensions import NotRequired, TypedDict


class ImageEditStreamEventTypedDict(TypedDict):
    """Image edit streaming event - flexible structure to accommodate various server responses"""

    type: str
    r"""Event type (e.g., 'image_edit.partial', 'image_edit.final', 'image_edit.chunk')"""

    # Core fields
    index: NotRequired[int]
    b64_json: NotRequired[str]
    url: NotRequired[str]
    progress: NotRequired[float]
    is_final: NotRequired[bool]
    revised_prompt: NotRequired[str]

    # Standard fields (may be present)
    id: NotRequired[str]
    created: NotRequired[int]
    model: NotRequired[str]
    object: NotRequired[str]

    # Additional fields
    output_format: NotRequired[str]
    usage: NotRequired[ImageUsageTypedDict]


class ImageEditStreamEvent(BaseModel):
    """Image edit streaming event - flexible structure to accommodate various server responses"""

    type: str
    r"""Event type (e.g., 'image_edit.partial', 'image_edit.final', 'image_edit.chunk')"""

    # Core fields
    index: Optional[int] = None
    r"""Image index in the batch"""

    b64_json: Optional[str] = None
    r"""Base64-encoded partial or final image"""

    url: Optional[str] = None
    r"""Image URL (alternative to b64_json)"""

    progress: Optional[float] = None
    r"""Generation progress (0.0-1.0)"""

    is_final: Optional[bool] = None
    r"""Whether this is the final image"""

    revised_prompt: Optional[str] = None
    r"""Revised prompt (if applicable)"""

    # Standard fields (may be present)
    id: Optional[str] = None
    r"""Unique edit request identifier"""

    created: Optional[int] = None
    r"""Unix timestamp"""

    model: Optional[str] = None
    r"""Model used for editing"""

    object: Optional[str] = None
    r"""Object type identifier"""

    # Additional fields
    output_format: Optional[str] = None
    r"""Output format of the image"""

    usage: Optional[ImageUsage] = None
    r"""Usage statistics (only in final chunk)"""

    # Catch-all for any additional fields
    class Config:
        extra = "allow"
