runwayml 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- runwayml/__init__.py +93 -0
- runwayml/_base_client.py +2019 -0
- runwayml/_client.py +432 -0
- runwayml/_compat.py +217 -0
- runwayml/_constants.py +14 -0
- runwayml/_exceptions.py +108 -0
- runwayml/_files.py +123 -0
- runwayml/_models.py +785 -0
- runwayml/_qs.py +150 -0
- runwayml/_resource.py +43 -0
- runwayml/_response.py +821 -0
- runwayml/_streaming.py +333 -0
- runwayml/_types.py +217 -0
- runwayml/_utils/__init__.py +55 -0
- runwayml/_utils/_logs.py +25 -0
- runwayml/_utils/_proxy.py +62 -0
- runwayml/_utils/_reflection.py +42 -0
- runwayml/_utils/_streams.py +12 -0
- runwayml/_utils/_sync.py +81 -0
- runwayml/_utils/_transform.py +382 -0
- runwayml/_utils/_typing.py +120 -0
- runwayml/_utils/_utils.py +397 -0
- runwayml/_version.py +4 -0
- runwayml/lib/.keep +4 -0
- runwayml/py.typed +0 -0
- runwayml/resources/__init__.py +33 -0
- runwayml/resources/image_to_video.py +222 -0
- runwayml/resources/tasks.py +257 -0
- runwayml/types/__init__.py +7 -0
- runwayml/types/image_to_video_create_params.py +37 -0
- runwayml/types/image_to_video_create_response.py +12 -0
- runwayml/types/task_retrieve_response.py +58 -0
- runwayml-1.0.0.dist-info/METADATA +379 -0
- runwayml-1.0.0.dist-info/RECORD +36 -0
- runwayml-1.0.0.dist-info/WHEEL +4 -0
- runwayml-1.0.0.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,397 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
import os
|
4
|
+
import re
|
5
|
+
import inspect
|
6
|
+
import functools
|
7
|
+
from typing import (
|
8
|
+
Any,
|
9
|
+
Tuple,
|
10
|
+
Mapping,
|
11
|
+
TypeVar,
|
12
|
+
Callable,
|
13
|
+
Iterable,
|
14
|
+
Sequence,
|
15
|
+
cast,
|
16
|
+
overload,
|
17
|
+
)
|
18
|
+
from pathlib import Path
|
19
|
+
from typing_extensions import TypeGuard
|
20
|
+
|
21
|
+
import sniffio
|
22
|
+
|
23
|
+
from .._types import NotGiven, FileTypes, NotGivenOr, HeadersLike
|
24
|
+
from .._compat import parse_date as parse_date, parse_datetime as parse_datetime
|
25
|
+
|
26
|
+
_T = TypeVar("_T")
|
27
|
+
_TupleT = TypeVar("_TupleT", bound=Tuple[object, ...])
|
28
|
+
_MappingT = TypeVar("_MappingT", bound=Mapping[str, object])
|
29
|
+
_SequenceT = TypeVar("_SequenceT", bound=Sequence[object])
|
30
|
+
CallableT = TypeVar("CallableT", bound=Callable[..., Any])
|
31
|
+
|
32
|
+
|
33
|
+
def flatten(t: Iterable[Iterable[_T]]) -> list[_T]:
|
34
|
+
return [item for sublist in t for item in sublist]
|
35
|
+
|
36
|
+
|
37
|
+
def extract_files(
|
38
|
+
# TODO: this needs to take Dict but variance issues.....
|
39
|
+
# create protocol type ?
|
40
|
+
query: Mapping[str, object],
|
41
|
+
*,
|
42
|
+
paths: Sequence[Sequence[str]],
|
43
|
+
) -> list[tuple[str, FileTypes]]:
|
44
|
+
"""Recursively extract files from the given dictionary based on specified paths.
|
45
|
+
|
46
|
+
A path may look like this ['foo', 'files', '<array>', 'data'].
|
47
|
+
|
48
|
+
Note: this mutates the given dictionary.
|
49
|
+
"""
|
50
|
+
files: list[tuple[str, FileTypes]] = []
|
51
|
+
for path in paths:
|
52
|
+
files.extend(_extract_items(query, path, index=0, flattened_key=None))
|
53
|
+
return files
|
54
|
+
|
55
|
+
|
56
|
+
def _extract_items(
|
57
|
+
obj: object,
|
58
|
+
path: Sequence[str],
|
59
|
+
*,
|
60
|
+
index: int,
|
61
|
+
flattened_key: str | None,
|
62
|
+
) -> list[tuple[str, FileTypes]]:
|
63
|
+
try:
|
64
|
+
key = path[index]
|
65
|
+
except IndexError:
|
66
|
+
if isinstance(obj, NotGiven):
|
67
|
+
# no value was provided - we can safely ignore
|
68
|
+
return []
|
69
|
+
|
70
|
+
# cyclical import
|
71
|
+
from .._files import assert_is_file_content
|
72
|
+
|
73
|
+
# We have exhausted the path, return the entry we found.
|
74
|
+
assert_is_file_content(obj, key=flattened_key)
|
75
|
+
assert flattened_key is not None
|
76
|
+
return [(flattened_key, cast(FileTypes, obj))]
|
77
|
+
|
78
|
+
index += 1
|
79
|
+
if is_dict(obj):
|
80
|
+
try:
|
81
|
+
# We are at the last entry in the path so we must remove the field
|
82
|
+
if (len(path)) == index:
|
83
|
+
item = obj.pop(key)
|
84
|
+
else:
|
85
|
+
item = obj[key]
|
86
|
+
except KeyError:
|
87
|
+
# Key was not present in the dictionary, this is not indicative of an error
|
88
|
+
# as the given path may not point to a required field. We also do not want
|
89
|
+
# to enforce required fields as the API may differ from the spec in some cases.
|
90
|
+
return []
|
91
|
+
if flattened_key is None:
|
92
|
+
flattened_key = key
|
93
|
+
else:
|
94
|
+
flattened_key += f"[{key}]"
|
95
|
+
return _extract_items(
|
96
|
+
item,
|
97
|
+
path,
|
98
|
+
index=index,
|
99
|
+
flattened_key=flattened_key,
|
100
|
+
)
|
101
|
+
elif is_list(obj):
|
102
|
+
if key != "<array>":
|
103
|
+
return []
|
104
|
+
|
105
|
+
return flatten(
|
106
|
+
[
|
107
|
+
_extract_items(
|
108
|
+
item,
|
109
|
+
path,
|
110
|
+
index=index,
|
111
|
+
flattened_key=flattened_key + "[]" if flattened_key is not None else "[]",
|
112
|
+
)
|
113
|
+
for item in obj
|
114
|
+
]
|
115
|
+
)
|
116
|
+
|
117
|
+
# Something unexpected was passed, just ignore it.
|
118
|
+
return []
|
119
|
+
|
120
|
+
|
121
|
+
def is_given(obj: NotGivenOr[_T]) -> TypeGuard[_T]:
|
122
|
+
return not isinstance(obj, NotGiven)
|
123
|
+
|
124
|
+
|
125
|
+
# Type safe methods for narrowing types with TypeVars.
|
126
|
+
# The default narrowing for isinstance(obj, dict) is dict[unknown, unknown],
|
127
|
+
# however this cause Pyright to rightfully report errors. As we know we don't
|
128
|
+
# care about the contained types we can safely use `object` in it's place.
|
129
|
+
#
|
130
|
+
# There are two separate functions defined, `is_*` and `is_*_t` for different use cases.
|
131
|
+
# `is_*` is for when you're dealing with an unknown input
|
132
|
+
# `is_*_t` is for when you're narrowing a known union type to a specific subset
|
133
|
+
|
134
|
+
|
135
|
+
def is_tuple(obj: object) -> TypeGuard[tuple[object, ...]]:
|
136
|
+
return isinstance(obj, tuple)
|
137
|
+
|
138
|
+
|
139
|
+
def is_tuple_t(obj: _TupleT | object) -> TypeGuard[_TupleT]:
|
140
|
+
return isinstance(obj, tuple)
|
141
|
+
|
142
|
+
|
143
|
+
def is_sequence(obj: object) -> TypeGuard[Sequence[object]]:
|
144
|
+
return isinstance(obj, Sequence)
|
145
|
+
|
146
|
+
|
147
|
+
def is_sequence_t(obj: _SequenceT | object) -> TypeGuard[_SequenceT]:
|
148
|
+
return isinstance(obj, Sequence)
|
149
|
+
|
150
|
+
|
151
|
+
def is_mapping(obj: object) -> TypeGuard[Mapping[str, object]]:
|
152
|
+
return isinstance(obj, Mapping)
|
153
|
+
|
154
|
+
|
155
|
+
def is_mapping_t(obj: _MappingT | object) -> TypeGuard[_MappingT]:
|
156
|
+
return isinstance(obj, Mapping)
|
157
|
+
|
158
|
+
|
159
|
+
def is_dict(obj: object) -> TypeGuard[dict[object, object]]:
|
160
|
+
return isinstance(obj, dict)
|
161
|
+
|
162
|
+
|
163
|
+
def is_list(obj: object) -> TypeGuard[list[object]]:
|
164
|
+
return isinstance(obj, list)
|
165
|
+
|
166
|
+
|
167
|
+
def is_iterable(obj: object) -> TypeGuard[Iterable[object]]:
|
168
|
+
return isinstance(obj, Iterable)
|
169
|
+
|
170
|
+
|
171
|
+
def deepcopy_minimal(item: _T) -> _T:
|
172
|
+
"""Minimal reimplementation of copy.deepcopy() that will only copy certain object types:
|
173
|
+
|
174
|
+
- mappings, e.g. `dict`
|
175
|
+
- list
|
176
|
+
|
177
|
+
This is done for performance reasons.
|
178
|
+
"""
|
179
|
+
if is_mapping(item):
|
180
|
+
return cast(_T, {k: deepcopy_minimal(v) for k, v in item.items()})
|
181
|
+
if is_list(item):
|
182
|
+
return cast(_T, [deepcopy_minimal(entry) for entry in item])
|
183
|
+
return item
|
184
|
+
|
185
|
+
|
186
|
+
# copied from https://github.com/Rapptz/RoboDanny
|
187
|
+
def human_join(seq: Sequence[str], *, delim: str = ", ", final: str = "or") -> str:
|
188
|
+
size = len(seq)
|
189
|
+
if size == 0:
|
190
|
+
return ""
|
191
|
+
|
192
|
+
if size == 1:
|
193
|
+
return seq[0]
|
194
|
+
|
195
|
+
if size == 2:
|
196
|
+
return f"{seq[0]} {final} {seq[1]}"
|
197
|
+
|
198
|
+
return delim.join(seq[:-1]) + f" {final} {seq[-1]}"
|
199
|
+
|
200
|
+
|
201
|
+
def quote(string: str) -> str:
|
202
|
+
"""Add single quotation marks around the given string. Does *not* do any escaping."""
|
203
|
+
return f"'{string}'"
|
204
|
+
|
205
|
+
|
206
|
+
def required_args(*variants: Sequence[str]) -> Callable[[CallableT], CallableT]:
|
207
|
+
"""Decorator to enforce a given set of arguments or variants of arguments are passed to the decorated function.
|
208
|
+
|
209
|
+
Useful for enforcing runtime validation of overloaded functions.
|
210
|
+
|
211
|
+
Example usage:
|
212
|
+
```py
|
213
|
+
@overload
|
214
|
+
def foo(*, a: str) -> str: ...
|
215
|
+
|
216
|
+
|
217
|
+
@overload
|
218
|
+
def foo(*, b: bool) -> str: ...
|
219
|
+
|
220
|
+
|
221
|
+
# This enforces the same constraints that a static type checker would
|
222
|
+
# i.e. that either a or b must be passed to the function
|
223
|
+
@required_args(["a"], ["b"])
|
224
|
+
def foo(*, a: str | None = None, b: bool | None = None) -> str: ...
|
225
|
+
```
|
226
|
+
"""
|
227
|
+
|
228
|
+
def inner(func: CallableT) -> CallableT:
|
229
|
+
params = inspect.signature(func).parameters
|
230
|
+
positional = [
|
231
|
+
name
|
232
|
+
for name, param in params.items()
|
233
|
+
if param.kind
|
234
|
+
in {
|
235
|
+
param.POSITIONAL_ONLY,
|
236
|
+
param.POSITIONAL_OR_KEYWORD,
|
237
|
+
}
|
238
|
+
]
|
239
|
+
|
240
|
+
@functools.wraps(func)
|
241
|
+
def wrapper(*args: object, **kwargs: object) -> object:
|
242
|
+
given_params: set[str] = set()
|
243
|
+
for i, _ in enumerate(args):
|
244
|
+
try:
|
245
|
+
given_params.add(positional[i])
|
246
|
+
except IndexError:
|
247
|
+
raise TypeError(
|
248
|
+
f"{func.__name__}() takes {len(positional)} argument(s) but {len(args)} were given"
|
249
|
+
) from None
|
250
|
+
|
251
|
+
for key in kwargs.keys():
|
252
|
+
given_params.add(key)
|
253
|
+
|
254
|
+
for variant in variants:
|
255
|
+
matches = all((param in given_params for param in variant))
|
256
|
+
if matches:
|
257
|
+
break
|
258
|
+
else: # no break
|
259
|
+
if len(variants) > 1:
|
260
|
+
variations = human_join(
|
261
|
+
["(" + human_join([quote(arg) for arg in variant], final="and") + ")" for variant in variants]
|
262
|
+
)
|
263
|
+
msg = f"Missing required arguments; Expected either {variations} arguments to be given"
|
264
|
+
else:
|
265
|
+
assert len(variants) > 0
|
266
|
+
|
267
|
+
# TODO: this error message is not deterministic
|
268
|
+
missing = list(set(variants[0]) - given_params)
|
269
|
+
if len(missing) > 1:
|
270
|
+
msg = f"Missing required arguments: {human_join([quote(arg) for arg in missing])}"
|
271
|
+
else:
|
272
|
+
msg = f"Missing required argument: {quote(missing[0])}"
|
273
|
+
raise TypeError(msg)
|
274
|
+
return func(*args, **kwargs)
|
275
|
+
|
276
|
+
return wrapper # type: ignore
|
277
|
+
|
278
|
+
return inner
|
279
|
+
|
280
|
+
|
281
|
+
_K = TypeVar("_K")
|
282
|
+
_V = TypeVar("_V")
|
283
|
+
|
284
|
+
|
285
|
+
@overload
|
286
|
+
def strip_not_given(obj: None) -> None: ...
|
287
|
+
|
288
|
+
|
289
|
+
@overload
|
290
|
+
def strip_not_given(obj: Mapping[_K, _V | NotGiven]) -> dict[_K, _V]: ...
|
291
|
+
|
292
|
+
|
293
|
+
@overload
|
294
|
+
def strip_not_given(obj: object) -> object: ...
|
295
|
+
|
296
|
+
|
297
|
+
def strip_not_given(obj: object | None) -> object:
|
298
|
+
"""Remove all top-level keys where their values are instances of `NotGiven`"""
|
299
|
+
if obj is None:
|
300
|
+
return None
|
301
|
+
|
302
|
+
if not is_mapping(obj):
|
303
|
+
return obj
|
304
|
+
|
305
|
+
return {key: value for key, value in obj.items() if not isinstance(value, NotGiven)}
|
306
|
+
|
307
|
+
|
308
|
+
def coerce_integer(val: str) -> int:
|
309
|
+
return int(val, base=10)
|
310
|
+
|
311
|
+
|
312
|
+
def coerce_float(val: str) -> float:
|
313
|
+
return float(val)
|
314
|
+
|
315
|
+
|
316
|
+
def coerce_boolean(val: str) -> bool:
|
317
|
+
return val == "true" or val == "1" or val == "on"
|
318
|
+
|
319
|
+
|
320
|
+
def maybe_coerce_integer(val: str | None) -> int | None:
|
321
|
+
if val is None:
|
322
|
+
return None
|
323
|
+
return coerce_integer(val)
|
324
|
+
|
325
|
+
|
326
|
+
def maybe_coerce_float(val: str | None) -> float | None:
|
327
|
+
if val is None:
|
328
|
+
return None
|
329
|
+
return coerce_float(val)
|
330
|
+
|
331
|
+
|
332
|
+
def maybe_coerce_boolean(val: str | None) -> bool | None:
|
333
|
+
if val is None:
|
334
|
+
return None
|
335
|
+
return coerce_boolean(val)
|
336
|
+
|
337
|
+
|
338
|
+
def removeprefix(string: str, prefix: str) -> str:
|
339
|
+
"""Remove a prefix from a string.
|
340
|
+
|
341
|
+
Backport of `str.removeprefix` for Python < 3.9
|
342
|
+
"""
|
343
|
+
if string.startswith(prefix):
|
344
|
+
return string[len(prefix) :]
|
345
|
+
return string
|
346
|
+
|
347
|
+
|
348
|
+
def removesuffix(string: str, suffix: str) -> str:
|
349
|
+
"""Remove a suffix from a string.
|
350
|
+
|
351
|
+
Backport of `str.removesuffix` for Python < 3.9
|
352
|
+
"""
|
353
|
+
if string.endswith(suffix):
|
354
|
+
return string[: -len(suffix)]
|
355
|
+
return string
|
356
|
+
|
357
|
+
|
358
|
+
def file_from_path(path: str) -> FileTypes:
|
359
|
+
contents = Path(path).read_bytes()
|
360
|
+
file_name = os.path.basename(path)
|
361
|
+
return (file_name, contents)
|
362
|
+
|
363
|
+
|
364
|
+
def get_required_header(headers: HeadersLike, header: str) -> str:
|
365
|
+
lower_header = header.lower()
|
366
|
+
if is_mapping_t(headers):
|
367
|
+
# mypy doesn't understand the type narrowing here
|
368
|
+
for k, v in headers.items(): # type: ignore
|
369
|
+
if k.lower() == lower_header and isinstance(v, str):
|
370
|
+
return v
|
371
|
+
|
372
|
+
# to deal with the case where the header looks like Stainless-Event-Id
|
373
|
+
intercaps_header = re.sub(r"([^\w])(\w)", lambda pat: pat.group(1) + pat.group(2).upper(), header.capitalize())
|
374
|
+
|
375
|
+
for normalized_header in [header, lower_header, header.upper(), intercaps_header]:
|
376
|
+
value = headers.get(normalized_header)
|
377
|
+
if value:
|
378
|
+
return value
|
379
|
+
|
380
|
+
raise ValueError(f"Could not find {header} header")
|
381
|
+
|
382
|
+
|
383
|
+
def get_async_library() -> str:
|
384
|
+
try:
|
385
|
+
return sniffio.current_async_library()
|
386
|
+
except Exception:
|
387
|
+
return "false"
|
388
|
+
|
389
|
+
|
390
|
+
def lru_cache(*, maxsize: int | None = 128) -> Callable[[CallableT], CallableT]:
|
391
|
+
"""A version of functools.lru_cache that retains the type signature
|
392
|
+
for the wrapped function arguments.
|
393
|
+
"""
|
394
|
+
wrapper = functools.lru_cache( # noqa: TID251
|
395
|
+
maxsize=maxsize,
|
396
|
+
)
|
397
|
+
return cast(Any, wrapper) # type: ignore[no-any-return]
|
runwayml/_version.py
ADDED
runwayml/lib/.keep
ADDED
runwayml/py.typed
ADDED
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2
|
+
|
3
|
+
from .tasks import (
|
4
|
+
TasksResource,
|
5
|
+
AsyncTasksResource,
|
6
|
+
TasksResourceWithRawResponse,
|
7
|
+
AsyncTasksResourceWithRawResponse,
|
8
|
+
TasksResourceWithStreamingResponse,
|
9
|
+
AsyncTasksResourceWithStreamingResponse,
|
10
|
+
)
|
11
|
+
from .image_to_video import (
|
12
|
+
ImageToVideoResource,
|
13
|
+
AsyncImageToVideoResource,
|
14
|
+
ImageToVideoResourceWithRawResponse,
|
15
|
+
AsyncImageToVideoResourceWithRawResponse,
|
16
|
+
ImageToVideoResourceWithStreamingResponse,
|
17
|
+
AsyncImageToVideoResourceWithStreamingResponse,
|
18
|
+
)
|
19
|
+
|
20
|
+
__all__ = [
|
21
|
+
"TasksResource",
|
22
|
+
"AsyncTasksResource",
|
23
|
+
"TasksResourceWithRawResponse",
|
24
|
+
"AsyncTasksResourceWithRawResponse",
|
25
|
+
"TasksResourceWithStreamingResponse",
|
26
|
+
"AsyncTasksResourceWithStreamingResponse",
|
27
|
+
"ImageToVideoResource",
|
28
|
+
"AsyncImageToVideoResource",
|
29
|
+
"ImageToVideoResourceWithRawResponse",
|
30
|
+
"AsyncImageToVideoResourceWithRawResponse",
|
31
|
+
"ImageToVideoResourceWithStreamingResponse",
|
32
|
+
"AsyncImageToVideoResourceWithStreamingResponse",
|
33
|
+
]
|
@@ -0,0 +1,222 @@
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2
|
+
|
3
|
+
from __future__ import annotations
|
4
|
+
|
5
|
+
from typing_extensions import Literal
|
6
|
+
|
7
|
+
import httpx
|
8
|
+
|
9
|
+
from ..types import image_to_video_create_params
|
10
|
+
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
11
|
+
from .._utils import (
|
12
|
+
maybe_transform,
|
13
|
+
async_maybe_transform,
|
14
|
+
)
|
15
|
+
from .._compat import cached_property
|
16
|
+
from .._resource import SyncAPIResource, AsyncAPIResource
|
17
|
+
from .._response import (
|
18
|
+
to_raw_response_wrapper,
|
19
|
+
to_streamed_response_wrapper,
|
20
|
+
async_to_raw_response_wrapper,
|
21
|
+
async_to_streamed_response_wrapper,
|
22
|
+
)
|
23
|
+
from .._base_client import make_request_options
|
24
|
+
from ..types.image_to_video_create_response import ImageToVideoCreateResponse
|
25
|
+
|
26
|
+
__all__ = ["ImageToVideoResource", "AsyncImageToVideoResource"]
|
27
|
+
|
28
|
+
|
29
|
+
class ImageToVideoResource(SyncAPIResource):
|
30
|
+
@cached_property
|
31
|
+
def with_raw_response(self) -> ImageToVideoResourceWithRawResponse:
|
32
|
+
"""
|
33
|
+
This property can be used as a prefix for any HTTP method call to return the
|
34
|
+
the raw response object instead of the parsed content.
|
35
|
+
|
36
|
+
For more information, see https://www.github.com/runwayml/sdk-python#accessing-raw-response-data-eg-headers
|
37
|
+
"""
|
38
|
+
return ImageToVideoResourceWithRawResponse(self)
|
39
|
+
|
40
|
+
@cached_property
|
41
|
+
def with_streaming_response(self) -> ImageToVideoResourceWithStreamingResponse:
|
42
|
+
"""
|
43
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
44
|
+
|
45
|
+
For more information, see https://www.github.com/runwayml/sdk-python#with_streaming_response
|
46
|
+
"""
|
47
|
+
return ImageToVideoResourceWithStreamingResponse(self)
|
48
|
+
|
49
|
+
def create(
|
50
|
+
self,
|
51
|
+
*,
|
52
|
+
model: Literal["gen3a_turbo"],
|
53
|
+
prompt_image: str,
|
54
|
+
prompt_text: str | NotGiven = NOT_GIVEN,
|
55
|
+
seed: int | NotGiven = NOT_GIVEN,
|
56
|
+
watermark: bool | NotGiven = NOT_GIVEN,
|
57
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
58
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
59
|
+
extra_headers: Headers | None = None,
|
60
|
+
extra_query: Query | None = None,
|
61
|
+
extra_body: Body | None = None,
|
62
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
63
|
+
) -> ImageToVideoCreateResponse:
|
64
|
+
"""
|
65
|
+
This endpoint will start a new task to generate a video from an image prompt.
|
66
|
+
|
67
|
+
Args:
|
68
|
+
model: The model variant to use.
|
69
|
+
|
70
|
+
prompt_image: A HTTPS URL pointing to an image. Images must be JPEG, PNG, or WebP and are
|
71
|
+
limited to 16MB. Responses must include a valid `Content-Length` header.
|
72
|
+
|
73
|
+
prompt_text
|
74
|
+
|
75
|
+
seed: If unspecified, a random number is chosen. Varying the seed integer is a way to
|
76
|
+
get different results for the same other request parameters. Using the same seed
|
77
|
+
integer for an identical request will produce similar results.
|
78
|
+
|
79
|
+
watermark: A boolean indicating whether or not the output video will contain a Runway
|
80
|
+
watermark.
|
81
|
+
|
82
|
+
extra_headers: Send extra headers
|
83
|
+
|
84
|
+
extra_query: Add additional query parameters to the request
|
85
|
+
|
86
|
+
extra_body: Add additional JSON properties to the request
|
87
|
+
|
88
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
89
|
+
"""
|
90
|
+
return self._post(
|
91
|
+
"/v1/image_to_video",
|
92
|
+
body=maybe_transform(
|
93
|
+
{
|
94
|
+
"model": model,
|
95
|
+
"prompt_image": prompt_image,
|
96
|
+
"prompt_text": prompt_text,
|
97
|
+
"seed": seed,
|
98
|
+
"watermark": watermark,
|
99
|
+
},
|
100
|
+
image_to_video_create_params.ImageToVideoCreateParams,
|
101
|
+
),
|
102
|
+
options=make_request_options(
|
103
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
104
|
+
),
|
105
|
+
cast_to=ImageToVideoCreateResponse,
|
106
|
+
)
|
107
|
+
|
108
|
+
|
109
|
+
class AsyncImageToVideoResource(AsyncAPIResource):
|
110
|
+
@cached_property
|
111
|
+
def with_raw_response(self) -> AsyncImageToVideoResourceWithRawResponse:
|
112
|
+
"""
|
113
|
+
This property can be used as a prefix for any HTTP method call to return the
|
114
|
+
the raw response object instead of the parsed content.
|
115
|
+
|
116
|
+
For more information, see https://www.github.com/runwayml/sdk-python#accessing-raw-response-data-eg-headers
|
117
|
+
"""
|
118
|
+
return AsyncImageToVideoResourceWithRawResponse(self)
|
119
|
+
|
120
|
+
@cached_property
|
121
|
+
def with_streaming_response(self) -> AsyncImageToVideoResourceWithStreamingResponse:
|
122
|
+
"""
|
123
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
124
|
+
|
125
|
+
For more information, see https://www.github.com/runwayml/sdk-python#with_streaming_response
|
126
|
+
"""
|
127
|
+
return AsyncImageToVideoResourceWithStreamingResponse(self)
|
128
|
+
|
129
|
+
async def create(
|
130
|
+
self,
|
131
|
+
*,
|
132
|
+
model: Literal["gen3a_turbo"],
|
133
|
+
prompt_image: str,
|
134
|
+
prompt_text: str | NotGiven = NOT_GIVEN,
|
135
|
+
seed: int | NotGiven = NOT_GIVEN,
|
136
|
+
watermark: bool | NotGiven = NOT_GIVEN,
|
137
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
138
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
139
|
+
extra_headers: Headers | None = None,
|
140
|
+
extra_query: Query | None = None,
|
141
|
+
extra_body: Body | None = None,
|
142
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
143
|
+
) -> ImageToVideoCreateResponse:
|
144
|
+
"""
|
145
|
+
This endpoint will start a new task to generate a video from an image prompt.
|
146
|
+
|
147
|
+
Args:
|
148
|
+
model: The model variant to use.
|
149
|
+
|
150
|
+
prompt_image: A HTTPS URL pointing to an image. Images must be JPEG, PNG, or WebP and are
|
151
|
+
limited to 16MB. Responses must include a valid `Content-Length` header.
|
152
|
+
|
153
|
+
prompt_text
|
154
|
+
|
155
|
+
seed: If unspecified, a random number is chosen. Varying the seed integer is a way to
|
156
|
+
get different results for the same other request parameters. Using the same seed
|
157
|
+
integer for an identical request will produce similar results.
|
158
|
+
|
159
|
+
watermark: A boolean indicating whether or not the output video will contain a Runway
|
160
|
+
watermark.
|
161
|
+
|
162
|
+
extra_headers: Send extra headers
|
163
|
+
|
164
|
+
extra_query: Add additional query parameters to the request
|
165
|
+
|
166
|
+
extra_body: Add additional JSON properties to the request
|
167
|
+
|
168
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
169
|
+
"""
|
170
|
+
return await self._post(
|
171
|
+
"/v1/image_to_video",
|
172
|
+
body=await async_maybe_transform(
|
173
|
+
{
|
174
|
+
"model": model,
|
175
|
+
"prompt_image": prompt_image,
|
176
|
+
"prompt_text": prompt_text,
|
177
|
+
"seed": seed,
|
178
|
+
"watermark": watermark,
|
179
|
+
},
|
180
|
+
image_to_video_create_params.ImageToVideoCreateParams,
|
181
|
+
),
|
182
|
+
options=make_request_options(
|
183
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
184
|
+
),
|
185
|
+
cast_to=ImageToVideoCreateResponse,
|
186
|
+
)
|
187
|
+
|
188
|
+
|
189
|
+
class ImageToVideoResourceWithRawResponse:
|
190
|
+
def __init__(self, image_to_video: ImageToVideoResource) -> None:
|
191
|
+
self._image_to_video = image_to_video
|
192
|
+
|
193
|
+
self.create = to_raw_response_wrapper(
|
194
|
+
image_to_video.create,
|
195
|
+
)
|
196
|
+
|
197
|
+
|
198
|
+
class AsyncImageToVideoResourceWithRawResponse:
|
199
|
+
def __init__(self, image_to_video: AsyncImageToVideoResource) -> None:
|
200
|
+
self._image_to_video = image_to_video
|
201
|
+
|
202
|
+
self.create = async_to_raw_response_wrapper(
|
203
|
+
image_to_video.create,
|
204
|
+
)
|
205
|
+
|
206
|
+
|
207
|
+
class ImageToVideoResourceWithStreamingResponse:
|
208
|
+
def __init__(self, image_to_video: ImageToVideoResource) -> None:
|
209
|
+
self._image_to_video = image_to_video
|
210
|
+
|
211
|
+
self.create = to_streamed_response_wrapper(
|
212
|
+
image_to_video.create,
|
213
|
+
)
|
214
|
+
|
215
|
+
|
216
|
+
class AsyncImageToVideoResourceWithStreamingResponse:
|
217
|
+
def __init__(self, image_to_video: AsyncImageToVideoResource) -> None:
|
218
|
+
self._image_to_video = image_to_video
|
219
|
+
|
220
|
+
self.create = async_to_streamed_response_wrapper(
|
221
|
+
image_to_video.create,
|
222
|
+
)
|