runwayml 2.0.0__py3-none-any.whl → 2.1.1__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/_base_client.py CHANGED
@@ -143,6 +143,12 @@ class PageInfo:
143
143
  self.url = url
144
144
  self.params = params
145
145
 
146
+ @override
147
+ def __repr__(self) -> str:
148
+ if self.url:
149
+ return f"{self.__class__.__name__}(url={self.url})"
150
+ return f"{self.__class__.__name__}(params={self.params})"
151
+
146
152
 
147
153
  class BasePage(GenericModel, Generic[_T]):
148
154
  """
@@ -689,7 +695,8 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
689
695
  if retry_after is not None and 0 < retry_after <= 60:
690
696
  return retry_after
691
697
 
692
- nb_retries = max_retries - remaining_retries
698
+ # Also cap retry count to 1000 to avoid any potential overflows with `pow`
699
+ nb_retries = min(max_retries - remaining_retries, 1000)
693
700
 
694
701
  # Apply exponential backoff, but not more than the max.
695
702
  sleep_seconds = min(INITIAL_RETRY_DELAY * pow(2.0, nb_retries), MAX_RETRY_DELAY)
@@ -785,6 +792,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
785
792
  custom_query: Mapping[str, object] | None = None,
786
793
  _strict_response_validation: bool,
787
794
  ) -> None:
795
+ kwargs: dict[str, Any] = {}
788
796
  if limits is not None:
789
797
  warnings.warn(
790
798
  "The `connection_pool_limits` argument is deprecated. The `http_client` argument should be passed instead",
@@ -797,6 +805,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
797
805
  limits = DEFAULT_CONNECTION_LIMITS
798
806
 
799
807
  if transport is not None:
808
+ kwargs["transport"] = transport
800
809
  warnings.warn(
801
810
  "The `transport` argument is deprecated. The `http_client` argument should be passed instead",
802
811
  category=DeprecationWarning,
@@ -806,6 +815,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
806
815
  raise ValueError("The `http_client` argument is mutually exclusive with `transport`")
807
816
 
808
817
  if proxies is not None:
818
+ kwargs["proxies"] = proxies
809
819
  warnings.warn(
810
820
  "The `proxies` argument is deprecated. The `http_client` argument should be passed instead",
811
821
  category=DeprecationWarning,
@@ -849,10 +859,9 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
849
859
  base_url=base_url,
850
860
  # cast to a valid type because mypy doesn't understand our type narrowing
851
861
  timeout=cast(Timeout, timeout),
852
- proxies=proxies,
853
- transport=transport,
854
862
  limits=limits,
855
863
  follow_redirects=True,
864
+ **kwargs, # type: ignore
856
865
  )
857
866
 
858
867
  def is_closed(self) -> bool:
@@ -1351,6 +1360,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1351
1360
  custom_headers: Mapping[str, str] | None = None,
1352
1361
  custom_query: Mapping[str, object] | None = None,
1353
1362
  ) -> None:
1363
+ kwargs: dict[str, Any] = {}
1354
1364
  if limits is not None:
1355
1365
  warnings.warn(
1356
1366
  "The `connection_pool_limits` argument is deprecated. The `http_client` argument should be passed instead",
@@ -1363,6 +1373,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1363
1373
  limits = DEFAULT_CONNECTION_LIMITS
1364
1374
 
1365
1375
  if transport is not None:
1376
+ kwargs["transport"] = transport
1366
1377
  warnings.warn(
1367
1378
  "The `transport` argument is deprecated. The `http_client` argument should be passed instead",
1368
1379
  category=DeprecationWarning,
@@ -1372,6 +1383,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1372
1383
  raise ValueError("The `http_client` argument is mutually exclusive with `transport`")
1373
1384
 
1374
1385
  if proxies is not None:
1386
+ kwargs["proxies"] = proxies
1375
1387
  warnings.warn(
1376
1388
  "The `proxies` argument is deprecated. The `http_client` argument should be passed instead",
1377
1389
  category=DeprecationWarning,
@@ -1415,10 +1427,9 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1415
1427
  base_url=base_url,
1416
1428
  # cast to a valid type because mypy doesn't understand our type narrowing
1417
1429
  timeout=cast(Timeout, timeout),
1418
- proxies=proxies,
1419
- transport=transport,
1420
1430
  limits=limits,
1421
1431
  follow_redirects=True,
1432
+ **kwargs, # type: ignore
1422
1433
  )
1423
1434
 
1424
1435
  def is_closed(self) -> bool:
@@ -1568,7 +1579,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1568
1579
  except Exception as err:
1569
1580
  log.debug("Encountered Exception", exc_info=True)
1570
1581
 
1571
- if retries_taken > 0:
1582
+ if remaining_retries > 0:
1572
1583
  return await self._retry_request(
1573
1584
  input_options,
1574
1585
  cast_to,
runwayml/_client.py CHANGED
@@ -59,7 +59,7 @@ class RunwayML(SyncAPIClient):
59
59
  self,
60
60
  *,
61
61
  api_key: str | None = None,
62
- runway_version: str | None = "2024-09-13",
62
+ runway_version: str | None = "2024-11-06",
63
63
  base_url: str | httpx.URL | None = None,
64
64
  timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
65
65
  max_retries: int = DEFAULT_MAX_RETRIES,
@@ -92,7 +92,7 @@ class RunwayML(SyncAPIClient):
92
92
  self.api_key = api_key
93
93
 
94
94
  if runway_version is None:
95
- runway_version = "2024-09-13"
95
+ runway_version = "2024-11-06"
96
96
  self.runway_version = runway_version
97
97
 
98
98
  if base_url is None:
@@ -238,7 +238,7 @@ class AsyncRunwayML(AsyncAPIClient):
238
238
  self,
239
239
  *,
240
240
  api_key: str | None = None,
241
- runway_version: str | None = "2024-09-13",
241
+ runway_version: str | None = "2024-11-06",
242
242
  base_url: str | httpx.URL | None = None,
243
243
  timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
244
244
  max_retries: int = DEFAULT_MAX_RETRIES,
@@ -271,7 +271,7 @@ class AsyncRunwayML(AsyncAPIClient):
271
271
  self.api_key = api_key
272
272
 
273
273
  if runway_version is None:
274
- runway_version = "2024-09-13"
274
+ runway_version = "2024-11-06"
275
275
  self.runway_version = runway_version
276
276
 
277
277
  if base_url is None:
runwayml/_compat.py CHANGED
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING, Any, Union, Generic, TypeVar, Callable, cast, overload
4
4
  from datetime import date, datetime
5
- from typing_extensions import Self
5
+ from typing_extensions import Self, Literal
6
6
 
7
7
  import pydantic
8
8
  from pydantic.fields import FieldInfo
@@ -133,17 +133,20 @@ def model_json(model: pydantic.BaseModel, *, indent: int | None = None) -> str:
133
133
  def model_dump(
134
134
  model: pydantic.BaseModel,
135
135
  *,
136
- exclude: IncEx = None,
136
+ exclude: IncEx | None = None,
137
137
  exclude_unset: bool = False,
138
138
  exclude_defaults: bool = False,
139
139
  warnings: bool = True,
140
+ mode: Literal["json", "python"] = "python",
140
141
  ) -> dict[str, Any]:
141
- if PYDANTIC_V2:
142
+ if PYDANTIC_V2 or hasattr(model, "model_dump"):
142
143
  return model.model_dump(
144
+ mode=mode,
143
145
  exclude=exclude,
144
146
  exclude_unset=exclude_unset,
145
147
  exclude_defaults=exclude_defaults,
146
- warnings=warnings,
148
+ # warnings are not supported in Pydantic v1
149
+ warnings=warnings if PYDANTIC_V2 else True,
147
150
  )
148
151
  return cast(
149
152
  "dict[str, Any]",
@@ -211,9 +214,6 @@ if TYPE_CHECKING:
211
214
  # __set__ is not defined at runtime, but @cached_property is designed to be settable
212
215
  def __set__(self, instance: object, value: _T) -> None: ...
213
216
  else:
214
- try:
215
- from functools import cached_property as cached_property
216
- except ImportError:
217
- from cached_property import cached_property as cached_property
217
+ from functools import cached_property as cached_property
218
218
 
219
219
  typed_cached_property = cached_property
runwayml/_models.py CHANGED
@@ -37,6 +37,7 @@ from ._utils import (
37
37
  PropertyInfo,
38
38
  is_list,
39
39
  is_given,
40
+ json_safe,
40
41
  lru_cache,
41
42
  is_mapping,
42
43
  parse_date,
@@ -176,7 +177,7 @@ class BaseModel(pydantic.BaseModel):
176
177
  # Based on https://github.com/samuelcolvin/pydantic/issues/1168#issuecomment-817742836.
177
178
  @classmethod
178
179
  @override
179
- def construct(
180
+ def construct( # pyright: ignore[reportIncompatibleMethodOverride]
180
181
  cls: Type[ModelT],
181
182
  _fields_set: set[str] | None = None,
182
183
  **values: object,
@@ -248,8 +249,8 @@ class BaseModel(pydantic.BaseModel):
248
249
  self,
249
250
  *,
250
251
  mode: Literal["json", "python"] | str = "python",
251
- include: IncEx = None,
252
- exclude: IncEx = None,
252
+ include: IncEx | None = None,
253
+ exclude: IncEx | None = None,
253
254
  by_alias: bool = False,
254
255
  exclude_unset: bool = False,
255
256
  exclude_defaults: bool = False,
@@ -279,8 +280,8 @@ class BaseModel(pydantic.BaseModel):
279
280
  Returns:
280
281
  A dictionary representation of the model.
281
282
  """
282
- if mode != "python":
283
- raise ValueError("mode is only supported in Pydantic v2")
283
+ if mode not in {"json", "python"}:
284
+ raise ValueError("mode must be either 'json' or 'python'")
284
285
  if round_trip != False:
285
286
  raise ValueError("round_trip is only supported in Pydantic v2")
286
287
  if warnings != True:
@@ -289,7 +290,7 @@ class BaseModel(pydantic.BaseModel):
289
290
  raise ValueError("context is only supported in Pydantic v2")
290
291
  if serialize_as_any != False:
291
292
  raise ValueError("serialize_as_any is only supported in Pydantic v2")
292
- return super().dict( # pyright: ignore[reportDeprecated]
293
+ dumped = super().dict( # pyright: ignore[reportDeprecated]
293
294
  include=include,
294
295
  exclude=exclude,
295
296
  by_alias=by_alias,
@@ -298,13 +299,15 @@ class BaseModel(pydantic.BaseModel):
298
299
  exclude_none=exclude_none,
299
300
  )
300
301
 
302
+ return cast(dict[str, Any], json_safe(dumped)) if mode == "json" else dumped
303
+
301
304
  @override
302
305
  def model_dump_json(
303
306
  self,
304
307
  *,
305
308
  indent: int | None = None,
306
- include: IncEx = None,
307
- exclude: IncEx = None,
309
+ include: IncEx | None = None,
310
+ exclude: IncEx | None = None,
308
311
  by_alias: bool = False,
309
312
  exclude_unset: bool = False,
310
313
  exclude_defaults: bool = False,
runwayml/_response.py CHANGED
@@ -192,6 +192,9 @@ class BaseAPIResponse(Generic[R]):
192
192
  if cast_to == float:
193
193
  return cast(R, float(response.text))
194
194
 
195
+ if cast_to == bool:
196
+ return cast(R, response.text.lower() == "true")
197
+
195
198
  origin = get_origin(cast_to) or cast_to
196
199
 
197
200
  if origin == APIResponse:
runwayml/_types.py CHANGED
@@ -16,7 +16,7 @@ from typing import (
16
16
  Optional,
17
17
  Sequence,
18
18
  )
19
- from typing_extensions import Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable
19
+ from typing_extensions import Set, Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable
20
20
 
21
21
  import httpx
22
22
  import pydantic
@@ -193,7 +193,9 @@ StrBytesIntFloat = Union[str, bytes, int, float]
193
193
 
194
194
  # Note: copied from Pydantic
195
195
  # https://github.com/pydantic/pydantic/blob/32ea570bf96e84234d2992e1ddf40ab8a565925a/pydantic/main.py#L49
196
- IncEx: TypeAlias = "set[int] | set[str] | dict[int, Any] | dict[str, Any] | None"
196
+ IncEx: TypeAlias = Union[
197
+ Set[int], Set[str], Mapping[int, Union["IncEx", Literal[True]]], Mapping[str, Union["IncEx", Literal[True]]]
198
+ ]
197
199
 
198
200
  PostParser = Callable[[Any], Any]
199
201
 
@@ -6,6 +6,7 @@ from ._utils import (
6
6
  is_list as is_list,
7
7
  is_given as is_given,
8
8
  is_tuple as is_tuple,
9
+ json_safe as json_safe,
9
10
  lru_cache as lru_cache,
10
11
  is_mapping as is_mapping,
11
12
  is_tuple_t as is_tuple_t,
runwayml/_utils/_sync.py CHANGED
@@ -1,56 +1,62 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import sys
4
+ import asyncio
3
5
  import functools
4
- from typing import TypeVar, Callable, Awaitable
6
+ import contextvars
7
+ from typing import Any, TypeVar, Callable, Awaitable
5
8
  from typing_extensions import ParamSpec
6
9
 
7
- import anyio
8
- import anyio.to_thread
9
-
10
- from ._reflection import function_has_argument
11
-
12
10
  T_Retval = TypeVar("T_Retval")
13
11
  T_ParamSpec = ParamSpec("T_ParamSpec")
14
12
 
15
13
 
16
- # copied from `asyncer`, https://github.com/tiangolo/asyncer
17
- def asyncify(
18
- function: Callable[T_ParamSpec, T_Retval],
19
- *,
20
- cancellable: bool = False,
21
- limiter: anyio.CapacityLimiter | None = None,
22
- ) -> Callable[T_ParamSpec, Awaitable[T_Retval]]:
14
+ if sys.version_info >= (3, 9):
15
+ to_thread = asyncio.to_thread
16
+ else:
17
+ # backport of https://docs.python.org/3/library/asyncio-task.html#asyncio.to_thread
18
+ # for Python 3.8 support
19
+ async def to_thread(
20
+ func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs
21
+ ) -> Any:
22
+ """Asynchronously run function *func* in a separate thread.
23
+
24
+ Any *args and **kwargs supplied for this function are directly passed
25
+ to *func*. Also, the current :class:`contextvars.Context` is propagated,
26
+ allowing context variables from the main thread to be accessed in the
27
+ separate thread.
28
+
29
+ Returns a coroutine that can be awaited to get the eventual result of *func*.
30
+ """
31
+ loop = asyncio.events.get_running_loop()
32
+ ctx = contextvars.copy_context()
33
+ func_call = functools.partial(ctx.run, func, *args, **kwargs)
34
+ return await loop.run_in_executor(None, func_call)
35
+
36
+
37
+ # inspired by `asyncer`, https://github.com/tiangolo/asyncer
38
+ def asyncify(function: Callable[T_ParamSpec, T_Retval]) -> Callable[T_ParamSpec, Awaitable[T_Retval]]:
23
39
  """
24
40
  Take a blocking function and create an async one that receives the same
25
- positional and keyword arguments, and that when called, calls the original function
26
- in a worker thread using `anyio.to_thread.run_sync()`. Internally,
27
- `asyncer.asyncify()` uses the same `anyio.to_thread.run_sync()`, but it supports
28
- keyword arguments additional to positional arguments and it adds better support for
29
- autocompletion and inline errors for the arguments of the function called and the
30
- return value.
31
-
32
- If the `cancellable` option is enabled and the task waiting for its completion is
33
- cancelled, the thread will still run its course but its return value (or any raised
34
- exception) will be ignored.
41
+ positional and keyword arguments. For python version 3.9 and above, it uses
42
+ asyncio.to_thread to run the function in a separate thread. For python version
43
+ 3.8, it uses locally defined copy of the asyncio.to_thread function which was
44
+ introduced in python 3.9.
35
45
 
36
- Use it like this:
46
+ Usage:
37
47
 
38
- ```Python
39
- def do_work(arg1, arg2, kwarg1="", kwarg2="") -> str:
40
- # Do work
41
- return "Some result"
48
+ ```python
49
+ def blocking_func(arg1, arg2, kwarg1=None):
50
+ # blocking code
51
+ return result
42
52
 
43
53
 
44
- result = await to_thread.asyncify(do_work)("spam", "ham", kwarg1="a", kwarg2="b")
45
- print(result)
54
+ result = asyncify(blocking_function)(arg1, arg2, kwarg1=value1)
46
55
  ```
47
56
 
48
57
  ## Arguments
49
58
 
50
59
  `function`: a blocking regular callable (e.g. a function)
51
- `cancellable`: `True` to allow cancellation of the operation
52
- `limiter`: capacity limiter to use to limit the total amount of threads running
53
- (if omitted, the default limiter is used)
54
60
 
55
61
  ## Return
56
62
 
@@ -60,22 +66,6 @@ def asyncify(
60
66
  """
61
67
 
62
68
  async def wrapper(*args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs) -> T_Retval:
63
- partial_f = functools.partial(function, *args, **kwargs)
64
-
65
- # In `v4.1.0` anyio added the `abandon_on_cancel` argument and deprecated the old
66
- # `cancellable` argument, so we need to use the new `abandon_on_cancel` to avoid
67
- # surfacing deprecation warnings.
68
- if function_has_argument(anyio.to_thread.run_sync, "abandon_on_cancel"):
69
- return await anyio.to_thread.run_sync(
70
- partial_f,
71
- abandon_on_cancel=cancellable,
72
- limiter=limiter,
73
- )
74
-
75
- return await anyio.to_thread.run_sync(
76
- partial_f,
77
- cancellable=cancellable,
78
- limiter=limiter,
79
- )
69
+ return await to_thread(function, *args, **kwargs)
80
70
 
81
71
  return wrapper
@@ -173,6 +173,11 @@ def _transform_recursive(
173
173
  # Iterable[T]
174
174
  or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
175
175
  ):
176
+ # dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
177
+ # intended as an iterable, so we don't transform it.
178
+ if isinstance(data, dict):
179
+ return cast(object, data)
180
+
176
181
  inner_type = extract_type_arg(stripped_type, 0)
177
182
  return [_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]
178
183
 
@@ -186,7 +191,7 @@ def _transform_recursive(
186
191
  return data
187
192
 
188
193
  if isinstance(data, pydantic.BaseModel):
189
- return model_dump(data, exclude_unset=True)
194
+ return model_dump(data, exclude_unset=True, mode="json")
190
195
 
191
196
  annotated_type = _get_annotated_type(annotation)
192
197
  if annotated_type is None:
@@ -311,6 +316,11 @@ async def _async_transform_recursive(
311
316
  # Iterable[T]
312
317
  or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
313
318
  ):
319
+ # dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
320
+ # intended as an iterable, so we don't transform it.
321
+ if isinstance(data, dict):
322
+ return cast(object, data)
323
+
314
324
  inner_type = extract_type_arg(stripped_type, 0)
315
325
  return [await _async_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]
316
326
 
@@ -324,7 +334,7 @@ async def _async_transform_recursive(
324
334
  return data
325
335
 
326
336
  if isinstance(data, pydantic.BaseModel):
327
- return model_dump(data, exclude_unset=True)
337
+ return model_dump(data, exclude_unset=True, mode="json")
328
338
 
329
339
  annotated_type = _get_annotated_type(annotation)
330
340
  if annotated_type is None:
runwayml/_utils/_utils.py CHANGED
@@ -16,6 +16,7 @@ from typing import (
16
16
  overload,
17
17
  )
18
18
  from pathlib import Path
19
+ from datetime import date, datetime
19
20
  from typing_extensions import TypeGuard
20
21
 
21
22
  import sniffio
@@ -395,3 +396,19 @@ def lru_cache(*, maxsize: int | None = 128) -> Callable[[CallableT], CallableT]:
395
396
  maxsize=maxsize,
396
397
  )
397
398
  return cast(Any, wrapper) # type: ignore[no-any-return]
399
+
400
+
401
+ def json_safe(data: object) -> object:
402
+ """Translates a mapping / sequence recursively in the same fashion
403
+ as `pydantic` v2's `model_dump(mode="json")`.
404
+ """
405
+ if is_mapping(data):
406
+ return {json_safe(key): json_safe(value) for key, value in data.items()}
407
+
408
+ if is_iterable(data) and not isinstance(data, (str, bytes, bytearray)):
409
+ return [json_safe(item) for item in data]
410
+
411
+ if isinstance(data, (datetime, date)):
412
+ return data.isoformat()
413
+
414
+ return data
runwayml/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "runwayml"
4
- __version__ = "2.0.0" # x-release-please-version
4
+ __version__ = "2.1.1" # x-release-please-version
@@ -2,6 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ from typing import Union, Iterable
5
6
  from typing_extensions import Literal
6
7
 
7
8
  import httpx
@@ -50,10 +51,10 @@ class ImageToVideoResource(SyncAPIResource):
50
51
  self,
51
52
  *,
52
53
  model: Literal["gen3a_turbo"],
53
- prompt_image: str,
54
+ prompt_image: Union[str, Iterable[image_to_video_create_params.PromptImagePromptImage]],
54
55
  duration: Literal[5, 10] | NotGiven = NOT_GIVEN,
55
56
  prompt_text: str | NotGiven = NOT_GIVEN,
56
- ratio: Literal["16:9", "9:16"] | NotGiven = NOT_GIVEN,
57
+ ratio: Literal["1280:768", "768:1280"] | NotGiven = NOT_GIVEN,
57
58
  seed: int | NotGiven = NOT_GIVEN,
58
59
  watermark: bool | NotGiven = NOT_GIVEN,
59
60
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -69,14 +70,15 @@ class ImageToVideoResource(SyncAPIResource):
69
70
  Args:
70
71
  model: The model variant to use.
71
72
 
72
- prompt_image: A HTTPS URL pointing to an image. Images must be JPEG, PNG, or WebP and are
73
- limited to 16MB. Responses must include a valid `Content-Length` header.
73
+ prompt_image: A HTTPS URL or data URI containing an encoded image to be used as the first
74
+ frame of the generated video. See [our docs](/assets/inputs#images) on image
75
+ inputs for more information.
74
76
 
75
77
  duration: The number of seconds of duration for the output video.
76
78
 
77
79
  prompt_text
78
80
 
79
- ratio: The aspect ratio of the output video.
81
+ ratio
80
82
 
81
83
  seed: If unspecified, a random number is chosen. Varying the seed integer is a way to
82
84
  get different results for the same other request parameters. Using the same seed
@@ -138,10 +140,10 @@ class AsyncImageToVideoResource(AsyncAPIResource):
138
140
  self,
139
141
  *,
140
142
  model: Literal["gen3a_turbo"],
141
- prompt_image: str,
143
+ prompt_image: Union[str, Iterable[image_to_video_create_params.PromptImagePromptImage]],
142
144
  duration: Literal[5, 10] | NotGiven = NOT_GIVEN,
143
145
  prompt_text: str | NotGiven = NOT_GIVEN,
144
- ratio: Literal["16:9", "9:16"] | NotGiven = NOT_GIVEN,
146
+ ratio: Literal["1280:768", "768:1280"] | NotGiven = NOT_GIVEN,
145
147
  seed: int | NotGiven = NOT_GIVEN,
146
148
  watermark: bool | NotGiven = NOT_GIVEN,
147
149
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -157,14 +159,15 @@ class AsyncImageToVideoResource(AsyncAPIResource):
157
159
  Args:
158
160
  model: The model variant to use.
159
161
 
160
- prompt_image: A HTTPS URL pointing to an image. Images must be JPEG, PNG, or WebP and are
161
- limited to 16MB. Responses must include a valid `Content-Length` header.
162
+ prompt_image: A HTTPS URL or data URI containing an encoded image to be used as the first
163
+ frame of the generated video. See [our docs](/assets/inputs#images) on image
164
+ inputs for more information.
162
165
 
163
166
  duration: The number of seconds of duration for the output video.
164
167
 
165
168
  prompt_text
166
169
 
167
- ratio: The aspect ratio of the output video.
170
+ ratio
168
171
 
169
172
  seed: If unspecified, a random number is chosen. Varying the seed integer is a way to
170
173
  get different results for the same other request parameters. Using the same seed
@@ -2,22 +2,23 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ from typing import Union, Iterable
5
6
  from typing_extensions import Literal, Required, Annotated, TypedDict
6
7
 
7
8
  from .._utils import PropertyInfo
8
9
 
9
- __all__ = ["ImageToVideoCreateParams"]
10
+ __all__ = ["ImageToVideoCreateParams", "PromptImagePromptImage"]
10
11
 
11
12
 
12
13
  class ImageToVideoCreateParams(TypedDict, total=False):
13
14
  model: Required[Literal["gen3a_turbo"]]
14
15
  """The model variant to use."""
15
16
 
16
- prompt_image: Required[Annotated[str, PropertyInfo(alias="promptImage")]]
17
- """A HTTPS URL pointing to an image.
18
-
19
- Images must be JPEG, PNG, or WebP and are limited to 16MB. Responses must
20
- include a valid `Content-Length` header.
17
+ prompt_image: Required[Annotated[Union[str, Iterable[PromptImagePromptImage]], PropertyInfo(alias="promptImage")]]
18
+ """
19
+ A HTTPS URL or data URI containing an encoded image to be used as the first
20
+ frame of the generated video. See [our docs](/assets/inputs#images) on image
21
+ inputs for more information.
21
22
  """
22
23
 
23
24
  duration: Literal[5, 10]
@@ -25,8 +26,7 @@ class ImageToVideoCreateParams(TypedDict, total=False):
25
26
 
26
27
  prompt_text: Annotated[str, PropertyInfo(alias="promptText")]
27
28
 
28
- ratio: Literal["16:9", "9:16"]
29
- """The aspect ratio of the output video."""
29
+ ratio: Literal["1280:768", "768:1280"]
30
30
 
31
31
  seed: int
32
32
  """If unspecified, a random number is chosen.
@@ -41,3 +41,18 @@ class ImageToVideoCreateParams(TypedDict, total=False):
41
41
  A boolean indicating whether or not the output video will contain a Runway
42
42
  watermark.
43
43
  """
44
+
45
+
46
+ class PromptImagePromptImage(TypedDict, total=False):
47
+ position: Required[Literal["first", "last"]]
48
+ """The position of the image in the output video.
49
+
50
+ "first" will use the image as the first frame of the video, "last" will use the
51
+ image as the last frame of the video.
52
+ """
53
+
54
+ uri: Required[str]
55
+ """A HTTPS URL or data URI containing an encoded image.
56
+
57
+ See [our docs](/assets/inputs#images) on image inputs for more information.
58
+ """
@@ -1,7 +1,6 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
 
4
-
5
4
  from .._models import BaseModel
6
5
 
7
6
  __all__ = ["ImageToVideoCreateResponse"]
@@ -9,4 +8,7 @@ __all__ = ["ImageToVideoCreateResponse"]
9
8
 
10
9
  class ImageToVideoCreateResponse(BaseModel):
11
10
  id: str
12
- """The ID of the newly created task."""
11
+ """The ID of the newly created task.
12
+
13
+ Use this ID to query the task status and retrieve the generated video.
14
+ """
@@ -13,6 +13,7 @@ __all__ = ["TaskRetrieveResponse"]
13
13
 
14
14
  class TaskRetrieveResponse(BaseModel):
15
15
  id: str
16
+ """The ID of the task being returned."""
16
17
 
17
18
  created_at: datetime = FieldInfo(alias="createdAt")
18
19
  """The timestamp that the task was submitted at."""
@@ -1,12 +1,11 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: runwayml
3
- Version: 2.0.0
3
+ Version: 2.1.1
4
4
  Summary: The official Python library for the runwayml API
5
5
  Project-URL: Homepage, https://github.com/runwayml/sdk-python
6
6
  Project-URL: Repository, https://github.com/runwayml/sdk-python
7
7
  Author-email: RunwayML <dev-feedback@runwayml.com>
8
- License-Expression: Apache-2.0
9
- License-File: LICENSE
8
+ License: Apache-2.0
10
9
  Classifier: Intended Audience :: Developers
11
10
  Classifier: License :: OSI Approved :: Apache Software License
12
11
  Classifier: Operating System :: MacOS
@@ -14,7 +13,6 @@ Classifier: Operating System :: Microsoft :: Windows
14
13
  Classifier: Operating System :: OS Independent
15
14
  Classifier: Operating System :: POSIX
16
15
  Classifier: Operating System :: POSIX :: Linux
17
- Classifier: Programming Language :: Python :: 3.7
18
16
  Classifier: Programming Language :: Python :: 3.8
19
17
  Classifier: Programming Language :: Python :: 3.9
20
18
  Classifier: Programming Language :: Python :: 3.10
@@ -22,9 +20,8 @@ Classifier: Programming Language :: Python :: 3.11
22
20
  Classifier: Programming Language :: Python :: 3.12
23
21
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
22
  Classifier: Typing :: Typed
25
- Requires-Python: >=3.7
23
+ Requires-Python: >=3.8
26
24
  Requires-Dist: anyio<5,>=3.5.0
27
- Requires-Dist: cached-property; python_version < '3.8'
28
25
  Requires-Dist: distro<2,>=1.7.0
29
26
  Requires-Dist: httpx<1,>=0.23.0
30
27
  Requires-Dist: pydantic<3,>=1.9.0
@@ -36,7 +33,7 @@ Description-Content-Type: text/markdown
36
33
 
37
34
  [![PyPI version](https://img.shields.io/pypi/v/runwayml.svg)](https://pypi.org/project/runwayml/)
38
35
 
39
- The RunwayML Python library provides convenient access to the RunwayML REST API from any Python 3.7+
36
+ The RunwayML Python library provides convenient access to the RunwayML REST API from any Python 3.8+
40
37
  application. The library includes type definitions for all request params and response fields,
41
38
  and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).
42
39
 
@@ -62,8 +59,7 @@ import os
62
59
  from runwayml import RunwayML
63
60
 
64
61
  client = RunwayML(
65
- # This is the default and can be omitted
66
- api_key=os.environ.get("RUNWAYML_API_SECRET"),
62
+ api_key=os.environ.get("RUNWAYML_API_SECRET"), # This is the default and can be omitted
67
63
  )
68
64
 
69
65
  image_to_video = client.image_to_video.create(
@@ -89,8 +85,7 @@ import asyncio
89
85
  from runwayml import AsyncRunwayML
90
86
 
91
87
  client = AsyncRunwayML(
92
- # This is the default and can be omitted
93
- api_key=os.environ.get("RUNWAYML_API_SECRET"),
88
+ api_key=os.environ.get("RUNWAYML_API_SECRET"), # This is the default and can be omitted
94
89
  )
95
90
 
96
91
 
@@ -224,12 +219,14 @@ Note that requests that time out are [retried twice by default](https://github.c
224
219
 
225
220
  We use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.
226
221
 
227
- You can enable logging by setting the environment variable `RUNWAYML_LOG` to `debug`.
222
+ You can enable logging by setting the environment variable `RUNWAYML_LOG` to `info`.
228
223
 
229
224
  ```shell
230
- $ export RUNWAYML_LOG=debug
225
+ $ export RUNWAYML_LOG=info
231
226
  ```
232
227
 
228
+ Or to `debug` for more verbose logging.
229
+
233
230
  ### How to tell whether `None` means `null` or missing
234
231
 
235
232
  In an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:
@@ -376,7 +373,7 @@ print(runwayml.__version__)
376
373
 
377
374
  ## Requirements
378
375
 
379
- Python 3.7 or higher.
376
+ Python 3.8 or higher.
380
377
 
381
378
  ## Contributing
382
379
 
@@ -0,0 +1,36 @@
1
+ runwayml/__init__.py,sha256=LsywCoz3efgd9DJAXxam_dZp4-0CuDCfyY658Isqy8k,2458
2
+ runwayml/_base_client.py,sha256=Ehfq1oaghucmu9n_MpuoOlH-qZGbetwzgNOmVG81cns,68038
3
+ runwayml/_client.py,sha256=mJfU5Cq2rBWL1fwMlbjFd9w5oWZ8kb5Ps5B37y53PQw,16428
4
+ runwayml/_compat.py,sha256=VWemUKbj6DDkQ-O4baSpHVLJafotzeXmCQGJugfVTIw,6580
5
+ runwayml/_constants.py,sha256=JE8kyZa2Q4NK_i4fO--8siEYTzeHnT0fYbOFDgDP4uk,464
6
+ runwayml/_exceptions.py,sha256=p2Q8kywHCVQzArLQL4Ht-HetTBhAvevU6yDvEq7PpIE,3224
7
+ runwayml/_files.py,sha256=mf4dOgL4b0ryyZlbqLhggD3GVgDf6XxdGFAgce01ugE,3549
8
+ runwayml/_models.py,sha256=uhxvXZC0JO7HuGR_GWXH-zYKuptF2rwiGVJfMMfg3fw,28470
9
+ runwayml/_qs.py,sha256=AOkSz4rHtK4YI3ZU_kzea-zpwBUgEY8WniGmTPyEimc,4846
10
+ runwayml/_resource.py,sha256=BF-j3xY5eRTKmuTxg8eDhLtLP4MLB1phDh_B6BKipKA,1112
11
+ runwayml/_response.py,sha256=7EGNYCVRHiVys7y6gAx5HWIwUxWvmjhd05ur53OeFkQ,28621
12
+ runwayml/_streaming.py,sha256=NSVuAgknVQWU1cgZEjQn01IdZKKynb5rOeYp5Lo-OEQ,10108
13
+ runwayml/_types.py,sha256=Mr22kL-koHslGlVH9m-m0B9AMh9Ke2iktDDu_rTGdy4,6169
14
+ runwayml/_version.py,sha256=jewVENkeCrsl3eeyxLXqBB-3C3t83ldrhRd3uFyAEd4,160
15
+ runwayml/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ runwayml/_utils/__init__.py,sha256=k266EatJr88V8Zseb7xUimTlCeno9SynRfLwadHP1b4,2016
17
+ runwayml/_utils/_logs.py,sha256=ZfS5W59hdqEBVV86lNrk28PhvUxtHOzs9JqiLhSu0pI,780
18
+ runwayml/_utils/_proxy.py,sha256=z3zsateHtb0EARTWKk8QZNHfPkqJbqwd1lM993LBwGE,1902
19
+ runwayml/_utils/_reflection.py,sha256=ZmGkIgT_PuwedyNBrrKGbxoWtkpytJNU1uU4QHnmEMU,1364
20
+ runwayml/_utils/_streams.py,sha256=SMC90diFFecpEg_zgDRVbdR3hSEIgVVij4taD-noMLM,289
21
+ runwayml/_utils/_sync.py,sha256=jJl-iCEaZZUAkq4IUtzN1-aMsKTUFaNoNbeYnnpQjIQ,2438
22
+ runwayml/_utils/_transform.py,sha256=Dkkyr7OveGmOolepcvXmVJWE3kqim4b0nM0h7yWbgeY,13468
23
+ runwayml/_utils/_typing.py,sha256=tFbktdpdHCQliwzGsWysgn0P5H0JRdagkZdb_LegGkY,3838
24
+ runwayml/_utils/_utils.py,sha256=8UmbPOy_AAr2uUjjFui-VZSrVBHRj6bfNEKRp5YZP2A,12004
25
+ runwayml/lib/.keep,sha256=wuNrz-5SXo3jJaJOJgz4vFHM41YH_g20F5cRQo0vLes,224
26
+ runwayml/resources/__init__.py,sha256=O-ZVFaODsGXK0pKVlV4HKoeJyq3p9sK_9COJTv7P1WM,1069
27
+ runwayml/resources/image_to_video.py,sha256=bts-S7MA6Rk9p1BMx-2J8WOdrP5iw4c4Kor6jiYaseE,9391
28
+ runwayml/resources/tasks.py,sha256=j80KvE6QkVAJvfIUx37tJEizcBB1u5vhd9zkSiv6Tuk,9681
29
+ runwayml/types/__init__.py,sha256=R3cLEXzpcEpEOuxaFBo3R72ewH1LtjpkZ0aYOIt1CAo,400
30
+ runwayml/types/image_to_video_create_params.py,sha256=98DsjOHnmHEi8mVjZOQEDL3P1hJUT8uktp0mDA5WJ5Y,1869
31
+ runwayml/types/image_to_video_create_response.py,sha256=l5GszzUSItV-ZYHCB8hH_GSVibUZEkzfRLrAhXkd8O4,346
32
+ runwayml/types/task_retrieve_response.py,sha256=v8y2bLxsW6srzScW-B3Akv72q_PI_NQmduGrGRQMHds,2139
33
+ runwayml-2.1.1.dist-info/METADATA,sha256=1jF1NtUuZ-vNGcSndJolTsRgr3TEDG_e5I-JKo7xZf0,13303
34
+ runwayml-2.1.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
35
+ runwayml-2.1.1.dist-info/licenses/LICENSE,sha256=p4nykVRdA5nXTd8-slKCIfrlJZMB3wn8QBVasNQ_G_Q,11338
36
+ runwayml-2.1.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.25.0
2
+ Generator: hatchling 1.26.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,36 +0,0 @@
1
- runwayml/__init__.py,sha256=LsywCoz3efgd9DJAXxam_dZp4-0CuDCfyY658Isqy8k,2458
2
- runwayml/_base_client.py,sha256=VXZ-FzF2qniEobkIlTWQ_Ld0ZMofwnKNu638T4RsuSE,67551
3
- runwayml/_client.py,sha256=bXqlcEWa3xtVB70cQ3UN9eSBKV45WfEdSflQbeJpK0U,16428
4
- runwayml/_compat.py,sha256=9CWnEaYK0kot7aSNW-m2W9xZb5giIdvKN9sWxvBbbSA,6488
5
- runwayml/_constants.py,sha256=JE8kyZa2Q4NK_i4fO--8siEYTzeHnT0fYbOFDgDP4uk,464
6
- runwayml/_exceptions.py,sha256=p2Q8kywHCVQzArLQL4Ht-HetTBhAvevU6yDvEq7PpIE,3224
7
- runwayml/_files.py,sha256=mf4dOgL4b0ryyZlbqLhggD3GVgDf6XxdGFAgce01ugE,3549
8
- runwayml/_models.py,sha256=pXirq94yiihFXBbiR50vA-0NIlDurxbJ_rLXK062vWQ,28267
9
- runwayml/_qs.py,sha256=AOkSz4rHtK4YI3ZU_kzea-zpwBUgEY8WniGmTPyEimc,4846
10
- runwayml/_resource.py,sha256=BF-j3xY5eRTKmuTxg8eDhLtLP4MLB1phDh_B6BKipKA,1112
11
- runwayml/_response.py,sha256=sKuVjGpyu3n8kUojbOPqPUtxKMKYWQOBEaPM9Y-I9J4,28532
12
- runwayml/_streaming.py,sha256=NSVuAgknVQWU1cgZEjQn01IdZKKynb5rOeYp5Lo-OEQ,10108
13
- runwayml/_types.py,sha256=8a6x8uZ5xoBLrmu6rK3X9NKZhcMYcaE2tUeh3wgKHNk,6105
14
- runwayml/_version.py,sha256=4m1aRIUMyDTo1gDj3xtglqgDkjnJ-ozbHt8QFxYy3SE,160
15
- runwayml/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- runwayml/_utils/__init__.py,sha256=Uzq1-FIih_VUjzdNVWXks0sdC39KBKLMrZoz-_JOjJ4,1988
17
- runwayml/_utils/_logs.py,sha256=ZfS5W59hdqEBVV86lNrk28PhvUxtHOzs9JqiLhSu0pI,780
18
- runwayml/_utils/_proxy.py,sha256=z3zsateHtb0EARTWKk8QZNHfPkqJbqwd1lM993LBwGE,1902
19
- runwayml/_utils/_reflection.py,sha256=ZmGkIgT_PuwedyNBrrKGbxoWtkpytJNU1uU4QHnmEMU,1364
20
- runwayml/_utils/_streams.py,sha256=SMC90diFFecpEg_zgDRVbdR3hSEIgVVij4taD-noMLM,289
21
- runwayml/_utils/_sync.py,sha256=9ex9pfOyd8xAF1LxpFx4IkqL8k0vk8srE2Ee-OTMQ0A,2840
22
- runwayml/_utils/_transform.py,sha256=NCz3q9_O-vuj60xVe-qzhEQ8uJWlZWJTsM-GwHDccf8,12958
23
- runwayml/_utils/_typing.py,sha256=tFbktdpdHCQliwzGsWysgn0P5H0JRdagkZdb_LegGkY,3838
24
- runwayml/_utils/_utils.py,sha256=tYrr7IX-5NMwsVKbNggbzOM84uNw7XnAe06e2Ln8Or0,11472
25
- runwayml/lib/.keep,sha256=wuNrz-5SXo3jJaJOJgz4vFHM41YH_g20F5cRQo0vLes,224
26
- runwayml/resources/__init__.py,sha256=O-ZVFaODsGXK0pKVlV4HKoeJyq3p9sK_9COJTv7P1WM,1069
27
- runwayml/resources/image_to_video.py,sha256=B91VHPH5XdJbrbaXrTzBkLc4ed81-MkXOOFwIyc2eAc,9184
28
- runwayml/resources/tasks.py,sha256=j80KvE6QkVAJvfIUx37tJEizcBB1u5vhd9zkSiv6Tuk,9681
29
- runwayml/types/__init__.py,sha256=R3cLEXzpcEpEOuxaFBo3R72ewH1LtjpkZ0aYOIt1CAo,400
30
- runwayml/types/image_to_video_create_params.py,sha256=EkB8zKmqeupVfDANnrLdHvY5LgdOW1kf7oN4JPlbruY,1303
31
- runwayml/types/image_to_video_create_response.py,sha256=Qc5C86xJ_i1JkRLCCkEh6lMnPoO3-iB92gcR7mXooUw,266
32
- runwayml/types/task_retrieve_response.py,sha256=2BsxvP95VgKkn3rdv1vXotMV1zw8RwDSsO27AHjlpyc,2094
33
- runwayml-2.0.0.dist-info/METADATA,sha256=GYCmARjDBFcQSD0134xLlyIg5a34GvjLRrQcqs_bwI8,13408
34
- runwayml-2.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
35
- runwayml-2.0.0.dist-info/licenses/LICENSE,sha256=p4nykVRdA5nXTd8-slKCIfrlJZMB3wn8QBVasNQ_G_Q,11338
36
- runwayml-2.0.0.dist-info/RECORD,,