Download data/src/elevenlabs/flows/video/client.py from introvoyz045/elevenlabs-python: direct link, hf CLI and curl.
- Browser
- Download file 9.29 kB
-
https://huggingface.co/datasets/introvoyz045/elevenlabs-python/resolve/main/data/src/elevenlabs/flows/video/client.py
- Command line
-
hf download hf://datasets/introvoyz045/elevenlabs-python/data/src/elevenlabs/flows/video/client.py
-
curl -L -o client.py https://huggingface.co/datasets/introvoyz045/elevenlabs-python/resolve/main/data/src/elevenlabs/flows/video/client.py
9.29 kB
| # 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.media_generation_create_response import MediaGenerationCreateResponse | |
| from ...types.media_generation_list_response import MediaGenerationListResponse | |
| from ...types.media_generation_response import MediaGenerationResponse | |
| from ...types.video_generation_request import VideoGenerationRequest | |
| from .raw_client import AsyncRawVideoClient, RawVideoClient | |
| from .types.video_list_request_status import VideoListRequestStatus | |
| # this is used as the default value for optional parameters | |
| OMIT = typing.cast(typing.Any, ...) | |
| class VideoClient: | |
| def __init__(self, *, client_wrapper: SyncClientWrapper): | |
| self._raw_client = RawVideoClient(client_wrapper=client_wrapper) | |
| def with_raw_response(self) -> RawVideoClient: | |
| """ | |
| Retrieves a raw implementation of this client that returns raw responses. | |
| Returns | |
| ------- | |
| RawVideoClient | |
| """ | |
| return self._raw_client | |
| def list( | |
| self, | |
| *, | |
| cursor: typing.Optional[str] = None, | |
| page_size: typing.Optional[int] = None, | |
| status: typing.Optional[VideoListRequestStatus] = None, | |
| model_id: typing.Optional[str] = None, | |
| request_options: typing.Optional[RequestOptions] = None, | |
| ) -> MediaGenerationListResponse: | |
| """ | |
| List the video 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[VideoListRequestStatus] | |
| 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.video.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: VideoGenerationRequest, request_options: typing.Optional[RequestOptions] = None | |
| ) -> MediaGenerationCreateResponse: | |
| """ | |
| Start a video generation with the selected model. | |
| Parameters | |
| ---------- | |
| request : VideoGenerationRequest | |
| request_options : typing.Optional[RequestOptions] | |
| Request-specific configuration. | |
| Returns | |
| ------- | |
| MediaGenerationCreateResponse | |
| Successful Response | |
| Examples | |
| -------- | |
| from elevenlabs import ElevenLabs, VideoGenerationRequest_BytedanceSeedanceV2 | |
| client = ElevenLabs( | |
| api_key="YOUR_API_KEY", | |
| ) | |
| client.flows.video.create( | |
| request=VideoGenerationRequest_BytedanceSeedanceV2( | |
| prompt="A corgi rides a tiny surfboard across a sunlit wave at golden hour, cinematic", | |
| ), | |
| ) | |
| """ | |
| _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 a video 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.video.get( | |
| generation_id="generation_id", | |
| ) | |
| """ | |
| _response = self._raw_client.get(generation_id, request_options=request_options) | |
| return _response.data | |
| class AsyncVideoClient: | |
| def __init__(self, *, client_wrapper: AsyncClientWrapper): | |
| self._raw_client = AsyncRawVideoClient(client_wrapper=client_wrapper) | |
| def with_raw_response(self) -> AsyncRawVideoClient: | |
| """ | |
| Retrieves a raw implementation of this client that returns raw responses. | |
| Returns | |
| ------- | |
| AsyncRawVideoClient | |
| """ | |
| return self._raw_client | |
| async def list( | |
| self, | |
| *, | |
| cursor: typing.Optional[str] = None, | |
| page_size: typing.Optional[int] = None, | |
| status: typing.Optional[VideoListRequestStatus] = None, | |
| model_id: typing.Optional[str] = None, | |
| request_options: typing.Optional[RequestOptions] = None, | |
| ) -> MediaGenerationListResponse: | |
| """ | |
| List the video 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[VideoListRequestStatus] | |
| 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.video.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: VideoGenerationRequest, request_options: typing.Optional[RequestOptions] = None | |
| ) -> MediaGenerationCreateResponse: | |
| """ | |
| Start a video generation with the selected model. | |
| Parameters | |
| ---------- | |
| request : VideoGenerationRequest | |
| request_options : typing.Optional[RequestOptions] | |
| Request-specific configuration. | |
| Returns | |
| ------- | |
| MediaGenerationCreateResponse | |
| Successful Response | |
| Examples | |
| -------- | |
| import asyncio | |
| from elevenlabs import ( | |
| AsyncElevenLabs, | |
| VideoGenerationRequest_BytedanceSeedanceV2, | |
| ) | |
| client = AsyncElevenLabs( | |
| api_key="YOUR_API_KEY", | |
| ) | |
| async def main() -> None: | |
| await client.flows.video.create( | |
| request=VideoGenerationRequest_BytedanceSeedanceV2( | |
| prompt="A corgi rides a tiny surfboard across a sunlit wave at golden hour, cinematic", | |
| ), | |
| ) | |
| 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 a video 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.video.get( | |
| generation_id="generation_id", | |
| ) | |
| asyncio.run(main()) | |
| """ | |
| _response = await self._raw_client.get(generation_id, request_options=request_options) | |
| return _response.data | |