# This file was auto-generated by Fern from our API Definition. import typing from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.request_options import RequestOptions from ...types.image_generation_request import ImageGenerationRequest from ...types.media_generation_create_response import MediaGenerationCreateResponse from ...types.media_generation_list_response import MediaGenerationListResponse from ...types.media_generation_response import MediaGenerationResponse from .raw_client import AsyncRawImageClient, RawImageClient from .types.image_list_request_status import ImageListRequestStatus # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) class ImageClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawImageClient(client_wrapper=client_wrapper) @property def with_raw_response(self) -> RawImageClient: """ Retrieves a raw implementation of this client that returns raw responses. Returns ------- RawImageClient """ return self._raw_client def list( self, *, cursor: typing.Optional[str] = None, page_size: typing.Optional[int] = None, status: typing.Optional[ImageListRequestStatus] = None, model_id: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None, ) -> MediaGenerationListResponse: """ List the image generations created through this API, newest first. Parameters ---------- cursor : typing.Optional[str] Pagination cursor: the `next_cursor` value of the previous page's response. Omit it for the first page. page_size : typing.Optional[int] How many generations to return per page. status : typing.Optional[ImageListRequestStatus] Only return generations with this lifecycle status. model_id : typing.Optional[str] Only return generations of this model. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- MediaGenerationListResponse Successful Response Examples -------- from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) client.flows.image.list( cursor="cursor", page_size=1, status="pending", model_id="model_id", ) """ _response = self._raw_client.list( cursor=cursor, page_size=page_size, status=status, model_id=model_id, request_options=request_options ) return _response.data def create( self, *, request: ImageGenerationRequest, request_options: typing.Optional[RequestOptions] = None ) -> MediaGenerationCreateResponse: """ Start an image generation with the selected model. Parameters ---------- request : ImageGenerationRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- MediaGenerationCreateResponse Successful Response Examples -------- from elevenlabs import ElevenLabs, ImageGenerationRequest_BytedanceSeedream5Lite client = ElevenLabs( api_key="YOUR_API_KEY", ) client.flows.image.create( request=ImageGenerationRequest_BytedanceSeedream5Lite( prompt="A corgi in a tiny lifeguard chair on a sunlit beach at golden hour, photorealistic", ), ) """ _response = self._raw_client.create(request=request, request_options=request_options) return _response.data def get( self, generation_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> MediaGenerationResponse: """ Retrieve the status of an image generation, and retrieve its output URL once completed. Parameters ---------- generation_id : str request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- MediaGenerationResponse Successful Response Examples -------- from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) client.flows.image.get( generation_id="generation_id", ) """ _response = self._raw_client.get(generation_id, request_options=request_options) return _response.data class AsyncImageClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawImageClient(client_wrapper=client_wrapper) @property def with_raw_response(self) -> AsyncRawImageClient: """ Retrieves a raw implementation of this client that returns raw responses. Returns ------- AsyncRawImageClient """ return self._raw_client async def list( self, *, cursor: typing.Optional[str] = None, page_size: typing.Optional[int] = None, status: typing.Optional[ImageListRequestStatus] = None, model_id: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None, ) -> MediaGenerationListResponse: """ List the image generations created through this API, newest first. Parameters ---------- cursor : typing.Optional[str] Pagination cursor: the `next_cursor` value of the previous page's response. Omit it for the first page. page_size : typing.Optional[int] How many generations to return per page. status : typing.Optional[ImageListRequestStatus] Only return generations with this lifecycle status. model_id : typing.Optional[str] Only return generations of this model. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- MediaGenerationListResponse Successful Response Examples -------- import asyncio from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", ) async def main() -> None: await client.flows.image.list( cursor="cursor", page_size=1, status="pending", model_id="model_id", ) asyncio.run(main()) """ _response = await self._raw_client.list( cursor=cursor, page_size=page_size, status=status, model_id=model_id, request_options=request_options ) return _response.data async def create( self, *, request: ImageGenerationRequest, request_options: typing.Optional[RequestOptions] = None ) -> MediaGenerationCreateResponse: """ Start an image generation with the selected model. Parameters ---------- request : ImageGenerationRequest request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- MediaGenerationCreateResponse Successful Response Examples -------- import asyncio from elevenlabs import ( AsyncElevenLabs, ImageGenerationRequest_BytedanceSeedream5Lite, ) client = AsyncElevenLabs( api_key="YOUR_API_KEY", ) async def main() -> None: await client.flows.image.create( request=ImageGenerationRequest_BytedanceSeedream5Lite( prompt="A corgi in a tiny lifeguard chair on a sunlit beach at golden hour, photorealistic", ), ) asyncio.run(main()) """ _response = await self._raw_client.create(request=request, request_options=request_options) return _response.data async def get( self, generation_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> MediaGenerationResponse: """ Retrieve the status of an image generation, and retrieve its output URL once completed. Parameters ---------- generation_id : str request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- MediaGenerationResponse Successful Response Examples -------- import asyncio from elevenlabs import AsyncElevenLabs client = AsyncElevenLabs( api_key="YOUR_API_KEY", ) async def main() -> None: await client.flows.image.get( generation_id="generation_id", ) asyncio.run(main()) """ _response = await self._raw_client.get(generation_id, request_options=request_options) return _response.data