Skip to content

Commit 9dc1d1a

Browse files
feat(api): gpt-image-1.5
1 parent 74b1e6f commit 9dc1d1a

File tree

11 files changed

+298
-260
lines changed

11 files changed

+298
-260
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: 137
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-fe8e67bdc351a518b113ab48e775750190e207807903d6b03ab22c438c38a588.yml
3-
openapi_spec_hash: 8af972190647ffb9dcec516e19d8761a
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-cded37ac004364c2110ebdacf922ef611b3c51258790c72ca479dcfad4df66aa.yml
3+
openapi_spec_hash: 6e615d34cf8c6bc76e0c6933fc8569af
44
config_hash: d013f4fdd4dd59c6f376a9ca482b7f9e

src/openai/resources/images.py

Lines changed: 222 additions & 210 deletions
Large diffs are not rendered by default.

src/openai/types/image.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class Image(BaseModel):
1313
b64_json: Optional[str] = None
1414
"""The base64-encoded JSON of the generated image.
1515
16-
Default value for `gpt-image-1`, and only present if `response_format` is set to
17-
`b64_json` for `dall-e-2` and `dall-e-3`.
16+
Returned by default for the GPT image models, and only present if
17+
`response_format` is set to `b64_json` for `dall-e-2` and `dall-e-3`.
1818
"""
1919

2020
revised_prompt: Optional[str] = None
@@ -23,6 +23,6 @@ class Image(BaseModel):
2323
url: Optional[str] = None
2424
"""
2525
When using `dall-e-2` or `dall-e-3`, the URL of the generated image if
26-
`response_format` is set to `url` (default value). Unsupported for
27-
`gpt-image-1`.
26+
`response_format` is set to `url` (default value). Unsupported for the GPT image
27+
models.
2828
"""

src/openai/types/image_edit_completed_event.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ class UsageInputTokensDetails(BaseModel):
1818

1919

2020
class Usage(BaseModel):
21-
"""For `gpt-image-1` only, the token usage information for the image generation."""
21+
"""
22+
For the GPT image models only, the token usage information for the image generation.
23+
"""
2224

2325
input_tokens: int
2426
"""The number of tokens (images and text) in the input prompt."""
@@ -58,4 +60,7 @@ class ImageEditCompletedEvent(BaseModel):
5860
"""The type of the event. Always `image_edit.completed`."""
5961

6062
usage: Usage
61-
"""For `gpt-image-1` only, the token usage information for the image generation."""
63+
"""
64+
For the GPT image models only, the token usage information for the image
65+
generation.
66+
"""

src/openai/types/image_edit_params.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class ImageEditParamsBase(TypedDict, total=False):
1515
image: Required[Union[FileTypes, SequenceNotStr[FileTypes]]]
1616
"""The image(s) to edit. Must be a supported image file or an array of images.
1717
18-
For `gpt-image-1`, each image should be a `png`, `webp`, or `jpg` file less than
18+
For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, and
19+
`gpt-image-1.5`), each image should be a `png`, `webp`, or `jpg` file less than
1920
50MB. You can provide up to 16 images.
2021
2122
For `dall-e-2`, you can only provide one image, and it should be a square `png`
@@ -26,15 +27,15 @@ class ImageEditParamsBase(TypedDict, total=False):
2627
"""A text description of the desired image(s).
2728
2829
The maximum length is 1000 characters for `dall-e-2`, and 32000 characters for
29-
`gpt-image-1`.
30+
the GPT image models.
3031
"""
3132

3233
background: Optional[Literal["transparent", "opaque", "auto"]]
3334
"""
3435
Allows to set transparency for the background of the generated image(s). This
35-
parameter is only supported for `gpt-image-1`. Must be one of `transparent`,
36-
`opaque` or `auto` (default value). When `auto` is used, the model will
37-
automatically determine the best background for the image.
36+
parameter is only supported for the GPT image models. Must be one of
37+
`transparent`, `opaque` or `auto` (default value). When `auto` is used, the
38+
model will automatically determine the best background for the image.
3839
3940
If `transparent`, the output format needs to support transparency, so it should
4041
be set to either `png` (default value) or `webp`.
@@ -59,8 +60,8 @@ class ImageEditParamsBase(TypedDict, total=False):
5960
model: Union[str, ImageModel, None]
6061
"""The model to use for image generation.
6162
62-
Only `dall-e-2` and `gpt-image-1` are supported. Defaults to `dall-e-2` unless a
63-
parameter specific to `gpt-image-1` is used.
63+
Only `dall-e-2` and the GPT image models are supported. Defaults to `dall-e-2`
64+
unless a parameter specific to the GPT image models is used.
6465
"""
6566

6667
n: Optional[int]
@@ -69,14 +70,14 @@ class ImageEditParamsBase(TypedDict, total=False):
6970
output_compression: Optional[int]
7071
"""The compression level (0-100%) for the generated images.
7172
72-
This parameter is only supported for `gpt-image-1` with the `webp` or `jpeg`
73-
output formats, and defaults to 100.
73+
This parameter is only supported for the GPT image models with the `webp` or
74+
`jpeg` output formats, and defaults to 100.
7475
"""
7576

7677
output_format: Optional[Literal["png", "jpeg", "webp"]]
7778
"""The format in which the generated images are returned.
7879
79-
This parameter is only supported for `gpt-image-1`. Must be one of `png`,
80+
This parameter is only supported for the GPT image models. Must be one of `png`,
8081
`jpeg`, or `webp`. The default value is `png`.
8182
"""
8283

@@ -94,24 +95,24 @@ class ImageEditParamsBase(TypedDict, total=False):
9495
quality: Optional[Literal["standard", "low", "medium", "high", "auto"]]
9596
"""The quality of the image that will be generated.
9697
97-
`high`, `medium` and `low` are only supported for `gpt-image-1`. `dall-e-2` only
98-
supports `standard` quality. Defaults to `auto`.
98+
`high`, `medium` and `low` are only supported for the GPT image models.
99+
`dall-e-2` only supports `standard` quality. Defaults to `auto`.
99100
"""
100101

101102
response_format: Optional[Literal["url", "b64_json"]]
102103
"""The format in which the generated images are returned.
103104
104105
Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the
105106
image has been generated. This parameter is only supported for `dall-e-2`, as
106-
`gpt-image-1` will always return base64-encoded images.
107+
the GPT image models always return base64-encoded images.
107108
"""
108109

109110
size: Optional[Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"]]
110111
"""The size of the generated images.
111112
112113
Must be one of `1024x1024`, `1536x1024` (landscape), `1024x1536` (portrait), or
113-
`auto` (default value) for `gpt-image-1`, and one of `256x256`, `512x512`, or
114-
`1024x1024` for `dall-e-2`.
114+
`auto` (default value) for the GPT image models, and one of `256x256`,
115+
`512x512`, or `1024x1024` for `dall-e-2`.
115116
"""
116117

117118
user: str

src/openai/types/image_gen_completed_event.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ class UsageInputTokensDetails(BaseModel):
1818

1919

2020
class Usage(BaseModel):
21-
"""For `gpt-image-1` only, the token usage information for the image generation."""
21+
"""
22+
For the GPT image models only, the token usage information for the image generation.
23+
"""
2224

2325
input_tokens: int
2426
"""The number of tokens (images and text) in the input prompt."""
@@ -58,4 +60,7 @@ class ImageGenCompletedEvent(BaseModel):
5860
"""The type of the event. Always `image_generation.completed`."""
5961

6062
usage: Usage
61-
"""For `gpt-image-1` only, the token usage information for the image generation."""
63+
"""
64+
For the GPT image models only, the token usage information for the image
65+
generation.
66+
"""

src/openai/types/image_generate_params.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ class ImageGenerateParamsBase(TypedDict, total=False):
1414
prompt: Required[str]
1515
"""A text description of the desired image(s).
1616
17-
The maximum length is 32000 characters for `gpt-image-1`, 1000 characters for
18-
`dall-e-2` and 4000 characters for `dall-e-3`.
17+
The maximum length is 32000 characters for the GPT image models, 1000 characters
18+
for `dall-e-2` and 4000 characters for `dall-e-3`.
1919
"""
2020

2121
background: Optional[Literal["transparent", "opaque", "auto"]]
2222
"""
2323
Allows to set transparency for the background of the generated image(s). This
24-
parameter is only supported for `gpt-image-1`. Must be one of `transparent`,
25-
`opaque` or `auto` (default value). When `auto` is used, the model will
26-
automatically determine the best background for the image.
24+
parameter is only supported for the GPT image models. Must be one of
25+
`transparent`, `opaque` or `auto` (default value). When `auto` is used, the
26+
model will automatically determine the best background for the image.
2727
2828
If `transparent`, the output format needs to support transparency, so it should
2929
be set to either `png` (default value) or `webp`.
@@ -32,14 +32,16 @@ class ImageGenerateParamsBase(TypedDict, total=False):
3232
model: Union[str, ImageModel, None]
3333
"""The model to use for image generation.
3434
35-
One of `dall-e-2`, `dall-e-3`, or `gpt-image-1`. Defaults to `dall-e-2` unless a
36-
parameter specific to `gpt-image-1` is used.
35+
One of `dall-e-2`, `dall-e-3`, or a GPT image model (`gpt-image-1`,
36+
`gpt-image-1-mini`, `gpt-image-1.5`). Defaults to `dall-e-2` unless a parameter
37+
specific to the GPT image models is used.
3738
"""
3839

3940
moderation: Optional[Literal["low", "auto"]]
40-
"""Control the content-moderation level for images generated by `gpt-image-1`.
41-
42-
Must be either `low` for less restrictive filtering or `auto` (default value).
41+
"""
42+
Control the content-moderation level for images generated by the GPT image
43+
models. Must be either `low` for less restrictive filtering or `auto` (default
44+
value).
4345
"""
4446

4547
n: Optional[int]
@@ -51,14 +53,14 @@ class ImageGenerateParamsBase(TypedDict, total=False):
5153
output_compression: Optional[int]
5254
"""The compression level (0-100%) for the generated images.
5355
54-
This parameter is only supported for `gpt-image-1` with the `webp` or `jpeg`
55-
output formats, and defaults to 100.
56+
This parameter is only supported for the GPT image models with the `webp` or
57+
`jpeg` output formats, and defaults to 100.
5658
"""
5759

5860
output_format: Optional[Literal["png", "jpeg", "webp"]]
5961
"""The format in which the generated images are returned.
6062
61-
This parameter is only supported for `gpt-image-1`. Must be one of `png`,
63+
This parameter is only supported for the GPT image models. Must be one of `png`,
6264
`jpeg`, or `webp`.
6365
"""
6466

@@ -78,7 +80,7 @@ class ImageGenerateParamsBase(TypedDict, total=False):
7880
7981
- `auto` (default value) will automatically select the best quality for the
8082
given model.
81-
- `high`, `medium` and `low` are supported for `gpt-image-1`.
83+
- `high`, `medium` and `low` are supported for the GPT image models.
8284
- `hd` and `standard` are supported for `dall-e-3`.
8385
- `standard` is the only option for `dall-e-2`.
8486
"""
@@ -88,8 +90,8 @@ class ImageGenerateParamsBase(TypedDict, total=False):
8890
returned.
8991
9092
Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the
91-
image has been generated. This parameter isn't supported for `gpt-image-1` which
92-
will always return base64-encoded images.
93+
image has been generated. This parameter isn't supported for the GPT image
94+
models, which always return base64-encoded images.
9395
"""
9496

9597
size: Optional[
@@ -98,7 +100,7 @@ class ImageGenerateParamsBase(TypedDict, total=False):
98100
"""The size of the generated images.
99101
100102
Must be one of `1024x1024`, `1536x1024` (landscape), `1024x1536` (portrait), or
101-
`auto` (default value) for `gpt-image-1`, one of `256x256`, `512x512`, or
103+
`auto` (default value) for the GPT image models, one of `256x256`, `512x512`, or
102104
`1024x1024` for `dall-e-2`, and one of `1024x1024`, `1792x1024`, or `1024x1792`
103105
for `dall-e-3`.
104106
"""
@@ -126,7 +128,7 @@ class ImageGenerateParamsNonStreaming(ImageGenerateParamsBase, total=False):
126128
127129
Defaults to `false`. See the
128130
[Image generation guide](https://platform.openai.com/docs/guides/image-generation)
129-
for more information. This parameter is only supported for `gpt-image-1`.
131+
for more information. This parameter is only supported for the GPT image models.
130132
"""
131133

132134

@@ -136,7 +138,7 @@ class ImageGenerateParamsStreaming(ImageGenerateParamsBase):
136138
137139
Defaults to `false`. See the
138140
[Image generation guide](https://platform.openai.com/docs/guides/image-generation)
139-
for more information. This parameter is only supported for `gpt-image-1`.
141+
for more information. This parameter is only supported for the GPT image models.
140142
"""
141143

142144

src/openai/types/image_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
__all__ = ["ImageModel"]
66

7-
ImageModel: TypeAlias = Literal["dall-e-2", "dall-e-3", "gpt-image-1", "gpt-image-1-mini"]
7+
ImageModel: TypeAlias = Literal["gpt-image-1.5", "dall-e-2", "dall-e-3", "gpt-image-1", "gpt-image-1-mini"]

src/openai/types/images_response.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from .image import Image
77
from .._models import BaseModel
88

9-
__all__ = ["ImagesResponse", "Usage", "UsageInputTokensDetails"]
9+
__all__ = ["ImagesResponse", "Usage", "UsageInputTokensDetails", "UsageOutputTokensDetails"]
1010

1111

1212
class UsageInputTokensDetails(BaseModel):
@@ -19,6 +19,16 @@ class UsageInputTokensDetails(BaseModel):
1919
"""The number of text tokens in the input prompt."""
2020

2121

22+
class UsageOutputTokensDetails(BaseModel):
23+
"""The output token details for the image generation."""
24+
25+
image_tokens: int
26+
"""The number of image output tokens generated by the model."""
27+
28+
text_tokens: int
29+
"""The number of text output tokens generated by the model."""
30+
31+
2232
class Usage(BaseModel):
2333
"""For `gpt-image-1` only, the token usage information for the image generation."""
2434

@@ -34,6 +44,9 @@ class Usage(BaseModel):
3444
total_tokens: int
3545
"""The total number of tokens (images and text) used for the image generation."""
3646

47+
output_tokens_details: Optional[UsageOutputTokensDetails] = None
48+
"""The output token details for the image generation."""
49+
3750

3851
class ImagesResponse(BaseModel):
3952
"""The response from the image generation endpoint."""

src/openai/types/responses/tool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class ImageGenerationInputImageMask(BaseModel):
221221

222222

223223
class ImageGeneration(BaseModel):
224-
"""A tool that generates images using a model like `gpt-image-1`."""
224+
"""A tool that generates images using the GPT image models."""
225225

226226
type: Literal["image_generation"]
227227
"""The type of the image generation tool. Always `image_generation`."""
@@ -246,7 +246,7 @@ class ImageGeneration(BaseModel):
246246
Contains `image_url` (string, optional) and `file_id` (string, optional).
247247
"""
248248

249-
model: Optional[Literal["gpt-image-1", "gpt-image-1-mini"]] = None
249+
model: Union[str, Literal["gpt-image-1", "gpt-image-1-mini"], None] = None
250250
"""The image generation model to use. Default: `gpt-image-1`."""
251251

252252
moderation: Optional[Literal["auto", "low"]] = None

0 commit comments

Comments
 (0)