Skip to content

Commit ec27134

Browse files
committed
Merge "integration_2025-09-11_1051496969474" into "cen-Python-2020-04-01-online-1537-2025_09_05_16_10_13"
Conflicts: meta.json setup.py volcenginesdkcore/api_client.py volcenginesdkcore/configuration.py
2 parents c8926dd + 94b73e2 commit ec27134

40 files changed

+1894
-23
lines changed

volcenginesdkarkruntime/resources/images/images.py

Lines changed: 178 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,106 @@
1212

1313
from __future__ import annotations
1414

15+
from typing import Optional
16+
from typing_extensions import Literal, overload
17+
1518
import httpx
1619

20+
from ..._types import NOT_GIVEN, NotGiven
1721
from ..._base_client import make_request_options
1822
from ..._utils._utils import apikey_required, async_apikey_required
1923
from ..._resource import SyncAPIResource, AsyncAPIResource
20-
from ...types.images import ImagesResponse
24+
from ...types.images import SequentialImageGenerationOptions, ImagesResponse
25+
from ...types.images.image_gen_stream_event import ImageGenStreamEvent
2126
from ..._types import Body, Query, Headers
27+
from ..._streaming import Stream
2228

2329

2430
class Images(SyncAPIResource):
31+
@overload
32+
def generate(
33+
self,
34+
*,
35+
model: str,
36+
prompt: str,
37+
image: str | list[str] | None = None,
38+
response_format: str | None = None,
39+
size: str | None = None,
40+
seed: int | None = None,
41+
guidance_scale: float | None = None,
42+
watermark: bool | None = None,
43+
optimize_prompt: bool | None = None,
44+
extra_headers: Headers | None = None,
45+
extra_query: Query | None = None,
46+
extra_body: Body | None = None,
47+
timeout: float | httpx.Timeout | None = None,
48+
sequential_image_generation: str | None = None,
49+
sequential_image_generation_options: SequentialImageGenerationOptions | None = None,
50+
stream: Optional[Literal[False]] | NotGiven = NOT_GIVEN,
51+
) -> ImagesResponse:
52+
...
53+
54+
"""
55+
ImageSequenceGeneration:
56+
Controls whether the multi-image feature is enforced
57+
- Enum values:
58+
- auto: Automatic mode; the model decides whether to return multiple images and how many based on the user's prompt
59+
- disabled: Disables multi-image; the model generates only a single image
60+
"""
61+
62+
@overload
63+
def generate(
64+
self,
65+
*,
66+
model: str,
67+
prompt: str,
68+
image: str | list[str] | None = None,
69+
response_format: str | None = None,
70+
size: str | None = None,
71+
seed: int | None = None,
72+
guidance_scale: float | None = None,
73+
watermark: bool | None = None,
74+
optimize_prompt: bool | None = None,
75+
extra_headers: Headers | None = None,
76+
extra_query: Query | None = None,
77+
extra_body: Body | None = None,
78+
timeout: float | httpx.Timeout | None = None,
79+
sequential_image_generation: str | None = None,
80+
sequential_image_generation_options: SequentialImageGenerationOptions | None = None,
81+
stream: Literal[True],
82+
) -> Stream[ImageGenStreamEvent]:
83+
...
84+
85+
@overload
86+
def generate(
87+
self,
88+
*,
89+
model: str,
90+
prompt: str,
91+
image: str | list[str] | None = None,
92+
response_format: str | None = None,
93+
size: str | None = None,
94+
seed: int | None = None,
95+
guidance_scale: float | None = None,
96+
watermark: bool | None = None,
97+
optimize_prompt: bool | None = None,
98+
extra_headers: Headers | None = None,
99+
extra_query: Query | None = None,
100+
extra_body: Body | None = None,
101+
timeout: float | httpx.Timeout | None = None,
102+
sequential_image_generation: str | None = None,
103+
sequential_image_generation_options: SequentialImageGenerationOptions | None = None,
104+
stream: bool,
105+
) -> ImagesResponse | Stream[ImageGenStreamEvent]:
106+
...
107+
25108
@apikey_required
26109
def generate(
27110
self,
28111
*,
29112
model: str,
30113
prompt: str,
31-
image: str | None = None,
114+
image: str | list[str] | None = None,
32115
response_format: str | None = None,
33116
size: str | None = None,
34117
seed: int | None = None,
@@ -39,6 +122,9 @@ def generate(
39122
extra_query: Query | None = None,
40123
extra_body: Body | None = None,
41124
timeout: float | httpx.Timeout | None = None,
125+
sequential_image_generation: str | None = None,
126+
sequential_image_generation_options: SequentialImageGenerationOptions | None = None,
127+
stream: Optional[Literal[False]] | Literal[True] | NotGiven = NOT_GIVEN,
42128
) -> ImagesResponse:
43129
resp = self._post(
44130
"/images/generations",
@@ -52,6 +138,12 @@ def generate(
52138
"guidance_scale": guidance_scale,
53139
"watermark": watermark,
54140
"optimize_prompt": optimize_prompt,
141+
"sequential_image_generation": sequential_image_generation,
142+
"sequential_image_generation_options": (
143+
sequential_image_generation_options.model_dump(mode="json")
144+
if sequential_image_generation_options is not None else None
145+
),
146+
"stream": stream,
55147
},
56148
options=make_request_options(
57149
extra_headers=extra_headers,
@@ -60,19 +152,90 @@ def generate(
60152
timeout=timeout,
61153
),
62154
cast_to=ImagesResponse,
155+
stream=stream or False,
156+
stream_cls=Stream[ImageGenStreamEvent],
63157
)
64158

65159
return resp
66160

67161

68162
class AsyncImages(AsyncAPIResource):
163+
@overload
164+
async def generate(
165+
self,
166+
*,
167+
model: str,
168+
prompt: str,
169+
image: str | list[str] | None = None,
170+
response_format: str | None = None,
171+
size: str | None = None,
172+
seed: int | None = None,
173+
guidance_scale: float | None = None,
174+
watermark: bool | None = None,
175+
optimize_prompt: bool | None = None,
176+
extra_headers: Headers | None = None,
177+
extra_query: Query | None = None,
178+
extra_body: Body | None = None,
179+
timeout: float | httpx.Timeout | None = None,
180+
sequential_image_generation: str | None = None,
181+
sequential_image_generation_options: SequentialImageGenerationOptions | None = None,
182+
stream: Optional[Literal[False]] | NotGiven = NOT_GIVEN,
183+
) -> ImagesResponse:
184+
...
185+
186+
@overload
187+
async def generate(
188+
self,
189+
*,
190+
model: str,
191+
prompt: str,
192+
image: str | list[str] | None = None,
193+
response_format: str | None = None,
194+
size: str | None = None,
195+
seed: int | None = None,
196+
guidance_scale: float | None = None,
197+
watermark: bool | None = None,
198+
optimize_prompt: bool | None = None,
199+
extra_headers: Headers | None = None,
200+
extra_query: Query | None = None,
201+
extra_body: Body | None = None,
202+
timeout: float | httpx.Timeout | None = None,
203+
sequential_image_generation: str | None = None,
204+
sequential_image_generation_options: SequentialImageGenerationOptions | None = None,
205+
stream: Literal[True],
206+
) -> Stream[ImageGenStreamEvent]:
207+
...
208+
209+
@overload
210+
async def generate(
211+
self,
212+
*,
213+
model: str,
214+
prompt: str,
215+
image: str | list[str] | None = None,
216+
response_format: str | None = None,
217+
size: str | None = None,
218+
seed: int | None = None,
219+
guidance_scale: float | None = None,
220+
watermark: bool | None = None,
221+
optimize_prompt: bool | None = None,
222+
extra_headers: Headers | None = None,
223+
extra_query: Query | None = None,
224+
extra_body: Body | None = None,
225+
timeout: float | httpx.Timeout | None = None,
226+
sequential_image_generation: str | None = None,
227+
sequential_image_generation_options: SequentialImageGenerationOptions | None = None,
228+
stream: bool,
229+
) -> ImagesResponse | Stream[ImageGenStreamEvent]:
230+
...
231+
69232
@async_apikey_required
70233
async def generate(
71234
self,
72235
*,
73236
model: str,
74237
prompt: str,
75-
image: str | None = None,
238+
image: str | list[str] | None = None,
76239
response_format: str | None = None,
77240
size: str | None = None,
78241
seed: int | None = None,
@@ -83,7 +246,10 @@ async def generate(
83246
extra_query: Query | None = None,
84247
extra_body: Body | None = None,
85248
timeout: float | httpx.Timeout | None = None,
86-
) -> ImagesResponse:
249+
sequential_image_generation: str | None = None,
250+
sequential_image_generation_options: SequentialImageGenerationOptions | None = None,
251+
stream: Optional[Literal[False]] | Literal[True] | NotGiven = NOT_GIVEN,
252+
) -> ImagesResponse | Stream[ImageGenStreamEvent]:
87253
return await self._post(
88254
"/images/generations",
89255
body={
@@ -96,6 +262,12 @@ async def generate(
96262
"guidance_scale": guidance_scale,
97263
"watermark": watermark,
98264
"optimize_prompt": optimize_prompt,
265+
"sequential_image_generation": sequential_image_generation,
266+
"sequential_image_generation_options": (
267+
sequential_image_generation_options.model_dump(mode="json")
268+
if sequential_image_generation_options is not None else None
269+
),
270+
"stream": stream,
99271
},
100272
options=make_request_options(
101273
extra_headers=extra_headers,
@@ -104,4 +276,6 @@ async def generate(
104276
timeout=timeout,
105277
),
106278
cast_to=ImagesResponse,
279+
stream=stream or False,
280+
stream_cls=Stream[ImageGenStreamEvent],
107281
)

volcenginesdkarkruntime/types/images/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#
1111
# This modified file is released under the same license.
1212

13-
from .images import ImagesResponse
13+
from .images import SequentialImageGenerationOptions, ImagesResponse
1414

15-
__all__ = ["ImagesResponse"]
15+
16+
__all__ = ["SequentialImageGenerationOptions", "ImagesResponse"]
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
# Copyright (c) [2025] [OpenAI]
3+
# Copyright (c) [2025] [ByteDance Ltd. and/or its affiliates.]
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# This file has been modified by [ByteDance Ltd. and/or its affiliates.] on 2025.7
7+
#
8+
# Original file was released under Apache License Version 2.0, with the full license text
9+
# available at https://github.com/openai/openai-python/blob/main/LICENSE.
10+
#
11+
# This modified file is released under the same license.
12+
13+
from typing import List
14+
15+
from volcenginesdkarkruntime._models import BaseModel
16+
17+
__all__ = ["ImageGenCompletedEvent"]
18+
19+
20+
class Usage(BaseModel):
21+
generated_images: int
22+
"""The number of images generated."""
23+
output_tokens: int
24+
"""The number of output tokens."""
25+
total_tokens: int
26+
"""The total number of tokens."""
27+
28+
29+
class Error(BaseModel):
30+
message: str
31+
"""The reason for failed image generation"""
32+
33+
code: str
34+
"""The error code for failed image generation"""
35+
36+
37+
class ImageGenCompletedEvent(BaseModel):
38+
type: str
39+
"""The type of image generating event."""
40+
41+
model: str
42+
"""The model used to generated the images."""
43+
44+
error: Error
45+
"""The error body, if applicable."""
46+
47+
usage: Usage
48+
"""The usage information for the generation of images."""
49+
50+
created_at: int
51+
"""The Unix timestamp when the image was generated."""
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
# Copyright (c) [2025] [OpenAI]
3+
# Copyright (c) [2025] [ByteDance Ltd. and/or its affiliates.]
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# This file has been modified by [ByteDance Ltd. and/or its affiliates.] on 2025.7
7+
#
8+
# Original file was released under Apache License Version 2.0, with the full license text
9+
# available at https://github.com/openai/openai-python/blob/main/LICENSE.
10+
#
11+
# This modified file is released under the same license.
12+
13+
from typing_extensions import Literal
14+
15+
from typing import List
16+
17+
from volcenginesdkarkruntime._models import BaseModel
18+
19+
__all__ = ["ImageGenGeneratingEvent"]
20+
21+
22+
class Error(BaseModel):
23+
message: str
24+
"""The reason for failed image generation"""
25+
26+
code: str
27+
"""The error code for failed image generation"""
28+
29+
30+
class ImageGenGeneratingEvent(BaseModel):
31+
type: str
32+
"""The type of image generating event."""
33+
34+
model: str
35+
"""The model used to generated the images."""
36+
37+
url: str
38+
"""The URL of the generated image, if any."""
39+
40+
b64_json: str
41+
"""The Base 64 encoded string of the generated image, if any."""
42+
43+
size: str
44+
"""The size of the generated image."""
45+
46+
error: Error
47+
"""The error body, if applicable."""
48+
49+
image_index: int
50+
"""The index of the image."""
51+
52+
created_at: int
53+
"""The Unix timestamp when the image was generated."""
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
# Copyright (c) [2025] [OpenAI]
3+
# Copyright (c) [2025] [ByteDance Ltd. and/or its affiliates.]
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# This file has been modified by [ByteDance Ltd. and/or its affiliates.] on 2025.7
7+
#
8+
# Original file was released under Apache License Version 2.0, with the full license text
9+
# available at https://github.com/openai/openai-python/blob/main/LICENSE.
10+
#
11+
# This modified file is released under the same license.
12+
13+
from typing import Union
14+
from typing_extensions import Annotated, TypeAlias
15+
16+
from volcenginesdkarkruntime._utils import PropertyInfo
17+
from .image_gen_completed_event import ImageGenCompletedEvent
18+
from .image_gen_generating_event import ImageGenGeneratingEvent
19+
20+
__all__ = ["ImageGenStreamEvent"]
21+
22+
ImageGenStreamEvent: TypeAlias = Annotated[
23+
Union[ImageGenGeneratingEvent, ImageGenCompletedEvent], PropertyInfo(discriminator="type")
24+
]

0 commit comments

Comments
 (0)