Skip to content

Commit 473469a

Browse files
feat(api): add image sizes, reasoning encryption
1 parent 8467d66 commit 473469a

26 files changed

+182
-86
lines changed

.stats.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 97
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-8b68ae6b807dca92e914da1dd9e835a20f69b075e79102a264367fd7fddddb33.yml
3-
openapi_spec_hash: b6ade5b1a6327339e6669e1134de2d03
4-
config_hash: b597cd9a31e9e5ec709e2eefb4c54122
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-0ee6b36cf3cc278cef4199a6aec5f7d530a6c1f17a74830037e96d50ca1edc50.yml
3+
openapi_spec_hash: e8ec5f46bc0655b34f292422d58a60f6
4+
config_hash: d9b6b6e6bc85744663e300eebc482067

src/openai/resources/audio/speech.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def create(
8585
`wav`, and `pcm`.
8686
8787
speed: The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is
88-
the default.
88+
the default. Does not work with `gpt-4o-mini-tts`.
8989
9090
extra_headers: Send extra headers
9191
@@ -176,7 +176,7 @@ async def create(
176176
`wav`, and `pcm`.
177177
178178
speed: The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is
179-
the default.
179+
the default. Does not work with `gpt-4o-mini-tts`.
180180
181181
extra_headers: Send extra headers
182182

src/openai/resources/images.py

+38-10
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,14 @@ def edit(
119119
*,
120120
image: Union[FileTypes, List[FileTypes]],
121121
prompt: str,
122+
background: Optional[Literal["transparent", "opaque", "auto"]] | NotGiven = NOT_GIVEN,
122123
mask: FileTypes | NotGiven = NOT_GIVEN,
123124
model: Union[str, ImageModel, None] | NotGiven = NOT_GIVEN,
124125
n: Optional[int] | NotGiven = NOT_GIVEN,
125126
quality: Optional[Literal["standard", "low", "medium", "high", "auto"]] | NotGiven = NOT_GIVEN,
126127
response_format: Optional[Literal["url", "b64_json"]] | NotGiven = NOT_GIVEN,
127-
size: Optional[Literal["256x256", "512x512", "1024x1024"]] | NotGiven = NOT_GIVEN,
128+
size: Optional[Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"]]
129+
| NotGiven = NOT_GIVEN,
128130
user: str | NotGiven = NOT_GIVEN,
129131
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
130132
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -139,14 +141,25 @@ def edit(
139141
This endpoint only supports `gpt-image-1` and `dall-e-2`.
140142
141143
Args:
142-
image: The image(s) to edit. Must be a supported image file or an array of images. For
143-
`gpt-image-1`, each image should be a `png`, `webp`, or `jpg` file less than
144-
25MB. For `dall-e-2`, you can only provide one image, and it should be a square
145-
`png` file less than 4MB.
144+
image: The image(s) to edit. Must be a supported image file or an array of images.
145+
146+
For `gpt-image-1`, each image should be a `png`, `webp`, or `jpg` file less than
147+
25MB. You can provide up to 16 images.
148+
149+
For `dall-e-2`, you can only provide one image, and it should be a square `png`
150+
file less than 4MB.
146151
147152
prompt: A text description of the desired image(s). The maximum length is 1000
148153
characters for `dall-e-2`, and 32000 characters for `gpt-image-1`.
149154
155+
background: Allows to set transparency for the background of the generated image(s). This
156+
parameter is only supported for `gpt-image-1`. Must be one of `transparent`,
157+
`opaque` or `auto` (default value). When `auto` is used, the model will
158+
automatically determine the best background for the image.
159+
160+
If `transparent`, the output format needs to support transparency, so it should
161+
be set to either `png` (default value) or `webp`.
162+
150163
mask: An additional image whose fully transparent areas (e.g. where alpha is zero)
151164
indicate where `image` should be edited. If there are multiple images provided,
152165
the mask will be applied on the first image. Must be a valid PNG file, less than
@@ -187,6 +200,7 @@ def edit(
187200
{
188201
"image": image,
189202
"prompt": prompt,
203+
"background": background,
190204
"mask": mask,
191205
"model": model,
192206
"n": n,
@@ -429,12 +443,14 @@ async def edit(
429443
*,
430444
image: Union[FileTypes, List[FileTypes]],
431445
prompt: str,
446+
background: Optional[Literal["transparent", "opaque", "auto"]] | NotGiven = NOT_GIVEN,
432447
mask: FileTypes | NotGiven = NOT_GIVEN,
433448
model: Union[str, ImageModel, None] | NotGiven = NOT_GIVEN,
434449
n: Optional[int] | NotGiven = NOT_GIVEN,
435450
quality: Optional[Literal["standard", "low", "medium", "high", "auto"]] | NotGiven = NOT_GIVEN,
436451
response_format: Optional[Literal["url", "b64_json"]] | NotGiven = NOT_GIVEN,
437-
size: Optional[Literal["256x256", "512x512", "1024x1024"]] | NotGiven = NOT_GIVEN,
452+
size: Optional[Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"]]
453+
| NotGiven = NOT_GIVEN,
438454
user: str | NotGiven = NOT_GIVEN,
439455
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
440456
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -449,14 +465,25 @@ async def edit(
449465
This endpoint only supports `gpt-image-1` and `dall-e-2`.
450466
451467
Args:
452-
image: The image(s) to edit. Must be a supported image file or an array of images. For
453-
`gpt-image-1`, each image should be a `png`, `webp`, or `jpg` file less than
454-
25MB. For `dall-e-2`, you can only provide one image, and it should be a square
455-
`png` file less than 4MB.
468+
image: The image(s) to edit. Must be a supported image file or an array of images.
469+
470+
For `gpt-image-1`, each image should be a `png`, `webp`, or `jpg` file less than
471+
25MB. You can provide up to 16 images.
472+
473+
For `dall-e-2`, you can only provide one image, and it should be a square `png`
474+
file less than 4MB.
456475
457476
prompt: A text description of the desired image(s). The maximum length is 1000
458477
characters for `dall-e-2`, and 32000 characters for `gpt-image-1`.
459478
479+
background: Allows to set transparency for the background of the generated image(s). This
480+
parameter is only supported for `gpt-image-1`. Must be one of `transparent`,
481+
`opaque` or `auto` (default value). When `auto` is used, the model will
482+
automatically determine the best background for the image.
483+
484+
If `transparent`, the output format needs to support transparency, so it should
485+
be set to either `png` (default value) or `webp`.
486+
460487
mask: An additional image whose fully transparent areas (e.g. where alpha is zero)
461488
indicate where `image` should be edited. If there are multiple images provided,
462489
the mask will be applied on the first image. Must be a valid PNG file, less than
@@ -497,6 +524,7 @@ async def edit(
497524
{
498525
"image": image,
499526
"prompt": prompt,
527+
"background": background,
500528
"mask": mask,
501529
"model": model,
502530
"n": n,

src/openai/resources/responses/responses.py

+30
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ def create(
140140
- `message.input_image.image_url`: Include image urls from the input message.
141141
- `computer_call_output.output.image_url`: Include image urls from the computer
142142
call output.
143+
- `reasoning.encrypted_content`: Includes an encrypted version of reasoning
144+
tokens in reasoning item outputs. This enables reasoning items to be used in
145+
multi-turn conversations when using the Responses API statelessly (like when
146+
the `store` parameter is set to `false`, or when an organization is enrolled
147+
in the zero data retention program).
143148
144149
instructions: Inserts a system (or developer) message as the first item in the model's
145150
context.
@@ -331,6 +336,11 @@ def create(
331336
- `message.input_image.image_url`: Include image urls from the input message.
332337
- `computer_call_output.output.image_url`: Include image urls from the computer
333338
call output.
339+
- `reasoning.encrypted_content`: Includes an encrypted version of reasoning
340+
tokens in reasoning item outputs. This enables reasoning items to be used in
341+
multi-turn conversations when using the Responses API statelessly (like when
342+
the `store` parameter is set to `false`, or when an organization is enrolled
343+
in the zero data retention program).
334344
335345
instructions: Inserts a system (or developer) message as the first item in the model's
336346
context.
@@ -515,6 +525,11 @@ def create(
515525
- `message.input_image.image_url`: Include image urls from the input message.
516526
- `computer_call_output.output.image_url`: Include image urls from the computer
517527
call output.
528+
- `reasoning.encrypted_content`: Includes an encrypted version of reasoning
529+
tokens in reasoning item outputs. This enables reasoning items to be used in
530+
multi-turn conversations when using the Responses API statelessly (like when
531+
the `store` parameter is set to `false`, or when an organization is enrolled
532+
in the zero data retention program).
518533
519534
instructions: Inserts a system (or developer) message as the first item in the model's
520535
context.
@@ -1013,6 +1028,11 @@ async def create(
10131028
- `message.input_image.image_url`: Include image urls from the input message.
10141029
- `computer_call_output.output.image_url`: Include image urls from the computer
10151030
call output.
1031+
- `reasoning.encrypted_content`: Includes an encrypted version of reasoning
1032+
tokens in reasoning item outputs. This enables reasoning items to be used in
1033+
multi-turn conversations when using the Responses API statelessly (like when
1034+
the `store` parameter is set to `false`, or when an organization is enrolled
1035+
in the zero data retention program).
10161036
10171037
instructions: Inserts a system (or developer) message as the first item in the model's
10181038
context.
@@ -1204,6 +1224,11 @@ async def create(
12041224
- `message.input_image.image_url`: Include image urls from the input message.
12051225
- `computer_call_output.output.image_url`: Include image urls from the computer
12061226
call output.
1227+
- `reasoning.encrypted_content`: Includes an encrypted version of reasoning
1228+
tokens in reasoning item outputs. This enables reasoning items to be used in
1229+
multi-turn conversations when using the Responses API statelessly (like when
1230+
the `store` parameter is set to `false`, or when an organization is enrolled
1231+
in the zero data retention program).
12071232
12081233
instructions: Inserts a system (or developer) message as the first item in the model's
12091234
context.
@@ -1388,6 +1413,11 @@ async def create(
13881413
- `message.input_image.image_url`: Include image urls from the input message.
13891414
- `computer_call_output.output.image_url`: Include image urls from the computer
13901415
call output.
1416+
- `reasoning.encrypted_content`: Includes an encrypted version of reasoning
1417+
tokens in reasoning item outputs. This enables reasoning items to be used in
1418+
multi-turn conversations when using the Responses API statelessly (like when
1419+
the `store` parameter is set to `false`, or when an organization is enrolled
1420+
in the zero data retention program).
13911421
13921422
instructions: Inserts a system (or developer) message as the first item in the model's
13931423
context.

src/openai/types/audio/speech_create_params.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@ class SpeechCreateParams(TypedDict, total=False):
4848
speed: float
4949
"""The speed of the generated audio.
5050
51-
Select a value from `0.25` to `4.0`. `1.0` is the default.
51+
Select a value from `0.25` to `4.0`. `1.0` is the default. Does not work with
52+
`gpt-4o-mini-tts`.
5253
"""

src/openai/types/image_edit_params.py

+18-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313

1414
class ImageEditParams(TypedDict, total=False):
1515
image: Required[Union[FileTypes, List[FileTypes]]]
16-
"""The image(s) to edit.
16+
"""The image(s) to edit. Must be a supported image file or an array of images.
1717
18-
Must be a supported image file or an array of images. For `gpt-image-1`, each
19-
image should be a `png`, `webp`, or `jpg` file less than 25MB. For `dall-e-2`,
20-
you can only provide one image, and it should be a square `png` file less than
21-
4MB.
18+
For `gpt-image-1`, each image should be a `png`, `webp`, or `jpg` file less than
19+
25MB. You can provide up to 16 images.
20+
21+
For `dall-e-2`, you can only provide one image, and it should be a square `png`
22+
file less than 4MB.
2223
"""
2324

2425
prompt: Required[str]
@@ -28,6 +29,17 @@ class ImageEditParams(TypedDict, total=False):
2829
`gpt-image-1`.
2930
"""
3031

32+
background: Optional[Literal["transparent", "opaque", "auto"]]
33+
"""Allows to set transparency for the background of the generated image(s).
34+
35+
This parameter is only supported for `gpt-image-1`. Must be one of
36+
`transparent`, `opaque` or `auto` (default value). When `auto` is used, the
37+
model will automatically determine the best background for the image.
38+
39+
If `transparent`, the output format needs to support transparency, so it should
40+
be set to either `png` (default value) or `webp`.
41+
"""
42+
3143
mask: FileTypes
3244
"""An additional image whose fully transparent areas (e.g.
3345
@@ -61,7 +73,7 @@ class ImageEditParams(TypedDict, total=False):
6173
`gpt-image-1` will always return base64-encoded images.
6274
"""
6375

64-
size: Optional[Literal["256x256", "512x512", "1024x1024"]]
76+
size: Optional[Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"]]
6577
"""The size of the generated images.
6678
6779
Must be one of `1024x1024`, `1536x1024` (landscape), `1024x1536` (portrait), or

src/openai/types/responses/computer_tool.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99

1010
class ComputerTool(BaseModel):
11-
display_height: float
11+
display_height: int
1212
"""The height of the computer display."""
1313

14-
display_width: float
14+
display_width: int
1515
"""The width of the computer display."""
1616

17-
environment: Literal["mac", "windows", "ubuntu", "browser"]
17+
environment: Literal["windows", "mac", "linux", "ubuntu", "browser"]
1818
"""The type of computer environment to control."""
1919

2020
type: Literal["computer_use_preview"]

src/openai/types/responses/computer_tool_param.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99

1010
class ComputerToolParam(TypedDict, total=False):
11-
display_height: Required[float]
11+
display_height: Required[int]
1212
"""The height of the computer display."""
1313

14-
display_width: Required[float]
14+
display_width: Required[int]
1515
"""The width of the computer display."""
1616

17-
environment: Required[Literal["mac", "windows", "ubuntu", "browser"]]
17+
environment: Required[Literal["windows", "mac", "linux", "ubuntu", "browser"]]
1818
"""The type of computer environment to control."""
1919

2020
type: Required[Literal["computer_use_preview"]]

src/openai/types/responses/file_search_tool.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@
99

1010
__all__ = ["FileSearchTool", "Filters", "RankingOptions"]
1111

12-
Filters: TypeAlias = Union[ComparisonFilter, CompoundFilter]
12+
Filters: TypeAlias = Union[ComparisonFilter, CompoundFilter, None]
1313

1414

1515
class RankingOptions(BaseModel):
1616
ranker: Optional[Literal["auto", "default-2024-11-15"]] = None
1717
"""The ranker to use for the file search."""
1818

1919
score_threshold: Optional[float] = None
20-
"""
21-
The score threshold for the file search, a number between 0 and 1. Numbers
22-
closer to 1 will attempt to return only the most relevant results, but may
23-
return fewer results.
20+
"""The score threshold for the file search, a number between 0 and 1.
21+
22+
Numbers closer to 1 will attempt to return only the most relevant results, but
23+
may return fewer results.
2424
"""
2525

2626

@@ -32,7 +32,7 @@ class FileSearchTool(BaseModel):
3232
"""The IDs of the vector stores to search."""
3333

3434
filters: Optional[Filters] = None
35-
"""A filter to apply based on file attributes."""
35+
"""A filter to apply."""
3636

3737
max_num_results: Optional[int] = None
3838
"""The maximum number of results to return.

src/openai/types/responses/file_search_tool_param.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import List, Union
5+
from typing import List, Union, Optional
66
from typing_extensions import Literal, Required, TypeAlias, TypedDict
77

88
from ..shared_params.compound_filter import CompoundFilter
@@ -18,10 +18,10 @@ class RankingOptions(TypedDict, total=False):
1818
"""The ranker to use for the file search."""
1919

2020
score_threshold: float
21-
"""
22-
The score threshold for the file search, a number between 0 and 1. Numbers
23-
closer to 1 will attempt to return only the most relevant results, but may
24-
return fewer results.
21+
"""The score threshold for the file search, a number between 0 and 1.
22+
23+
Numbers closer to 1 will attempt to return only the most relevant results, but
24+
may return fewer results.
2525
"""
2626

2727

@@ -32,8 +32,8 @@ class FileSearchToolParam(TypedDict, total=False):
3232
vector_store_ids: Required[List[str]]
3333
"""The IDs of the vector stores to search."""
3434

35-
filters: Filters
36-
"""A filter to apply based on file attributes."""
35+
filters: Optional[Filters]
36+
"""A filter to apply."""
3737

3838
max_num_results: int
3939
"""The maximum number of results to return.

src/openai/types/responses/function_tool.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ class FunctionTool(BaseModel):
1212
name: str
1313
"""The name of the function to call."""
1414

15-
parameters: Dict[str, object]
15+
parameters: Optional[Dict[str, object]] = None
1616
"""A JSON schema object describing the parameters of the function."""
1717

18-
strict: bool
18+
strict: Optional[bool] = None
1919
"""Whether to enforce strict parameter validation. Default `true`."""
2020

2121
type: Literal["function"]

src/openai/types/responses/function_tool_param.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ class FunctionToolParam(TypedDict, total=False):
1212
name: Required[str]
1313
"""The name of the function to call."""
1414

15-
parameters: Required[Dict[str, object]]
15+
parameters: Required[Optional[Dict[str, object]]]
1616
"""A JSON schema object describing the parameters of the function."""
1717

18-
strict: Required[bool]
18+
strict: Required[Optional[bool]]
1919
"""Whether to enforce strict parameter validation. Default `true`."""
2020

2121
type: Required[Literal["function"]]

src/openai/types/responses/response_create_params.py

+5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ class ResponseCreateParamsBase(TypedDict, total=False):
5656
- `message.input_image.image_url`: Include image urls from the input message.
5757
- `computer_call_output.output.image_url`: Include image urls from the computer
5858
call output.
59+
- `reasoning.encrypted_content`: Includes an encrypted version of reasoning
60+
tokens in reasoning item outputs. This enables reasoning items to be used in
61+
multi-turn conversations when using the Responses API statelessly (like when
62+
the `store` parameter is set to `false`, or when an organization is enrolled
63+
in the zero data retention program).
5964
"""
6065

6166
instructions: Optional[str]

0 commit comments

Comments
 (0)