Skip to content

Commit 397e939

Browse files
fix(api): Make ratio a required parameter for i2v
1 parent 15cf17c commit 397e939

File tree

6 files changed

+51
-22
lines changed

6 files changed

+51
-22
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 4
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runwayml%2Frunwayml-8572445174f75794a6c3bdd3ffacd7ea80b140bb5ffbf59656e7da3668228249.yml
3-
openapi_spec_hash: 8b99d38d0511b6f4291a7d39c12d580e
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runwayml%2Frunwayml-50d72f887af30d0d676f216865284f2bc36899cc197f81774445e00bc0228c02.yml
3+
openapi_spec_hash: c692214e7e704169e0e82d5b367e8f8c
44
config_hash: 77ce816c37172a537f337abfaf2d65a9

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ client = RunwayML(
3434
image_to_video = client.image_to_video.create(
3535
model="gen4_turbo",
3636
prompt_image="https://example.com/assets/bunny.jpg",
37+
ratio="1280:720",
3738
prompt_text="The bunny is eating a carrot",
3839
)
3940
print(image_to_video.id)
@@ -62,6 +63,7 @@ async def main() -> None:
6263
image_to_video = await client.image_to_video.create(
6364
model="gen4_turbo",
6465
prompt_image="https://example.com/assets/bunny.jpg",
66+
ratio="1280:720",
6567
prompt_text="The bunny is eating a carrot",
6668
)
6769
print(image_to_video.id)
@@ -100,6 +102,7 @@ try:
100102
client.image_to_video.create(
101103
model="gen4_turbo",
102104
prompt_image="https://example.com/assets/bunny.jpg",
105+
ratio="1280:720",
103106
prompt_text="The bunny is eating a carrot",
104107
)
105108
except runwayml.APIConnectionError as e:
@@ -147,6 +150,7 @@ client = RunwayML(
147150
client.with_options(max_retries=5).image_to_video.create(
148151
model="gen4_turbo",
149152
prompt_image="https://example.com/assets/bunny.jpg",
153+
ratio="1280:720",
150154
prompt_text="The bunny is eating a carrot",
151155
)
152156
```
@@ -174,6 +178,7 @@ client = RunwayML(
174178
client.with_options(timeout=5.0).image_to_video.create(
175179
model="gen4_turbo",
176180
prompt_image="https://example.com/assets/bunny.jpg",
181+
ratio="1280:720",
177182
prompt_text="The bunny is eating a carrot",
178183
)
179184
```
@@ -219,6 +224,7 @@ client = RunwayML()
219224
response = client.image_to_video.with_raw_response.create(
220225
model="gen4_turbo",
221226
prompt_image="https://example.com/assets/bunny.jpg",
227+
ratio="1280:720",
222228
prompt_text="The bunny is eating a carrot",
223229
)
224230
print(response.headers.get('X-My-Header'))
@@ -241,6 +247,7 @@ To stream the response body, use `.with_streaming_response` instead, which requi
241247
with client.image_to_video.with_streaming_response.create(
242248
model="gen4_turbo",
243249
prompt_image="https://example.com/assets/bunny.jpg",
250+
ratio="1280:720",
244251
prompt_text="The bunny is eating a carrot",
245252
) as response:
246253
print(response.headers.get("X-My-Header"))

src/runwayml/resources/image_to_video.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ def create(
4949
*,
5050
model: Literal["gen4_turbo", "gen3a_turbo"],
5151
prompt_image: Union[str, Iterable[image_to_video_create_params.PromptImagePromptImage]],
52+
ratio: Literal["1280:720", "720:1280", "1104:832", "832:1104", "960:960", "1584:672", "1280:768", "768:1280"],
5253
duration: Literal[5, 10] | NotGiven = NOT_GIVEN,
5354
prompt_text: str | NotGiven = NOT_GIVEN,
54-
ratio: Literal["1280:720", "720:1280", "1104:832", "832:1104", "960:960", "1584:672", "1280:768", "768:1280"]
55-
| NotGiven = NOT_GIVEN,
5655
seed: int | NotGiven = NOT_GIVEN,
5756
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5857
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -71,12 +70,12 @@ def create(
7170
frame of the generated video. See [our docs](/assets/inputs#images) on image
7271
inputs for more information.
7372
73+
ratio
74+
7475
duration: The number of seconds of duration for the output video.
7576
7677
prompt_text
7778
78-
ratio
79-
8079
seed: If unspecified, a random number is chosen. Varying the seed integer is a way to
8180
get different results for the same other request parameters. Using the same seed
8281
integer for an identical request will produce similar results.
@@ -95,9 +94,9 @@ def create(
9594
{
9695
"model": model,
9796
"prompt_image": prompt_image,
97+
"ratio": ratio,
9898
"duration": duration,
9999
"prompt_text": prompt_text,
100-
"ratio": ratio,
101100
"seed": seed,
102101
},
103102
image_to_video_create_params.ImageToVideoCreateParams,
@@ -134,10 +133,9 @@ async def create(
134133
*,
135134
model: Literal["gen4_turbo", "gen3a_turbo"],
136135
prompt_image: Union[str, Iterable[image_to_video_create_params.PromptImagePromptImage]],
136+
ratio: Literal["1280:720", "720:1280", "1104:832", "832:1104", "960:960", "1584:672", "1280:768", "768:1280"],
137137
duration: Literal[5, 10] | NotGiven = NOT_GIVEN,
138138
prompt_text: str | NotGiven = NOT_GIVEN,
139-
ratio: Literal["1280:720", "720:1280", "1104:832", "832:1104", "960:960", "1584:672", "1280:768", "768:1280"]
140-
| NotGiven = NOT_GIVEN,
141139
seed: int | NotGiven = NOT_GIVEN,
142140
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
143141
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -156,12 +154,12 @@ async def create(
156154
frame of the generated video. See [our docs](/assets/inputs#images) on image
157155
inputs for more information.
158156
157+
ratio
158+
159159
duration: The number of seconds of duration for the output video.
160160
161161
prompt_text
162162
163-
ratio
164-
165163
seed: If unspecified, a random number is chosen. Varying the seed integer is a way to
166164
get different results for the same other request parameters. Using the same seed
167165
integer for an identical request will produce similar results.
@@ -180,9 +178,9 @@ async def create(
180178
{
181179
"model": model,
182180
"prompt_image": prompt_image,
181+
"ratio": ratio,
183182
"duration": duration,
184183
"prompt_text": prompt_text,
185-
"ratio": ratio,
186184
"seed": seed,
187185
},
188186
image_to_video_create_params.ImageToVideoCreateParams,

src/runwayml/types/image_to_video_create_params.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ class ImageToVideoCreateParams(TypedDict, total=False):
2121
inputs for more information.
2222
"""
2323

24+
ratio: Required[
25+
Literal["1280:720", "720:1280", "1104:832", "832:1104", "960:960", "1584:672", "1280:768", "768:1280"]
26+
]
27+
2428
duration: Literal[5, 10]
2529
"""The number of seconds of duration for the output video."""
2630

2731
prompt_text: Annotated[str, PropertyInfo(alias="promptText")]
2832

29-
ratio: Literal["1280:720", "720:1280", "1104:832", "832:1104", "960:960", "1584:672", "1280:768", "768:1280"]
30-
3133
seed: int
3234
"""If unspecified, a random number is chosen.
3335

tests/api_resources/test_image_to_video.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def test_method_create(self, client: RunwayML) -> None:
2222
image_to_video = client.image_to_video.create(
2323
model="gen4_turbo",
2424
prompt_image="https://example.com",
25+
ratio="1280:720",
2526
)
2627
assert_matches_type(ImageToVideoCreateResponse, image_to_video, path=["response"])
2728

@@ -30,9 +31,9 @@ def test_method_create_with_all_params(self, client: RunwayML) -> None:
3031
image_to_video = client.image_to_video.create(
3132
model="gen4_turbo",
3233
prompt_image="https://example.com",
34+
ratio="1280:720",
3335
duration=5,
3436
prompt_text="promptText",
35-
ratio="1280:720",
3637
seed=0,
3738
)
3839
assert_matches_type(ImageToVideoCreateResponse, image_to_video, path=["response"])
@@ -42,6 +43,7 @@ def test_raw_response_create(self, client: RunwayML) -> None:
4243
response = client.image_to_video.with_raw_response.create(
4344
model="gen4_turbo",
4445
prompt_image="https://example.com",
46+
ratio="1280:720",
4547
)
4648

4749
assert response.is_closed is True
@@ -54,6 +56,7 @@ def test_streaming_response_create(self, client: RunwayML) -> None:
5456
with client.image_to_video.with_streaming_response.create(
5557
model="gen4_turbo",
5658
prompt_image="https://example.com",
59+
ratio="1280:720",
5760
) as response:
5861
assert not response.is_closed
5962
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -72,6 +75,7 @@ async def test_method_create(self, async_client: AsyncRunwayML) -> None:
7275
image_to_video = await async_client.image_to_video.create(
7376
model="gen4_turbo",
7477
prompt_image="https://example.com",
78+
ratio="1280:720",
7579
)
7680
assert_matches_type(ImageToVideoCreateResponse, image_to_video, path=["response"])
7781

@@ -80,9 +84,9 @@ async def test_method_create_with_all_params(self, async_client: AsyncRunwayML)
8084
image_to_video = await async_client.image_to_video.create(
8185
model="gen4_turbo",
8286
prompt_image="https://example.com",
87+
ratio="1280:720",
8388
duration=5,
8489
prompt_text="promptText",
85-
ratio="1280:720",
8690
seed=0,
8791
)
8892
assert_matches_type(ImageToVideoCreateResponse, image_to_video, path=["response"])
@@ -92,6 +96,7 @@ async def test_raw_response_create(self, async_client: AsyncRunwayML) -> None:
9296
response = await async_client.image_to_video.with_raw_response.create(
9397
model="gen4_turbo",
9498
prompt_image="https://example.com",
99+
ratio="1280:720",
95100
)
96101

97102
assert response.is_closed is True
@@ -104,6 +109,7 @@ async def test_streaming_response_create(self, async_client: AsyncRunwayML) -> N
104109
async with async_client.image_to_video.with_streaming_response.create(
105110
model="gen4_turbo",
106111
prompt_image="https://example.com",
112+
ratio="1280:720",
107113
) as response:
108114
assert not response.is_closed
109115
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

tests/test_client.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,7 @@ def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> No
725725
dict(
726726
model="gen4_turbo",
727727
prompt_image="https://example.com/assets/bunny.jpg",
728+
ratio="1280:720",
728729
prompt_text="The bunny is eating a carrot",
729730
),
730731
ImageToVideoCreateParams,
@@ -750,6 +751,7 @@ def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> Non
750751
dict(
751752
model="gen4_turbo",
752753
prompt_image="https://example.com/assets/bunny.jpg",
754+
ratio="1280:720",
753755
prompt_text="The bunny is eating a carrot",
754756
),
755757
ImageToVideoCreateParams,
@@ -788,7 +790,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
788790
respx_mock.post("/v1/image_to_video").mock(side_effect=retry_handler)
789791

790792
response = client.image_to_video.with_raw_response.create(
791-
model="gen4_turbo", prompt_image="https://example.com"
793+
model="gen4_turbo", prompt_image="https://example.com", ratio="1280:720"
792794
)
793795

794796
assert response.retries_taken == failures_before_success
@@ -814,7 +816,10 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
814816
respx_mock.post("/v1/image_to_video").mock(side_effect=retry_handler)
815817

816818
response = client.image_to_video.with_raw_response.create(
817-
model="gen4_turbo", prompt_image="https://example.com", extra_headers={"x-stainless-retry-count": Omit()}
819+
model="gen4_turbo",
820+
prompt_image="https://example.com",
821+
ratio="1280:720",
822+
extra_headers={"x-stainless-retry-count": Omit()},
818823
)
819824

820825
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
@@ -839,7 +844,10 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
839844
respx_mock.post("/v1/image_to_video").mock(side_effect=retry_handler)
840845

841846
response = client.image_to_video.with_raw_response.create(
842-
model="gen4_turbo", prompt_image="https://example.com", extra_headers={"x-stainless-retry-count": "42"}
847+
model="gen4_turbo",
848+
prompt_image="https://example.com",
849+
ratio="1280:720",
850+
extra_headers={"x-stainless-retry-count": "42"},
843851
)
844852

845853
assert response.http_request.headers.get("x-stainless-retry-count") == "42"
@@ -1527,6 +1535,7 @@ async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter)
15271535
dict(
15281536
model="gen4_turbo",
15291537
prompt_image="https://example.com/assets/bunny.jpg",
1538+
ratio="1280:720",
15301539
prompt_text="The bunny is eating a carrot",
15311540
),
15321541
ImageToVideoCreateParams,
@@ -1552,6 +1561,7 @@ async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter)
15521561
dict(
15531562
model="gen4_turbo",
15541563
prompt_image="https://example.com/assets/bunny.jpg",
1564+
ratio="1280:720",
15551565
prompt_text="The bunny is eating a carrot",
15561566
),
15571567
ImageToVideoCreateParams,
@@ -1591,7 +1601,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
15911601
respx_mock.post("/v1/image_to_video").mock(side_effect=retry_handler)
15921602

15931603
response = await client.image_to_video.with_raw_response.create(
1594-
model="gen4_turbo", prompt_image="https://example.com"
1604+
model="gen4_turbo", prompt_image="https://example.com", ratio="1280:720"
15951605
)
15961606

15971607
assert response.retries_taken == failures_before_success
@@ -1618,7 +1628,10 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
16181628
respx_mock.post("/v1/image_to_video").mock(side_effect=retry_handler)
16191629

16201630
response = await client.image_to_video.with_raw_response.create(
1621-
model="gen4_turbo", prompt_image="https://example.com", extra_headers={"x-stainless-retry-count": Omit()}
1631+
model="gen4_turbo",
1632+
prompt_image="https://example.com",
1633+
ratio="1280:720",
1634+
extra_headers={"x-stainless-retry-count": Omit()},
16221635
)
16231636

16241637
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
@@ -1644,7 +1657,10 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
16441657
respx_mock.post("/v1/image_to_video").mock(side_effect=retry_handler)
16451658

16461659
response = await client.image_to_video.with_raw_response.create(
1647-
model="gen4_turbo", prompt_image="https://example.com", extra_headers={"x-stainless-retry-count": "42"}
1660+
model="gen4_turbo",
1661+
prompt_image="https://example.com",
1662+
ratio="1280:720",
1663+
extra_headers={"x-stainless-retry-count": "42"},
16481664
)
16491665

16501666
assert response.http_request.headers.get("x-stainless-retry-count") == "42"

0 commit comments

Comments
 (0)