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

import typing
import urllib.parse
from json.decoder import JSONDecodeError

from ..core.api_error import ApiError
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.jsonable_encoder import jsonable_encoder
from ..core.pydantic_utilities import pydantic_v1
from ..core.remove_none_from_dict import remove_none_from_dict
from ..core.request_options import RequestOptions
from .errors.unprocessable_entity_error import UnprocessableEntityError
from .types.http_validation_error import HttpValidationError
from .types.image_generation_request import ImageGenerationRequest
from .types.image_generation_response import ImageGenerationResponse
from .types.video_generation_request_seed import VideoGenerationRequestSeed
from .types.video_generation_response import VideoGenerationResponse

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


class ImageGenClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._client_wrapper = client_wrapper

    def generate_ssd(
        self, *, request: ImageGenerationRequest, request_options: typing.Optional[RequestOptions] = None
    ) -> ImageGenerationResponse:
        """
        Generate images in response to the given request.

        Parameters:
            - request: ImageGenerationRequest.

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from octoai.client import OctoAI
        from octoai.image_gen import ImageGenerationRequest

        client = OctoAI(
            api_key="YOUR_API_KEY",
        )
        client.image_gen.generate_ssd(
            request=ImageGenerationRequest(
                prompt="An octopus playing chess, masterpiece, photorealistic",
            ),
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_environment().image_gen}/", "generate/ssd"),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(ImageGenerationResponse, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def generate_controlnet_sdxl(
        self, *, request: ImageGenerationRequest, request_options: typing.Optional[RequestOptions] = None
    ) -> ImageGenerationResponse:
        """
        Generate images in response to the given request.

        Parameters:
            - request: ImageGenerationRequest.

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from octoai.client import OctoAI
        from octoai.image_gen import ImageGenerationRequest

        client = OctoAI(
            api_key="YOUR_API_KEY",
        )
        client.image_gen.generate_controlnet_sdxl(
            request=ImageGenerationRequest(
                prompt="An octopus playing chess, masterpiece, photorealistic",
            ),
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(
                f"{self._client_wrapper.get_environment().image_gen}/", "generate/controlnet-sdxl"
            ),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(ImageGenerationResponse, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def generate_controlnet_sd15(
        self, *, request: ImageGenerationRequest, request_options: typing.Optional[RequestOptions] = None
    ) -> ImageGenerationResponse:
        """
        Generate images in response to the given request.

        Parameters:
            - request: ImageGenerationRequest.

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from octoai.client import OctoAI
        from octoai.image_gen import ImageGenerationRequest

        client = OctoAI(
            api_key="YOUR_API_KEY",
        )
        client.image_gen.generate_controlnet_sd15(
            request=ImageGenerationRequest(
                prompt="An octopus playing chess, masterpiece, photorealistic",
            ),
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(
                f"{self._client_wrapper.get_environment().image_gen}/", "generate/controlnet-sd15"
            ),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(ImageGenerationResponse, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def generate_sdxl(
        self, *, request: ImageGenerationRequest, request_options: typing.Optional[RequestOptions] = None
    ) -> ImageGenerationResponse:
        """
        Generate images in response to the given request.

        Parameters:
            - request: ImageGenerationRequest.

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from octoai.client import OctoAI
        from octoai.image_gen import ImageGenerationRequest

        client = OctoAI(
            api_key="YOUR_API_KEY",
        )
        client.image_gen.generate_sdxl(
            request=ImageGenerationRequest(
                prompt="An octopus playing chess, masterpiece, photorealistic",
            ),
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_environment().image_gen}/", "generate/sdxl"),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(ImageGenerationResponse, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def generate_sd(
        self, *, request: ImageGenerationRequest, request_options: typing.Optional[RequestOptions] = None
    ) -> ImageGenerationResponse:
        """
        Generate images in response to the given request.

        Parameters:
            - request: ImageGenerationRequest.

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from octoai.client import OctoAI
        from octoai.image_gen import ImageGenerationRequest

        client = OctoAI(
            api_key="YOUR_API_KEY",
        )
        client.image_gen.generate_sd(
            request=ImageGenerationRequest(
                prompt="An octopus playing chess, masterpiece, photorealistic",
            ),
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_environment().image_gen}/", "generate/sd"),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(ImageGenerationResponse, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def generate_svd(
        self,
        *,
        image: str,
        height: typing.Optional[int] = OMIT,
        width: typing.Optional[int] = OMIT,
        cfg_scale: typing.Optional[float] = OMIT,
        steps: typing.Optional[int] = OMIT,
        motion_scale: typing.Optional[float] = OMIT,
        noise_aug_strength: typing.Optional[float] = OMIT,
        num_videos: typing.Optional[int] = OMIT,
        fps: typing.Optional[int] = OMIT,
        seed: typing.Optional[VideoGenerationRequestSeed] = OMIT,
        enable_safety: typing.Optional[bool] = OMIT,
        force_asset_download: typing.Optional[bool] = OMIT,
        force_asset_gpu_copy: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> VideoGenerationResponse:
        """
        Generate videos in response to the given request.

        Parameters:
            - image: str. Starting point image encoded in base64 string.

            - height: typing.Optional[int].

            - width: typing.Optional[int].

            - cfg_scale: typing.Optional[float]. Floating-point number represeting how closely to adhere to 'image'. Must be a positive number no greater than 10.0.

            - steps: typing.Optional[int]. Integer repreenting how many steps of diffusion to run. Must be greater than 0 and less than or equal to 50.

            - motion_scale: typing.Optional[float]. A floating point number between 0.0 and 5.0 indicating how much motion should be in the generated video/animation.

            - noise_aug_strength: typing.Optional[float]. A floating point number between 0.0 and 1.0 indicatiing how much noise to add to the initial image. Higher values encourage creativity.

            - num_videos: typing.Optional[int]. Integer representing how many output videos/animations to generate with a single 'image' and configuration.

            - fps: typing.Optional[int]. Integer representing how fast the generated frames should play back.

            - seed: typing.Optional[VideoGenerationRequestSeed]. Integer number or list of integers representing the seeds of random generators.Fixing random seed is useful when attempting to generate a specific video/animation (or set of videos/animations). Must be greater than 0 and less than 2^32.

            - enable_safety: typing.Optional[bool]. Boolean defining whether to use safety checker system on generated outputs or not.

            - force_asset_download: typing.Optional[bool]. [Internal] Boolean defining if assets must be re-downloaded into the cache even if present.

            - force_asset_gpu_copy: typing.Optional[bool]. [Internal] Boolean defining if assets must to be copied into the GPU even if present.

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from octoai.client import OctoAI

        client = OctoAI(
            api_key="YOUR_API_KEY",
        )
        client.image_gen.generate_svd(
            image="image",
        )
        """
        _request: typing.Dict[str, typing.Any] = {"image": image}
        if height is not OMIT:
            _request["height"] = height
        if width is not OMIT:
            _request["width"] = width
        if cfg_scale is not OMIT:
            _request["cfg_scale"] = cfg_scale
        if steps is not OMIT:
            _request["steps"] = steps
        if motion_scale is not OMIT:
            _request["motion_scale"] = motion_scale
        if noise_aug_strength is not OMIT:
            _request["noise_aug_strength"] = noise_aug_strength
        if num_videos is not OMIT:
            _request["num_videos"] = num_videos
        if fps is not OMIT:
            _request["fps"] = fps
        if seed is not OMIT:
            _request["seed"] = seed
        if enable_safety is not OMIT:
            _request["enable_safety"] = enable_safety
        if force_asset_download is not OMIT:
            _request["force_asset_download"] = force_asset_download
        if force_asset_gpu_copy is not OMIT:
            _request["force_asset_gpu_copy"] = force_asset_gpu_copy
        _response = self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_environment().image_gen}/", "generate/svd"),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(_request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(_request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(VideoGenerationResponse, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)


class AsyncImageGenClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._client_wrapper = client_wrapper

    async def generate_ssd(
        self, *, request: ImageGenerationRequest, request_options: typing.Optional[RequestOptions] = None
    ) -> ImageGenerationResponse:
        """
        Generate images in response to the given request.

        Parameters:
            - request: ImageGenerationRequest.

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from octoai.client import AsyncOctoAI
        from octoai.image_gen import ImageGenerationRequest

        client = AsyncOctoAI(
            api_key="YOUR_API_KEY",
        )
        await client.image_gen.generate_ssd(
            request=ImageGenerationRequest(
                prompt="An octopus playing chess, masterpiece, photorealistic",
            ),
        )
        """
        _response = await self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_environment().image_gen}/", "generate/ssd"),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(ImageGenerationResponse, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def generate_controlnet_sdxl(
        self, *, request: ImageGenerationRequest, request_options: typing.Optional[RequestOptions] = None
    ) -> ImageGenerationResponse:
        """
        Generate images in response to the given request.

        Parameters:
            - request: ImageGenerationRequest.

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from octoai.client import AsyncOctoAI
        from octoai.image_gen import ImageGenerationRequest

        client = AsyncOctoAI(
            api_key="YOUR_API_KEY",
        )
        await client.image_gen.generate_controlnet_sdxl(
            request=ImageGenerationRequest(
                prompt="An octopus playing chess, masterpiece, photorealistic",
            ),
        )
        """
        _response = await self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(
                f"{self._client_wrapper.get_environment().image_gen}/", "generate/controlnet-sdxl"
            ),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(ImageGenerationResponse, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def generate_controlnet_sd15(
        self, *, request: ImageGenerationRequest, request_options: typing.Optional[RequestOptions] = None
    ) -> ImageGenerationResponse:
        """
        Generate images in response to the given request.

        Parameters:
            - request: ImageGenerationRequest.

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from octoai.client import AsyncOctoAI
        from octoai.image_gen import ImageGenerationRequest

        client = AsyncOctoAI(
            api_key="YOUR_API_KEY",
        )
        await client.image_gen.generate_controlnet_sd15(
            request=ImageGenerationRequest(
                prompt="An octopus playing chess, masterpiece, photorealistic",
            ),
        )
        """
        _response = await self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(
                f"{self._client_wrapper.get_environment().image_gen}/", "generate/controlnet-sd15"
            ),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(ImageGenerationResponse, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def generate_sdxl(
        self, *, request: ImageGenerationRequest, request_options: typing.Optional[RequestOptions] = None
    ) -> ImageGenerationResponse:
        """
        Generate images in response to the given request.

        Parameters:
            - request: ImageGenerationRequest.

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from octoai.client import AsyncOctoAI
        from octoai.image_gen import ImageGenerationRequest

        client = AsyncOctoAI(
            api_key="YOUR_API_KEY",
        )
        await client.image_gen.generate_sdxl(
            request=ImageGenerationRequest(
                prompt="An octopus playing chess, masterpiece, photorealistic",
            ),
        )
        """
        _response = await self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_environment().image_gen}/", "generate/sdxl"),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(ImageGenerationResponse, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def generate_sd(
        self, *, request: ImageGenerationRequest, request_options: typing.Optional[RequestOptions] = None
    ) -> ImageGenerationResponse:
        """
        Generate images in response to the given request.

        Parameters:
            - request: ImageGenerationRequest.

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from octoai.client import AsyncOctoAI
        from octoai.image_gen import ImageGenerationRequest

        client = AsyncOctoAI(
            api_key="YOUR_API_KEY",
        )
        await client.image_gen.generate_sd(
            request=ImageGenerationRequest(
                prompt="An octopus playing chess, masterpiece, photorealistic",
            ),
        )
        """
        _response = await self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_environment().image_gen}/", "generate/sd"),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(ImageGenerationResponse, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def generate_svd(
        self,
        *,
        image: str,
        height: typing.Optional[int] = OMIT,
        width: typing.Optional[int] = OMIT,
        cfg_scale: typing.Optional[float] = OMIT,
        steps: typing.Optional[int] = OMIT,
        motion_scale: typing.Optional[float] = OMIT,
        noise_aug_strength: typing.Optional[float] = OMIT,
        num_videos: typing.Optional[int] = OMIT,
        fps: typing.Optional[int] = OMIT,
        seed: typing.Optional[VideoGenerationRequestSeed] = OMIT,
        enable_safety: typing.Optional[bool] = OMIT,
        force_asset_download: typing.Optional[bool] = OMIT,
        force_asset_gpu_copy: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> VideoGenerationResponse:
        """
        Generate videos in response to the given request.

        Parameters:
            - image: str. Starting point image encoded in base64 string.

            - height: typing.Optional[int].

            - width: typing.Optional[int].

            - cfg_scale: typing.Optional[float]. Floating-point number represeting how closely to adhere to 'image'. Must be a positive number no greater than 10.0.

            - steps: typing.Optional[int]. Integer repreenting how many steps of diffusion to run. Must be greater than 0 and less than or equal to 50.

            - motion_scale: typing.Optional[float]. A floating point number between 0.0 and 5.0 indicating how much motion should be in the generated video/animation.

            - noise_aug_strength: typing.Optional[float]. A floating point number between 0.0 and 1.0 indicatiing how much noise to add to the initial image. Higher values encourage creativity.

            - num_videos: typing.Optional[int]. Integer representing how many output videos/animations to generate with a single 'image' and configuration.

            - fps: typing.Optional[int]. Integer representing how fast the generated frames should play back.

            - seed: typing.Optional[VideoGenerationRequestSeed]. Integer number or list of integers representing the seeds of random generators.Fixing random seed is useful when attempting to generate a specific video/animation (or set of videos/animations). Must be greater than 0 and less than 2^32.

            - enable_safety: typing.Optional[bool]. Boolean defining whether to use safety checker system on generated outputs or not.

            - force_asset_download: typing.Optional[bool]. [Internal] Boolean defining if assets must be re-downloaded into the cache even if present.

            - force_asset_gpu_copy: typing.Optional[bool]. [Internal] Boolean defining if assets must to be copied into the GPU even if present.

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from octoai.client import AsyncOctoAI

        client = AsyncOctoAI(
            api_key="YOUR_API_KEY",
        )
        await client.image_gen.generate_svd(
            image="image",
        )
        """
        _request: typing.Dict[str, typing.Any] = {"image": image}
        if height is not OMIT:
            _request["height"] = height
        if width is not OMIT:
            _request["width"] = width
        if cfg_scale is not OMIT:
            _request["cfg_scale"] = cfg_scale
        if steps is not OMIT:
            _request["steps"] = steps
        if motion_scale is not OMIT:
            _request["motion_scale"] = motion_scale
        if noise_aug_strength is not OMIT:
            _request["noise_aug_strength"] = noise_aug_strength
        if num_videos is not OMIT:
            _request["num_videos"] = num_videos
        if fps is not OMIT:
            _request["fps"] = fps
        if seed is not OMIT:
            _request["seed"] = seed
        if enable_safety is not OMIT:
            _request["enable_safety"] = enable_safety
        if force_asset_download is not OMIT:
            _request["force_asset_download"] = force_asset_download
        if force_asset_gpu_copy is not OMIT:
            _request["force_asset_gpu_copy"] = force_asset_gpu_copy
        _response = await self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_environment().image_gen}/", "generate/svd"),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(_request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(_request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(VideoGenerationResponse, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)
