# This file was auto-generated by Fern from our API Definition.

import typing

from .. import core
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from .raw_client import AsyncRawImageOperationsClient, RawImageOperationsClient

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class ImageOperationsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawImageOperationsClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawImageOperationsClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawImageOperationsClient
        """
        return self._raw_client

    def list_image_models(
        self,
        *,
        provider: typing.Optional[str] = None,
        capability: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Any]:
        """
        Get a list of available image generation and manipulation models.

            Returns information about all supported image models including:
            - Model capabilities (generation, editing, analysis)
            - Supported resolutions and aspect ratios
            - Provider information
            - Format support

            **Authentication:**
            - Requires either Bearer token or X-API-Key header

            **Query Parameters:**
            - `provider`: Filter by provider (clipdrop, openai, google)
            - `capability`: Filter by capability (text_to_image, image_editing, image_analysis, etc.)

        Parameters
        ----------
        provider : typing.Optional[str]

        capability : typing.Optional[str]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, typing.Any]
            List of available image models

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.image_operations.list_image_models()
        """
        _response = self._raw_client.list_image_models(
            provider=provider, capability=capability, request_options=request_options
        )
        return _response.data

    def remove_background(
        self,
        *,
        provider: str,
        organization_id: str,
        image_file: core.File,
        transparency_handling: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Iterator[bytes]:
        """
        Remove background from an image using Clipdrop.

            **Supported Providers:**
            - `clipdrop`: Removes background and returns transparent PNG

            **Provider-Specific Notes:**
            - OpenAI does not support this operation (returns 422 error)
            - Clipdrop returns PNG with transparency

            **Response Headers:**
            - `X-Provider`: Provider that processed the request
            - `X-Provider-Request-Id`: Provider's request ID (if available)
            - `X-Provider-Credits-Consumed`: Credits consumed (Clipdrop only)

        Parameters
        ----------
        provider : str
            Provider name (must be 'clipdrop')

        organization_id : str
            Organization ID (org_ prefixed string)

        image_file : core.File
            See core.File for more documentation

        transparency_handling : typing.Optional[str]
            Transparency handling mode for Clipdrop

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.Iterator[bytes]
            Background removed successfully
        """
        with self._raw_client.remove_background(
            provider=provider,
            organization_id=organization_id,
            image_file=image_file,
            transparency_handling=transparency_handling,
            request_options=request_options,
        ) as r:
            yield from r.data

    def remove_text(
        self,
        *,
        provider: str,
        organization_id: str,
        image_file: core.File,
        mask_file: typing.Optional[core.File] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Iterator[bytes]:
        """
        Remove text overlays from an image.

            **Supported Providers:**
            - `clipdrop`: Removes text automatically
            - `openai`: Removes text using mask-based editing (requires mask_file)

            **Provider-Specific Requirements:**
            - **Clipdrop**: No mask required
            - **OpenAI**: Requires mask_file (PNG with alpha channel), mask dimensions must match image

            **Response Headers:**
            - `X-Provider`: Provider that processed the request
            - `X-Provider-Request-Id`: Provider's request ID (if available)
            - `X-Provider-Credits-Consumed`: Credits consumed (Clipdrop only)

        Parameters
        ----------
        provider : str
            Provider name ('clipdrop' or 'openai')

        organization_id : str
            Organization ID (org_ prefixed string)

        image_file : core.File
            See core.File for more documentation

        mask_file : typing.Optional[core.File]
            See core.File for more documentation

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.Iterator[bytes]
            Text removed successfully
        """
        with self._raw_client.remove_text(
            provider=provider,
            organization_id=organization_id,
            image_file=image_file,
            mask_file=mask_file,
            request_options=request_options,
        ) as r:
            yield from r.data

    def cleanup(
        self,
        *,
        provider: str,
        organization_id: str,
        image_file: core.File,
        mask_file: typing.Optional[core.File] = OMIT,
        mode: typing.Optional[str] = OMIT,
        prompt: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Iterator[bytes]:
        """
        Remove or replace objects in an image using mask-based editing.

            **Supported Providers:**
            - `clipdrop`: Mask-based cleanup with optional mode parameter
            - `openai`: Mask-based editing with optional prompt

            **Provider-Specific Parameters:**
            - **Clipdrop**: `mode` can be 'fast' or 'quality'
            - **OpenAI**: `prompt` describes desired changes, mask must be PNG with alpha channel

            **Requirements:**
            - Both `image_file` and `mask_file` are required
            - For OpenAI: mask dimensions must match image dimensions

            **Response Headers:**
            - `X-Provider`: Provider that processed the request
            - `X-Provider-Request-Id`: Provider's request ID (if available)
            - `X-Provider-Credits-Consumed`: Credits consumed (Clipdrop only)

        Parameters
        ----------
        provider : str
            Provider name ('clipdrop' or 'openai')

        organization_id : str
            Organization ID (org_ prefixed string)

        image_file : core.File
            See core.File for more documentation

        mask_file : typing.Optional[core.File]
            See core.File for more documentation

        mode : typing.Optional[str]
            Mode for Clipdrop ('fast' or 'quality')

        prompt : typing.Optional[str]
            Prompt for OpenAI/Google describing desired changes

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.Iterator[bytes]
            Cleanup completed successfully
        """
        with self._raw_client.cleanup(
            provider=provider,
            organization_id=organization_id,
            image_file=image_file,
            mask_file=mask_file,
            mode=mode,
            prompt=prompt,
            request_options=request_options,
        ) as r:
            yield from r.data

    def replace_background(
        self,
        *,
        provider: str,
        organization_id: str,
        image_file: core.File,
        mask_file: typing.Optional[core.File] = OMIT,
        prompt: typing.Optional[str] = OMIT,
        accept: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Iterator[bytes]:
        """
        Replace the background of an image with a new scene.

            **Supported Providers:**
            - `clipdrop`: Automatic background replacement with optional prompt
            - `openai`: Mask-based background replacement (requires mask_file)

            **Provider-Specific Requirements:**
            - **Clipdrop**: Optional `prompt` and `accept` header for output format
            - **OpenAI**: Requires `mask_file` (PNG with alpha channel) and `prompt`

            **Output Formats (Clipdrop):**
            - `image/png` (default)
            - `image/webp`
            - `image/jpeg`

            **Response Headers:**
            - `X-Provider`: Provider that processed the request
            - `X-Provider-Request-Id`: Provider's request ID (if available)
            - `X-Provider-Credits-Consumed`: Credits consumed (Clipdrop only)

        Parameters
        ----------
        provider : str
            Provider name ('clipdrop' or 'openai')

        organization_id : str
            Organization ID (org_ prefixed string)

        image_file : core.File
            See core.File for more documentation

        mask_file : typing.Optional[core.File]
            See core.File for more documentation

        prompt : typing.Optional[str]
            Prompt for background generation

        accept : typing.Optional[str]
            Accept header for Clipdrop response format (image/png, image/webp, image/jpeg)

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.Iterator[bytes]
            Background replaced successfully
        """
        with self._raw_client.replace_background(
            provider=provider,
            organization_id=organization_id,
            image_file=image_file,
            mask_file=mask_file,
            prompt=prompt,
            accept=accept,
            request_options=request_options,
        ) as r:
            yield from r.data

    def generate(
        self,
        *,
        provider: str,
        organization_id: str,
        prompt: str,
        size: typing.Optional[str] = OMIT,
        model: typing.Optional[str] = OMIT,
        aspect_ratio: typing.Optional[str] = OMIT,
        image_size: typing.Optional[str] = OMIT,
        quality: typing.Optional[str] = OMIT,
        style: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Iterator[bytes]:
        """
        Generate an image from a text prompt using AI.

            **Supported Providers:**
            - `clipdrop`: Text-to-image generation
            - `openai`: Text-to-image generation with GPT Image models
            - `gemini`: Text-to-image generation with Nano Banana models

            **Provider-Specific Parameters:**
            - **Clipdrop**: Prompt max 1000 characters
            - **OpenAI**: Optional `size` parameter (1024x1024, 1024x1536, or 1536x1024), `model`, `quality`, `style`
            - **Gemini**: Optional `aspect_ratio` (1:1, 16:9, etc.), `image_size` (1K, 2K, 4K), `model`

            **Response Headers:**
            - `X-Provider`: Provider that processed the request
            - `X-Provider-Request-Id`: Provider's request ID (if available)
            - `X-Provider-Credits-Consumed`: Credits consumed (Clipdrop only)

        Parameters
        ----------
        provider : str
            Provider name ('clipdrop', 'openai', or 'google')

        organization_id : str
            Organization ID (org_ prefixed string)

        prompt : str
            Text prompt for image generation (max 1000 chars for Clipdrop)

        size : typing.Optional[str]
            Size parameter for OpenAI (1024x1024, 1024x1536, or 1536x1024)

        model : typing.Optional[str]
            Model to use (OpenAI: dall-e-2, dall-e-3, gpt-image-1.5; Gemini: gemini-2.5-flash-image, gemini-3-pro-image-preview)

        aspect_ratio : typing.Optional[str]
            Aspect ratio for Gemini (1:1, 16:9, 9:16, etc.)

        image_size : typing.Optional[str]
            Image size for Gemini (1K, 2K, 4K)

        quality : typing.Optional[str]
            Quality level (standard, hd, low, medium, high, auto)

        style : typing.Optional[str]
            Artistic style for OpenAI (vivid, natural)

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.Iterator[bytes]
            Image generated successfully

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.image_operations.generate(
            provider="provider",
            organization_id="organization_id",
            prompt="prompt",
        )
        """
        with self._raw_client.generate(
            provider=provider,
            organization_id=organization_id,
            prompt=prompt,
            size=size,
            model=model,
            aspect_ratio=aspect_ratio,
            image_size=image_size,
            quality=quality,
            style=style,
            request_options=request_options,
        ) as r:
            yield from r.data

    def uncrop(
        self,
        *,
        provider: str,
        organization_id: str,
        image_file: core.File,
        extend_left: typing.Optional[int] = OMIT,
        extend_right: typing.Optional[int] = OMIT,
        extend_up: typing.Optional[int] = OMIT,
        extend_down: typing.Optional[int] = OMIT,
        seed: typing.Optional[int] = OMIT,
        mask_file: typing.Optional[core.File] = OMIT,
        size: typing.Optional[str] = OMIT,
        prompt: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Iterator[bytes]:
        """
        Extend an image beyond its original boundaries (uncrop/outpaint).

            **Supported Providers:**
            - `clipdrop`: Extend image with directional parameters
            - `openai`: Outpaint using mask-based editing (requires mask_file)

            **Provider-Specific Parameters:**
            - **Clipdrop**: `extend_left`, `extend_right`, `extend_up`, `extend_down` (max 2000px each), optional `seed`
            - **OpenAI**: Requires `mask_file` (PNG with alpha channel), optional `prompt` and `size`

            **Response Headers:**
            - `X-Provider`: Provider that processed the request
            - `X-Provider-Request-Id`: Provider's request ID (if available)
            - `X-Provider-Credits-Consumed`: Credits consumed (Clipdrop only)

        Parameters
        ----------
        provider : str
            Provider name ('clipdrop' or 'openai')

        organization_id : str
            Organization ID (org_ prefixed string)

        image_file : core.File
            See core.File for more documentation

        extend_left : typing.Optional[int]
            Pixels to extend left (Clipdrop, max 2000)

        extend_right : typing.Optional[int]
            Pixels to extend right (Clipdrop, max 2000)

        extend_up : typing.Optional[int]
            Pixels to extend up (Clipdrop, max 2000)

        extend_down : typing.Optional[int]
            Pixels to extend down (Clipdrop, max 2000)

        seed : typing.Optional[int]
            Random seed for Clipdrop generation

        mask_file : typing.Optional[core.File]
            See core.File for more documentation

        size : typing.Optional[str]
            Size parameter for OpenAI (1024x1024, 1024x1536, or 1536x1024)

        prompt : typing.Optional[str]
            Prompt for OpenAI outpainting

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.Iterator[bytes]
            Image extended successfully
        """
        with self._raw_client.uncrop(
            provider=provider,
            organization_id=organization_id,
            image_file=image_file,
            extend_left=extend_left,
            extend_right=extend_right,
            extend_up=extend_up,
            extend_down=extend_down,
            seed=seed,
            mask_file=mask_file,
            size=size,
            prompt=prompt,
            request_options=request_options,
        ) as r:
            yield from r.data

    def upscale(
        self,
        *,
        provider: str,
        organization_id: str,
        image_file: core.File,
        target_width: int,
        target_height: int,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Iterator[bytes]:
        """
        Upscale an image to a higher resolution while maintaining or improving quality.

            **Supported Providers:**
            - `clipdrop`: AI-powered upscaling

            **Provider-Specific Notes:**
            - OpenAI does not support this operation (returns 422 error)
            - Target dimensions must be between 1 and 12000 pixels

            **Response Headers:**
            - `X-Provider`: Provider that processed the request (always 'clipdrop')
            - `X-Provider-Request-Id`: Provider's request ID (if available)
            - `X-Provider-Credits-Consumed`: Credits consumed by Clipdrop

        Parameters
        ----------
        provider : str
            Provider name (must be 'clipdrop')

        organization_id : str
            Organization ID (org_ prefixed string)

        image_file : core.File
            See core.File for more documentation

        target_width : int
            Target width in pixels (1-12000)

        target_height : int
            Target height in pixels (1-12000)

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.Iterator[bytes]
            Image upscaled successfully
        """
        with self._raw_client.upscale(
            provider=provider,
            organization_id=organization_id,
            image_file=image_file,
            target_width=target_width,
            target_height=target_height,
            request_options=request_options,
        ) as r:
            yield from r.data


class AsyncImageOperationsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawImageOperationsClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawImageOperationsClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawImageOperationsClient
        """
        return self._raw_client

    async def list_image_models(
        self,
        *,
        provider: typing.Optional[str] = None,
        capability: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Any]:
        """
        Get a list of available image generation and manipulation models.

            Returns information about all supported image models including:
            - Model capabilities (generation, editing, analysis)
            - Supported resolutions and aspect ratios
            - Provider information
            - Format support

            **Authentication:**
            - Requires either Bearer token or X-API-Key header

            **Query Parameters:**
            - `provider`: Filter by provider (clipdrop, openai, google)
            - `capability`: Filter by capability (text_to_image, image_editing, image_analysis, etc.)

        Parameters
        ----------
        provider : typing.Optional[str]

        capability : typing.Optional[str]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Dict[str, typing.Any]
            List of available image models

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.image_operations.list_image_models()


        asyncio.run(main())
        """
        _response = await self._raw_client.list_image_models(
            provider=provider, capability=capability, request_options=request_options
        )
        return _response.data

    async def remove_background(
        self,
        *,
        provider: str,
        organization_id: str,
        image_file: core.File,
        transparency_handling: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.AsyncIterator[bytes]:
        """
        Remove background from an image using Clipdrop.

            **Supported Providers:**
            - `clipdrop`: Removes background and returns transparent PNG

            **Provider-Specific Notes:**
            - OpenAI does not support this operation (returns 422 error)
            - Clipdrop returns PNG with transparency

            **Response Headers:**
            - `X-Provider`: Provider that processed the request
            - `X-Provider-Request-Id`: Provider's request ID (if available)
            - `X-Provider-Credits-Consumed`: Credits consumed (Clipdrop only)

        Parameters
        ----------
        provider : str
            Provider name (must be 'clipdrop')

        organization_id : str
            Organization ID (org_ prefixed string)

        image_file : core.File
            See core.File for more documentation

        transparency_handling : typing.Optional[str]
            Transparency handling mode for Clipdrop

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.AsyncIterator[bytes]
            Background removed successfully
        """
        async with self._raw_client.remove_background(
            provider=provider,
            organization_id=organization_id,
            image_file=image_file,
            transparency_handling=transparency_handling,
            request_options=request_options,
        ) as r:
            async for _chunk in r.data:
                yield _chunk

    async def remove_text(
        self,
        *,
        provider: str,
        organization_id: str,
        image_file: core.File,
        mask_file: typing.Optional[core.File] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.AsyncIterator[bytes]:
        """
        Remove text overlays from an image.

            **Supported Providers:**
            - `clipdrop`: Removes text automatically
            - `openai`: Removes text using mask-based editing (requires mask_file)

            **Provider-Specific Requirements:**
            - **Clipdrop**: No mask required
            - **OpenAI**: Requires mask_file (PNG with alpha channel), mask dimensions must match image

            **Response Headers:**
            - `X-Provider`: Provider that processed the request
            - `X-Provider-Request-Id`: Provider's request ID (if available)
            - `X-Provider-Credits-Consumed`: Credits consumed (Clipdrop only)

        Parameters
        ----------
        provider : str
            Provider name ('clipdrop' or 'openai')

        organization_id : str
            Organization ID (org_ prefixed string)

        image_file : core.File
            See core.File for more documentation

        mask_file : typing.Optional[core.File]
            See core.File for more documentation

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.AsyncIterator[bytes]
            Text removed successfully
        """
        async with self._raw_client.remove_text(
            provider=provider,
            organization_id=organization_id,
            image_file=image_file,
            mask_file=mask_file,
            request_options=request_options,
        ) as r:
            async for _chunk in r.data:
                yield _chunk

    async def cleanup(
        self,
        *,
        provider: str,
        organization_id: str,
        image_file: core.File,
        mask_file: typing.Optional[core.File] = OMIT,
        mode: typing.Optional[str] = OMIT,
        prompt: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.AsyncIterator[bytes]:
        """
        Remove or replace objects in an image using mask-based editing.

            **Supported Providers:**
            - `clipdrop`: Mask-based cleanup with optional mode parameter
            - `openai`: Mask-based editing with optional prompt

            **Provider-Specific Parameters:**
            - **Clipdrop**: `mode` can be 'fast' or 'quality'
            - **OpenAI**: `prompt` describes desired changes, mask must be PNG with alpha channel

            **Requirements:**
            - Both `image_file` and `mask_file` are required
            - For OpenAI: mask dimensions must match image dimensions

            **Response Headers:**
            - `X-Provider`: Provider that processed the request
            - `X-Provider-Request-Id`: Provider's request ID (if available)
            - `X-Provider-Credits-Consumed`: Credits consumed (Clipdrop only)

        Parameters
        ----------
        provider : str
            Provider name ('clipdrop' or 'openai')

        organization_id : str
            Organization ID (org_ prefixed string)

        image_file : core.File
            See core.File for more documentation

        mask_file : typing.Optional[core.File]
            See core.File for more documentation

        mode : typing.Optional[str]
            Mode for Clipdrop ('fast' or 'quality')

        prompt : typing.Optional[str]
            Prompt for OpenAI/Google describing desired changes

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.AsyncIterator[bytes]
            Cleanup completed successfully
        """
        async with self._raw_client.cleanup(
            provider=provider,
            organization_id=organization_id,
            image_file=image_file,
            mask_file=mask_file,
            mode=mode,
            prompt=prompt,
            request_options=request_options,
        ) as r:
            async for _chunk in r.data:
                yield _chunk

    async def replace_background(
        self,
        *,
        provider: str,
        organization_id: str,
        image_file: core.File,
        mask_file: typing.Optional[core.File] = OMIT,
        prompt: typing.Optional[str] = OMIT,
        accept: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.AsyncIterator[bytes]:
        """
        Replace the background of an image with a new scene.

            **Supported Providers:**
            - `clipdrop`: Automatic background replacement with optional prompt
            - `openai`: Mask-based background replacement (requires mask_file)

            **Provider-Specific Requirements:**
            - **Clipdrop**: Optional `prompt` and `accept` header for output format
            - **OpenAI**: Requires `mask_file` (PNG with alpha channel) and `prompt`

            **Output Formats (Clipdrop):**
            - `image/png` (default)
            - `image/webp`
            - `image/jpeg`

            **Response Headers:**
            - `X-Provider`: Provider that processed the request
            - `X-Provider-Request-Id`: Provider's request ID (if available)
            - `X-Provider-Credits-Consumed`: Credits consumed (Clipdrop only)

        Parameters
        ----------
        provider : str
            Provider name ('clipdrop' or 'openai')

        organization_id : str
            Organization ID (org_ prefixed string)

        image_file : core.File
            See core.File for more documentation

        mask_file : typing.Optional[core.File]
            See core.File for more documentation

        prompt : typing.Optional[str]
            Prompt for background generation

        accept : typing.Optional[str]
            Accept header for Clipdrop response format (image/png, image/webp, image/jpeg)

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.AsyncIterator[bytes]
            Background replaced successfully
        """
        async with self._raw_client.replace_background(
            provider=provider,
            organization_id=organization_id,
            image_file=image_file,
            mask_file=mask_file,
            prompt=prompt,
            accept=accept,
            request_options=request_options,
        ) as r:
            async for _chunk in r.data:
                yield _chunk

    async def generate(
        self,
        *,
        provider: str,
        organization_id: str,
        prompt: str,
        size: typing.Optional[str] = OMIT,
        model: typing.Optional[str] = OMIT,
        aspect_ratio: typing.Optional[str] = OMIT,
        image_size: typing.Optional[str] = OMIT,
        quality: typing.Optional[str] = OMIT,
        style: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.AsyncIterator[bytes]:
        """
        Generate an image from a text prompt using AI.

            **Supported Providers:**
            - `clipdrop`: Text-to-image generation
            - `openai`: Text-to-image generation with GPT Image models
            - `gemini`: Text-to-image generation with Nano Banana models

            **Provider-Specific Parameters:**
            - **Clipdrop**: Prompt max 1000 characters
            - **OpenAI**: Optional `size` parameter (1024x1024, 1024x1536, or 1536x1024), `model`, `quality`, `style`
            - **Gemini**: Optional `aspect_ratio` (1:1, 16:9, etc.), `image_size` (1K, 2K, 4K), `model`

            **Response Headers:**
            - `X-Provider`: Provider that processed the request
            - `X-Provider-Request-Id`: Provider's request ID (if available)
            - `X-Provider-Credits-Consumed`: Credits consumed (Clipdrop only)

        Parameters
        ----------
        provider : str
            Provider name ('clipdrop', 'openai', or 'google')

        organization_id : str
            Organization ID (org_ prefixed string)

        prompt : str
            Text prompt for image generation (max 1000 chars for Clipdrop)

        size : typing.Optional[str]
            Size parameter for OpenAI (1024x1024, 1024x1536, or 1536x1024)

        model : typing.Optional[str]
            Model to use (OpenAI: dall-e-2, dall-e-3, gpt-image-1.5; Gemini: gemini-2.5-flash-image, gemini-3-pro-image-preview)

        aspect_ratio : typing.Optional[str]
            Aspect ratio for Gemini (1:1, 16:9, 9:16, etc.)

        image_size : typing.Optional[str]
            Image size for Gemini (1K, 2K, 4K)

        quality : typing.Optional[str]
            Quality level (standard, hd, low, medium, high, auto)

        style : typing.Optional[str]
            Artistic style for OpenAI (vivid, natural)

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.AsyncIterator[bytes]
            Image generated successfully

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.image_operations.generate(
                provider="provider",
                organization_id="organization_id",
                prompt="prompt",
            )


        asyncio.run(main())
        """
        async with self._raw_client.generate(
            provider=provider,
            organization_id=organization_id,
            prompt=prompt,
            size=size,
            model=model,
            aspect_ratio=aspect_ratio,
            image_size=image_size,
            quality=quality,
            style=style,
            request_options=request_options,
        ) as r:
            async for _chunk in r.data:
                yield _chunk

    async def uncrop(
        self,
        *,
        provider: str,
        organization_id: str,
        image_file: core.File,
        extend_left: typing.Optional[int] = OMIT,
        extend_right: typing.Optional[int] = OMIT,
        extend_up: typing.Optional[int] = OMIT,
        extend_down: typing.Optional[int] = OMIT,
        seed: typing.Optional[int] = OMIT,
        mask_file: typing.Optional[core.File] = OMIT,
        size: typing.Optional[str] = OMIT,
        prompt: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.AsyncIterator[bytes]:
        """
        Extend an image beyond its original boundaries (uncrop/outpaint).

            **Supported Providers:**
            - `clipdrop`: Extend image with directional parameters
            - `openai`: Outpaint using mask-based editing (requires mask_file)

            **Provider-Specific Parameters:**
            - **Clipdrop**: `extend_left`, `extend_right`, `extend_up`, `extend_down` (max 2000px each), optional `seed`
            - **OpenAI**: Requires `mask_file` (PNG with alpha channel), optional `prompt` and `size`

            **Response Headers:**
            - `X-Provider`: Provider that processed the request
            - `X-Provider-Request-Id`: Provider's request ID (if available)
            - `X-Provider-Credits-Consumed`: Credits consumed (Clipdrop only)

        Parameters
        ----------
        provider : str
            Provider name ('clipdrop' or 'openai')

        organization_id : str
            Organization ID (org_ prefixed string)

        image_file : core.File
            See core.File for more documentation

        extend_left : typing.Optional[int]
            Pixels to extend left (Clipdrop, max 2000)

        extend_right : typing.Optional[int]
            Pixels to extend right (Clipdrop, max 2000)

        extend_up : typing.Optional[int]
            Pixels to extend up (Clipdrop, max 2000)

        extend_down : typing.Optional[int]
            Pixels to extend down (Clipdrop, max 2000)

        seed : typing.Optional[int]
            Random seed for Clipdrop generation

        mask_file : typing.Optional[core.File]
            See core.File for more documentation

        size : typing.Optional[str]
            Size parameter for OpenAI (1024x1024, 1024x1536, or 1536x1024)

        prompt : typing.Optional[str]
            Prompt for OpenAI outpainting

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.AsyncIterator[bytes]
            Image extended successfully
        """
        async with self._raw_client.uncrop(
            provider=provider,
            organization_id=organization_id,
            image_file=image_file,
            extend_left=extend_left,
            extend_right=extend_right,
            extend_up=extend_up,
            extend_down=extend_down,
            seed=seed,
            mask_file=mask_file,
            size=size,
            prompt=prompt,
            request_options=request_options,
        ) as r:
            async for _chunk in r.data:
                yield _chunk

    async def upscale(
        self,
        *,
        provider: str,
        organization_id: str,
        image_file: core.File,
        target_width: int,
        target_height: int,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.AsyncIterator[bytes]:
        """
        Upscale an image to a higher resolution while maintaining or improving quality.

            **Supported Providers:**
            - `clipdrop`: AI-powered upscaling

            **Provider-Specific Notes:**
            - OpenAI does not support this operation (returns 422 error)
            - Target dimensions must be between 1 and 12000 pixels

            **Response Headers:**
            - `X-Provider`: Provider that processed the request (always 'clipdrop')
            - `X-Provider-Request-Id`: Provider's request ID (if available)
            - `X-Provider-Credits-Consumed`: Credits consumed by Clipdrop

        Parameters
        ----------
        provider : str
            Provider name (must be 'clipdrop')

        organization_id : str
            Organization ID (org_ prefixed string)

        image_file : core.File
            See core.File for more documentation

        target_width : int
            Target width in pixels (1-12000)

        target_height : int
            Target height in pixels (1-12000)

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.AsyncIterator[bytes]
            Image upscaled successfully
        """
        async with self._raw_client.upscale(
            provider=provider,
            organization_id=organization_id,
            image_file=image_file,
            target_width=target_width,
            target_height=target_height,
            request_options=request_options,
        ) as r:
            async for _chunk in r.data:
                yield _chunk
