Skip to content

Commit b244b09

Browse files
feat(api): manual updates
merge sora api changes
1 parent d806635 commit b244b09

6 files changed

Lines changed: 67 additions & 73 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 152
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-4e24269912b73a40b8af1ab2a59f99069b1f8cce2ff6ff342f2ad8644e94531e.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-8de5b14ece687aac55187d923c8dca4b8c4a4dbaaa38bb1bcfffc975d441aca8.yml
33
openapi_spec_hash: 626982004d5a594a822fa7883422efb4
4-
config_hash: 5e5cd24c6e3b2585b61b8fa0af24ade7
4+
config_hash: 8421b0e4dae127df4dcc071c1aa5ea1a

src/openai/resources/videos/videos.py

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ def create(
9595
Args:
9696
prompt: Text prompt that describes the video to generate.
9797
98-
input_reference: Optional reference object that guides generation. Provide exactly one of
99-
`image_url` or `file_id`.
98+
input_reference: Optional reference asset upload or reference object that guides generation.
10099
101100
model: The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults
102101
to `sora-2`.
@@ -124,11 +123,10 @@ def create(
124123
}
125124
)
126125
files = extract_files(cast(Mapping[str, object], body), paths=[["input_reference"]])
127-
if files:
128-
# It should be noted that the actual Content-Type header that will be
129-
# sent to the server will contain a `boundary` parameter, e.g.
130-
# multipart/form-data; boundary=---abc--
131-
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
126+
# It should be noted that the actual Content-Type header that will be
127+
# sent to the server will contain a `boundary` parameter, e.g.
128+
# multipart/form-data; boundary=---abc--
129+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
132130
return self._post(
133131
"/videos",
134132
body=maybe_transform(body, video_create_params.VideoCreateParams),
@@ -409,11 +407,10 @@ def edit(
409407
}
410408
)
411409
files = extract_files(cast(Mapping[str, object], body), paths=[["video"]])
412-
if files:
413-
# It should be noted that the actual Content-Type header that will be
414-
# sent to the server will contain a `boundary` parameter, e.g.
415-
# multipart/form-data; boundary=---abc--
416-
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
410+
# It should be noted that the actual Content-Type header that will be
411+
# sent to the server will contain a `boundary` parameter, e.g.
412+
# multipart/form-data; boundary=---abc--
413+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
417414
return self._post(
418415
"/videos/edits",
419416
body=maybe_transform(body, video_edit_params.VideoEditParams),
@@ -446,7 +443,7 @@ def extend(
446443
seconds: Length of the newly generated extension segment in seconds (allowed values: 4,
447444
8, 12, 16, 20).
448445
449-
video: Reference to the completed video to extend.
446+
video: Reference to the completed video.
450447
451448
extra_headers: Send extra headers
452449
@@ -464,11 +461,10 @@ def extend(
464461
}
465462
)
466463
files = extract_files(cast(Mapping[str, object], body), paths=[["video"]])
467-
if files:
468-
# It should be noted that the actual Content-Type header that will be
469-
# sent to the server will contain a `boundary` parameter, e.g.
470-
# multipart/form-data; boundary=---abc--
471-
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
464+
# It should be noted that the actual Content-Type header that will be
465+
# sent to the server will contain a `boundary` parameter, e.g.
466+
# multipart/form-data; boundary=---abc--
467+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
472468
return self._post(
473469
"/videos/extensions",
474470
body=maybe_transform(body, video_extend_params.VideoExtendParams),
@@ -562,8 +558,7 @@ async def create(
562558
Args:
563559
prompt: Text prompt that describes the video to generate.
564560
565-
input_reference: Optional reference object that guides generation. Provide exactly one of
566-
`image_url` or `file_id`.
561+
input_reference: Optional reference asset upload or reference object that guides generation.
567562
568563
model: The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults
569564
to `sora-2`.
@@ -591,11 +586,10 @@ async def create(
591586
}
592587
)
593588
files = extract_files(cast(Mapping[str, object], body), paths=[["input_reference"]])
594-
if files:
595-
# It should be noted that the actual Content-Type header that will be
596-
# sent to the server will contain a `boundary` parameter, e.g.
597-
# multipart/form-data; boundary=---abc--
598-
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
589+
# It should be noted that the actual Content-Type header that will be
590+
# sent to the server will contain a `boundary` parameter, e.g.
591+
# multipart/form-data; boundary=---abc--
592+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
599593
return await self._post(
600594
"/videos",
601595
body=await async_maybe_transform(body, video_create_params.VideoCreateParams),
@@ -878,11 +872,10 @@ async def edit(
878872
}
879873
)
880874
files = extract_files(cast(Mapping[str, object], body), paths=[["video"]])
881-
if files:
882-
# It should be noted that the actual Content-Type header that will be
883-
# sent to the server will contain a `boundary` parameter, e.g.
884-
# multipart/form-data; boundary=---abc--
885-
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
875+
# It should be noted that the actual Content-Type header that will be
876+
# sent to the server will contain a `boundary` parameter, e.g.
877+
# multipart/form-data; boundary=---abc--
878+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
886879
return await self._post(
887880
"/videos/edits",
888881
body=await async_maybe_transform(body, video_edit_params.VideoEditParams),
@@ -915,7 +908,7 @@ async def extend(
915908
seconds: Length of the newly generated extension segment in seconds (allowed values: 4,
916909
8, 12, 16, 20).
917910
918-
video: Reference to the completed video to extend.
911+
video: Reference to the completed video.
919912
920913
extra_headers: Send extra headers
921914
@@ -933,11 +926,10 @@ async def extend(
933926
}
934927
)
935928
files = extract_files(cast(Mapping[str, object], body), paths=[["video"]])
936-
if files:
937-
# It should be noted that the actual Content-Type header that will be
938-
# sent to the server will contain a `boundary` parameter, e.g.
939-
# multipart/form-data; boundary=---abc--
940-
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
929+
# It should be noted that the actual Content-Type header that will be
930+
# sent to the server will contain a `boundary` parameter, e.g.
931+
# multipart/form-data; boundary=---abc--
932+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
941933
return await self._post(
942934
"/videos/extensions",
943935
body=await async_maybe_transform(body, video_extend_params.VideoExtendParams),

src/openai/types/video_create_params.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,23 @@
22

33
from __future__ import annotations
44

5-
from typing_extensions import Required, TypedDict
5+
from typing import Union
6+
from typing_extensions import Required, TypeAlias, TypedDict
67

8+
from .._types import FileTypes
79
from .video_size import VideoSize
810
from .video_seconds import VideoSeconds
911
from .video_model_param import VideoModelParam
1012

11-
__all__ = ["VideoCreateParams", "InputReference"]
13+
__all__ = ["VideoCreateParams", "InputReference", "InputReferenceImageRefParam2"]
1214

1315

1416
class VideoCreateParams(TypedDict, total=False):
1517
prompt: Required[str]
1618
"""Text prompt that describes the video to generate."""
1719

1820
input_reference: InputReference
19-
"""Optional reference object that guides generation.
20-
21-
Provide exactly one of `image_url` or `file_id`.
22-
"""
21+
"""Optional reference asset upload or reference object that guides generation."""
2322

2423
model: VideoModelParam
2524
"""The video generation model to use (allowed values: sora-2, sora-2-pro).
@@ -37,13 +36,11 @@ class VideoCreateParams(TypedDict, total=False):
3736
"""
3837

3938

40-
class InputReference(TypedDict, total=False):
41-
"""Optional reference object that guides generation.
42-
43-
Provide exactly one of `image_url` or `file_id`.
44-
"""
45-
39+
class InputReferenceImageRefParam2(TypedDict, total=False):
4640
file_id: str
4741

4842
image_url: str
4943
"""A fully qualified URL or base64-encoded data URL."""
44+
45+
46+
InputReference: TypeAlias = Union[FileTypes, InputReferenceImageRefParam2]

src/openai/types/video_edit_params.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
from __future__ import annotations
44

5-
from typing_extensions import Required, TypedDict
5+
from typing import Union
6+
from typing_extensions import Required, TypeAlias, TypedDict
67

7-
__all__ = ["VideoEditParams", "Video"]
8+
from .._types import FileTypes
9+
10+
__all__ = ["VideoEditParams", "Video", "VideoVideoReferenceInputParam"]
811

912

1013
class VideoEditParams(TypedDict, total=False):
@@ -15,8 +18,11 @@ class VideoEditParams(TypedDict, total=False):
1518
"""Reference to the completed video to edit."""
1619

1720

18-
class Video(TypedDict, total=False):
19-
"""Reference to the completed video to edit."""
21+
class VideoVideoReferenceInputParam(TypedDict, total=False):
22+
"""Reference to the completed video."""
2023

2124
id: Required[str]
2225
"""The identifier of the completed video."""
26+
27+
28+
Video: TypeAlias = Union[FileTypes, VideoVideoReferenceInputParam]

src/openai/types/video_extend_params.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
from __future__ import annotations
44

5-
from typing_extensions import Required, TypedDict
5+
from typing import Union
6+
from typing_extensions import Required, TypeAlias, TypedDict
67

8+
from .._types import FileTypes
79
from .video_seconds import VideoSeconds
810

9-
__all__ = ["VideoExtendParams", "Video"]
11+
__all__ = ["VideoExtendParams", "Video", "VideoVideoReferenceInputParam"]
1012

1113

1214
class VideoExtendParams(TypedDict, total=False):
@@ -20,11 +22,14 @@ class VideoExtendParams(TypedDict, total=False):
2022
"""
2123

2224
video: Required[Video]
23-
"""Reference to the completed video to extend."""
25+
"""Reference to the completed video."""
2426

2527

26-
class Video(TypedDict, total=False):
27-
"""Reference to the completed video to extend."""
28+
class VideoVideoReferenceInputParam(TypedDict, total=False):
29+
"""Reference to the completed video."""
2830

2931
id: Required[str]
3032
"""The identifier of the completed video."""
33+
34+
35+
Video: TypeAlias = Union[VideoVideoReferenceInputParam, FileTypes]

tests/api_resources/test_videos.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ def test_method_create(self, client: OpenAI) -> None:
3838
def test_method_create_with_all_params(self, client: OpenAI) -> None:
3939
video = client.videos.create(
4040
prompt="x",
41-
input_reference={
42-
"file_id": "file-123",
43-
"image_url": "image_url",
44-
},
41+
input_reference=b"Example data",
4542
model="string",
4643
seconds="4",
4744
size="720x1280",
@@ -244,15 +241,15 @@ def test_path_params_download_content(self, client: OpenAI) -> None:
244241
def test_method_edit(self, client: OpenAI) -> None:
245242
video = client.videos.edit(
246243
prompt="x",
247-
video={"id": "video_123"},
244+
video=b"Example data",
248245
)
249246
assert_matches_type(Video, video, path=["response"])
250247

251248
@parametrize
252249
def test_raw_response_edit(self, client: OpenAI) -> None:
253250
response = client.videos.with_raw_response.edit(
254251
prompt="x",
255-
video={"id": "video_123"},
252+
video=b"Example data",
256253
)
257254

258255
assert response.is_closed is True
@@ -264,7 +261,7 @@ def test_raw_response_edit(self, client: OpenAI) -> None:
264261
def test_streaming_response_edit(self, client: OpenAI) -> None:
265262
with client.videos.with_streaming_response.edit(
266263
prompt="x",
267-
video={"id": "video_123"},
264+
video=b"Example data",
268265
) as response:
269266
assert not response.is_closed
270267
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -370,10 +367,7 @@ async def test_method_create(self, async_client: AsyncOpenAI) -> None:
370367
async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) -> None:
371368
video = await async_client.videos.create(
372369
prompt="x",
373-
input_reference={
374-
"file_id": "file-123",
375-
"image_url": "image_url",
376-
},
370+
input_reference=b"Example data",
377371
model="string",
378372
seconds="4",
379373
size="720x1280",
@@ -578,15 +572,15 @@ async def test_path_params_download_content(self, async_client: AsyncOpenAI) ->
578572
async def test_method_edit(self, async_client: AsyncOpenAI) -> None:
579573
video = await async_client.videos.edit(
580574
prompt="x",
581-
video={"id": "video_123"},
575+
video=b"Example data",
582576
)
583577
assert_matches_type(Video, video, path=["response"])
584578

585579
@parametrize
586580
async def test_raw_response_edit(self, async_client: AsyncOpenAI) -> None:
587581
response = await async_client.videos.with_raw_response.edit(
588582
prompt="x",
589-
video={"id": "video_123"},
583+
video=b"Example data",
590584
)
591585

592586
assert response.is_closed is True
@@ -598,7 +592,7 @@ async def test_raw_response_edit(self, async_client: AsyncOpenAI) -> None:
598592
async def test_streaming_response_edit(self, async_client: AsyncOpenAI) -> None:
599593
async with async_client.videos.with_streaming_response.edit(
600594
prompt="x",
601-
video={"id": "video_123"},
595+
video=b"Example data",
602596
) as response:
603597
assert not response.is_closed
604598
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

0 commit comments

Comments
 (0)