|
| 1 | +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +from typing import Iterable |
| 6 | +from typing_extensions import Literal |
| 7 | + |
| 8 | +import httpx |
| 9 | + |
| 10 | +from ..types import video_to_video_create_params |
| 11 | +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven |
| 12 | +from .._utils import maybe_transform, async_maybe_transform |
| 13 | +from .._compat import cached_property |
| 14 | +from .._resource import SyncAPIResource, AsyncAPIResource |
| 15 | +from .._response import ( |
| 16 | + to_raw_response_wrapper, |
| 17 | + to_streamed_response_wrapper, |
| 18 | + async_to_raw_response_wrapper, |
| 19 | + async_to_streamed_response_wrapper, |
| 20 | +) |
| 21 | +from ..lib.polling import ( |
| 22 | + NewTaskCreatedResponse, |
| 23 | + AsyncNewTaskCreatedResponse, |
| 24 | + create_waitable_resource, |
| 25 | + create_async_waitable_resource, |
| 26 | +) |
| 27 | +from .._base_client import make_request_options |
| 28 | +from ..types.video_to_video_create_response import VideoToVideoCreateResponse |
| 29 | + |
| 30 | +__all__ = ["VideoToVideoResource", "AsyncVideoToVideoResource"] |
| 31 | + |
| 32 | + |
| 33 | +class VideoToVideoResource(SyncAPIResource): |
| 34 | + @cached_property |
| 35 | + def with_raw_response(self) -> VideoToVideoResourceWithRawResponse: |
| 36 | + """ |
| 37 | + This property can be used as a prefix for any HTTP method call to return |
| 38 | + the raw response object instead of the parsed content. |
| 39 | +
|
| 40 | + For more information, see https://www.github.com/runwayml/sdk-python#accessing-raw-response-data-eg-headers |
| 41 | + """ |
| 42 | + return VideoToVideoResourceWithRawResponse(self) |
| 43 | + |
| 44 | + @cached_property |
| 45 | + def with_streaming_response(self) -> VideoToVideoResourceWithStreamingResponse: |
| 46 | + """ |
| 47 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 48 | +
|
| 49 | + For more information, see https://www.github.com/runwayml/sdk-python#with_streaming_response |
| 50 | + """ |
| 51 | + return VideoToVideoResourceWithStreamingResponse(self) |
| 52 | + |
| 53 | + def create( |
| 54 | + self, |
| 55 | + *, |
| 56 | + model: Literal["gen4_aleph"], |
| 57 | + prompt_text: str, |
| 58 | + ratio: Literal["1280:720", "720:1280", "1104:832", "960:960", "832:1104", "1584:672", "848:480", "640:480"], |
| 59 | + video_uri: str, |
| 60 | + content_moderation: video_to_video_create_params.ContentModeration | NotGiven = NOT_GIVEN, |
| 61 | + references: Iterable[video_to_video_create_params.Reference] | NotGiven = NOT_GIVEN, |
| 62 | + seed: int | NotGiven = NOT_GIVEN, |
| 63 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 64 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 65 | + extra_headers: Headers | None = None, |
| 66 | + extra_query: Query | None = None, |
| 67 | + extra_body: Body | None = None, |
| 68 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 69 | + ) -> NewTaskCreatedResponse: |
| 70 | + """ |
| 71 | + This endpoint will start a new task to generate a video from a video. |
| 72 | +
|
| 73 | + Args: |
| 74 | + model: The model variant to use. |
| 75 | +
|
| 76 | + prompt_text: A non-empty string up to 1000 characters (measured in UTF-16 code units). This |
| 77 | + should describe in detail what should appear in the output. |
| 78 | +
|
| 79 | + ratio: The resolution of the output video. |
| 80 | +
|
| 81 | + video_uri: A HTTPS URL pointing to a video or a data URI containing a video. See |
| 82 | + [our docs](/assets/inputs#videos) on video inputs for more information. |
| 83 | +
|
| 84 | + content_moderation: Settings that affect the behavior of the content moderation system. |
| 85 | +
|
| 86 | + references: An array of references. Currently up to one reference is supported. See |
| 87 | + [our docs](/assets/inputs#images) on image inputs for more information. |
| 88 | +
|
| 89 | + seed: If unspecified, a random number is chosen. Varying the seed integer is a way to |
| 90 | + get different results for the same other request parameters. Using the same seed |
| 91 | + integer for an identical request will produce similar results. |
| 92 | +
|
| 93 | + extra_headers: Send extra headers |
| 94 | +
|
| 95 | + extra_query: Add additional query parameters to the request |
| 96 | +
|
| 97 | + extra_body: Add additional JSON properties to the request |
| 98 | +
|
| 99 | + timeout: Override the client-level default timeout for this request, in seconds |
| 100 | + """ |
| 101 | + return self._post( |
| 102 | + "/v1/video_to_video", |
| 103 | + body=maybe_transform( |
| 104 | + { |
| 105 | + "model": model, |
| 106 | + "prompt_text": prompt_text, |
| 107 | + "ratio": ratio, |
| 108 | + "video_uri": video_uri, |
| 109 | + "content_moderation": content_moderation, |
| 110 | + "references": references, |
| 111 | + "seed": seed, |
| 112 | + }, |
| 113 | + video_to_video_create_params.VideoToVideoCreateParams, |
| 114 | + ), |
| 115 | + options=make_request_options( |
| 116 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 117 | + ), |
| 118 | + cast_to=create_waitable_resource(VideoToVideoCreateResponse, self._client), |
| 119 | + ) |
| 120 | + |
| 121 | + |
| 122 | +class AsyncVideoToVideoResource(AsyncAPIResource): |
| 123 | + @cached_property |
| 124 | + def with_raw_response(self) -> AsyncVideoToVideoResourceWithRawResponse: |
| 125 | + """ |
| 126 | + This property can be used as a prefix for any HTTP method call to return |
| 127 | + the raw response object instead of the parsed content. |
| 128 | +
|
| 129 | + For more information, see https://www.github.com/runwayml/sdk-python#accessing-raw-response-data-eg-headers |
| 130 | + """ |
| 131 | + return AsyncVideoToVideoResourceWithRawResponse(self) |
| 132 | + |
| 133 | + @cached_property |
| 134 | + def with_streaming_response(self) -> AsyncVideoToVideoResourceWithStreamingResponse: |
| 135 | + """ |
| 136 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 137 | +
|
| 138 | + For more information, see https://www.github.com/runwayml/sdk-python#with_streaming_response |
| 139 | + """ |
| 140 | + return AsyncVideoToVideoResourceWithStreamingResponse(self) |
| 141 | + |
| 142 | + async def create( |
| 143 | + self, |
| 144 | + *, |
| 145 | + model: Literal["gen4_aleph"], |
| 146 | + prompt_text: str, |
| 147 | + ratio: Literal["1280:720", "720:1280", "1104:832", "960:960", "832:1104", "1584:672", "848:480", "640:480"], |
| 148 | + video_uri: str, |
| 149 | + content_moderation: video_to_video_create_params.ContentModeration | NotGiven = NOT_GIVEN, |
| 150 | + references: Iterable[video_to_video_create_params.Reference] | NotGiven = NOT_GIVEN, |
| 151 | + seed: int | NotGiven = NOT_GIVEN, |
| 152 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 153 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 154 | + extra_headers: Headers | None = None, |
| 155 | + extra_query: Query | None = None, |
| 156 | + extra_body: Body | None = None, |
| 157 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 158 | + ) -> AsyncNewTaskCreatedResponse: |
| 159 | + """ |
| 160 | + This endpoint will start a new task to generate a video from a video. |
| 161 | +
|
| 162 | + Args: |
| 163 | + model: The model variant to use. |
| 164 | +
|
| 165 | + prompt_text: A non-empty string up to 1000 characters (measured in UTF-16 code units). This |
| 166 | + should describe in detail what should appear in the output. |
| 167 | +
|
| 168 | + ratio: The resolution of the output video. |
| 169 | +
|
| 170 | + video_uri: A HTTPS URL pointing to a video or a data URI containing a video. See |
| 171 | + [our docs](/assets/inputs#videos) on video inputs for more information. |
| 172 | +
|
| 173 | + content_moderation: Settings that affect the behavior of the content moderation system. |
| 174 | +
|
| 175 | + references: An array of references. Currently up to one reference is supported. See |
| 176 | + [our docs](/assets/inputs#images) on image inputs for more information. |
| 177 | +
|
| 178 | + seed: If unspecified, a random number is chosen. Varying the seed integer is a way to |
| 179 | + get different results for the same other request parameters. Using the same seed |
| 180 | + integer for an identical request will produce similar results. |
| 181 | +
|
| 182 | + extra_headers: Send extra headers |
| 183 | +
|
| 184 | + extra_query: Add additional query parameters to the request |
| 185 | +
|
| 186 | + extra_body: Add additional JSON properties to the request |
| 187 | +
|
| 188 | + timeout: Override the client-level default timeout for this request, in seconds |
| 189 | + """ |
| 190 | + return await self._post( |
| 191 | + "/v1/video_to_video", |
| 192 | + body=await async_maybe_transform( |
| 193 | + { |
| 194 | + "model": model, |
| 195 | + "prompt_text": prompt_text, |
| 196 | + "ratio": ratio, |
| 197 | + "video_uri": video_uri, |
| 198 | + "content_moderation": content_moderation, |
| 199 | + "references": references, |
| 200 | + "seed": seed, |
| 201 | + }, |
| 202 | + video_to_video_create_params.VideoToVideoCreateParams, |
| 203 | + ), |
| 204 | + options=make_request_options( |
| 205 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 206 | + ), |
| 207 | + cast_to=create_async_waitable_resource(VideoToVideoCreateResponse, self._client), |
| 208 | + ) |
| 209 | + |
| 210 | + |
| 211 | +class VideoToVideoResourceWithRawResponse: |
| 212 | + def __init__(self, video_to_video: VideoToVideoResource) -> None: |
| 213 | + self._video_to_video = video_to_video |
| 214 | + |
| 215 | + self.create = to_raw_response_wrapper( |
| 216 | + video_to_video.create, |
| 217 | + ) |
| 218 | + |
| 219 | + |
| 220 | +class AsyncVideoToVideoResourceWithRawResponse: |
| 221 | + def __init__(self, video_to_video: AsyncVideoToVideoResource) -> None: |
| 222 | + self._video_to_video = video_to_video |
| 223 | + |
| 224 | + self.create = async_to_raw_response_wrapper( |
| 225 | + video_to_video.create, |
| 226 | + ) |
| 227 | + |
| 228 | + |
| 229 | +class VideoToVideoResourceWithStreamingResponse: |
| 230 | + def __init__(self, video_to_video: VideoToVideoResource) -> None: |
| 231 | + self._video_to_video = video_to_video |
| 232 | + |
| 233 | + self.create = to_streamed_response_wrapper( |
| 234 | + video_to_video.create, |
| 235 | + ) |
| 236 | + |
| 237 | + |
| 238 | +class AsyncVideoToVideoResourceWithStreamingResponse: |
| 239 | + def __init__(self, video_to_video: AsyncVideoToVideoResource) -> None: |
| 240 | + self._video_to_video = video_to_video |
| 241 | + |
| 242 | + self.create = async_to_streamed_response_wrapper( |
| 243 | + video_to_video.create, |
| 244 | + ) |
0 commit comments