From a229b37a1af8b4efe5e59672be7b473d1bb44edd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 4 May 2026 19:09:50 +0000 Subject: [PATCH 01/12] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 723cea85fe..ff1ede1c54 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 233 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-21ecab7aeb61612b9da5e52ea4c0cb75a33d443d975022934b9305e97d1a7d62.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-81b872fc8a50941a72f77f3fa0791f7234b9180db95b451b38ced94279e947c5.yml openapi_spec_hash: cfc868a0bb3567183510c9b5629c510f -config_hash: dd484e2cc01206d26516338d0f4596b0 +config_hash: 4a32815d42629ed593422278834dcca4 From 6069e19a816e12c076fda6f1207094fdfb4692fe Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 4 May 2026 20:44:50 +0000 Subject: [PATCH 02/12] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index ff1ede1c54..3e1ed4b9e5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 233 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-81b872fc8a50941a72f77f3fa0791f7234b9180db95b451b38ced94279e947c5.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-b29ed93b301b4a89daf4fb5bb6463cbc059ce944ff9808639679794c10e60dd6.yml openapi_spec_hash: cfc868a0bb3567183510c9b5629c510f -config_hash: 4a32815d42629ed593422278834dcca4 +config_hash: 2524657a4d3e2779f4a70cc581c33d80 From 6dd268a36ae6c4dd73cfcf2086e5a8c49ba7c116 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 4 May 2026 21:31:50 +0000 Subject: [PATCH 03/12] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3e1ed4b9e5..1c61ea53ec 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 233 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-b29ed93b301b4a89daf4fb5bb6463cbc059ce944ff9808639679794c10e60dd6.yml -openapi_spec_hash: cfc868a0bb3567183510c9b5629c510f +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-70926f399403fb20d9cee460500dad50a9555dd72b5abb768215e9f541a648ea.yml +openapi_spec_hash: ae4a7852e20f39c14adbf6f253b8a004 config_hash: 2524657a4d3e2779f4a70cc581c33d80 From 641c8c487f1e0e786bac17c55f5d8536c5e0336d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 00:42:06 +0000 Subject: [PATCH 04/12] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 1c61ea53ec..0b6e9119d8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 233 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-70926f399403fb20d9cee460500dad50a9555dd72b5abb768215e9f541a648ea.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-61d75f384a1e6bee387e9e02168257426facdbbb9677b9b5cb30a3863da40b10.yml openapi_spec_hash: ae4a7852e20f39c14adbf6f253b8a004 -config_hash: 2524657a4d3e2779f4a70cc581c33d80 +config_hash: 51d639d7939b6ab974d1ee45e96c532b From 408dce57fe849024b6a4e9e45797b62c8dc6d97f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 08:07:54 +0000 Subject: [PATCH 05/12] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 0b6e9119d8..85f4cd414b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 233 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-61d75f384a1e6bee387e9e02168257426facdbbb9677b9b5cb30a3863da40b10.yml -openapi_spec_hash: ae4a7852e20f39c14adbf6f253b8a004 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-1405c20d24646f71eecd0f7ed222426973b8806ef70a3865a2428c0c57b1f050.yml +openapi_spec_hash: 92713b0825f6b8760836778e6d27e837 config_hash: 51d639d7939b6ab974d1ee45e96c532b From 0ba55d7569565045426e1587906a70d5682a4bba Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 15:49:42 +0000 Subject: [PATCH 06/12] feat(api): launch realtime translate + update image 2 --- .stats.yml | 4 +- src/openai/resources/images.py | 108 +++++++++++------- src/openai/types/image_edit_params.py | 15 ++- src/openai/types/image_generate_params.py | 5 +- src/openai/types/image_model.py | 11 +- .../types/realtime/translations/__init__.py | 3 + src/openai/types/responses/tool.py | 13 ++- src/openai/types/responses/tool_param.py | 12 +- tests/api_resources/test_images.py | 20 ++-- 9 files changed, 127 insertions(+), 64 deletions(-) create mode 100644 src/openai/types/realtime/translations/__init__.py diff --git a/.stats.yml b/.stats.yml index 85f4cd414b..1dee1de615 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 233 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-1405c20d24646f71eecd0f7ed222426973b8806ef70a3865a2428c0c57b1f050.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-5ae2eda70e6a4a375842fb8bf3e88deab8e0aad1b3871b86e73274f131bb37ce.yml openapi_spec_hash: 92713b0825f6b8760836778e6d27e837 -config_hash: 51d639d7939b6ab974d1ee45e96c532b +config_hash: c15a744b2771a3948032b2438475b330 diff --git a/src/openai/resources/images.py b/src/openai/resources/images.py index ec4ca23aa2..1b3ade12c9 100644 --- a/src/openai/resources/images.py +++ b/src/openai/resources/images.py @@ -160,10 +160,10 @@ def edit( Args: image: The image(s) to edit. Must be a supported image file or an array of images. - For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, and - `gpt-image-1.5`), each image should be a `png`, `webp`, or `jpg` file less than - 50MB. You can provide up to 16 images. `chatgpt-image-latest` follows the same - input constraints as GPT image models. + For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, + `gpt-image-2`, `gpt-image-2-2026-04-21`, and `chatgpt-image-latest`), each image + should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to + 16 images. For `dall-e-2`, you can only provide one image, and it should be a square `png` file less than 4MB. @@ -189,7 +189,10 @@ def edit( the mask will be applied on the first image. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`. - model: The model to use for image generation. Defaults to `gpt-image-1.5`. + model: The model to use for image generation. One of `dall-e-2` or a GPT image model + (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, + `gpt-image-2-2026-04-21`, or `chatgpt-image-latest`). Defaults to + `gpt-image-1.5`. n: The number of images to generate. Must be between 1 and 10. @@ -273,10 +276,10 @@ def edit( Args: image: The image(s) to edit. Must be a supported image file or an array of images. - For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, and - `gpt-image-1.5`), each image should be a `png`, `webp`, or `jpg` file less than - 50MB. You can provide up to 16 images. `chatgpt-image-latest` follows the same - input constraints as GPT image models. + For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, + `gpt-image-2`, `gpt-image-2-2026-04-21`, and `chatgpt-image-latest`), each image + should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to + 16 images. For `dall-e-2`, you can only provide one image, and it should be a square `png` file less than 4MB. @@ -306,7 +309,10 @@ def edit( the mask will be applied on the first image. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`. - model: The model to use for image generation. Defaults to `gpt-image-1.5`. + model: The model to use for image generation. One of `dall-e-2` or a GPT image model + (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, + `gpt-image-2-2026-04-21`, or `chatgpt-image-latest`). Defaults to + `gpt-image-1.5`. n: The number of images to generate. Must be between 1 and 10. @@ -386,10 +392,10 @@ def edit( Args: image: The image(s) to edit. Must be a supported image file or an array of images. - For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, and - `gpt-image-1.5`), each image should be a `png`, `webp`, or `jpg` file less than - 50MB. You can provide up to 16 images. `chatgpt-image-latest` follows the same - input constraints as GPT image models. + For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, + `gpt-image-2`, `gpt-image-2-2026-04-21`, and `chatgpt-image-latest`), each image + should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to + 16 images. For `dall-e-2`, you can only provide one image, and it should be a square `png` file less than 4MB. @@ -419,7 +425,10 @@ def edit( the mask will be applied on the first image. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`. - model: The model to use for image generation. Defaults to `gpt-image-1.5`. + model: The model to use for image generation. One of `dall-e-2` or a GPT image model + (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, + `gpt-image-2-2026-04-21`, or `chatgpt-image-latest`). Defaults to + `gpt-image-1.5`. n: The number of images to generate. Must be between 1 and 10. @@ -580,8 +589,9 @@ def generate( be set to either `png` (default value) or `webp`. model: The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or a GPT - image model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`). Defaults to - `dall-e-2` unless a parameter specific to the GPT image models is used. + image model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, + or `gpt-image-2-2026-04-21`). Defaults to `dall-e-2` unless a parameter specific + to the GPT image models is used. moderation: Control the content-moderation level for images generated by the GPT image models. Must be either `low` for less restrictive filtering or `auto` (default @@ -695,8 +705,9 @@ def generate( be set to either `png` (default value) or `webp`. model: The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or a GPT - image model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`). Defaults to - `dall-e-2` unless a parameter specific to the GPT image models is used. + image model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, + or `gpt-image-2-2026-04-21`). Defaults to `dall-e-2` unless a parameter specific + to the GPT image models is used. moderation: Control the content-moderation level for images generated by the GPT image models. Must be either `low` for less restrictive filtering or `auto` (default @@ -806,8 +817,9 @@ def generate( be set to either `png` (default value) or `webp`. model: The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or a GPT - image model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`). Defaults to - `dall-e-2` unless a parameter specific to the GPT image models is used. + image model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, + or `gpt-image-2-2026-04-21`). Defaults to `dall-e-2` unless a parameter specific + to the GPT image models is used. moderation: Control the content-moderation level for images generated by the GPT image models. Must be either `low` for less restrictive filtering or `auto` (default @@ -1066,10 +1078,10 @@ async def edit( Args: image: The image(s) to edit. Must be a supported image file or an array of images. - For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, and - `gpt-image-1.5`), each image should be a `png`, `webp`, or `jpg` file less than - 50MB. You can provide up to 16 images. `chatgpt-image-latest` follows the same - input constraints as GPT image models. + For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, + `gpt-image-2`, `gpt-image-2-2026-04-21`, and `chatgpt-image-latest`), each image + should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to + 16 images. For `dall-e-2`, you can only provide one image, and it should be a square `png` file less than 4MB. @@ -1095,7 +1107,10 @@ async def edit( the mask will be applied on the first image. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`. - model: The model to use for image generation. Defaults to `gpt-image-1.5`. + model: The model to use for image generation. One of `dall-e-2` or a GPT image model + (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, + `gpt-image-2-2026-04-21`, or `chatgpt-image-latest`). Defaults to + `gpt-image-1.5`. n: The number of images to generate. Must be between 1 and 10. @@ -1179,10 +1194,10 @@ async def edit( Args: image: The image(s) to edit. Must be a supported image file or an array of images. - For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, and - `gpt-image-1.5`), each image should be a `png`, `webp`, or `jpg` file less than - 50MB. You can provide up to 16 images. `chatgpt-image-latest` follows the same - input constraints as GPT image models. + For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, + `gpt-image-2`, `gpt-image-2-2026-04-21`, and `chatgpt-image-latest`), each image + should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to + 16 images. For `dall-e-2`, you can only provide one image, and it should be a square `png` file less than 4MB. @@ -1212,7 +1227,10 @@ async def edit( the mask will be applied on the first image. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`. - model: The model to use for image generation. Defaults to `gpt-image-1.5`. + model: The model to use for image generation. One of `dall-e-2` or a GPT image model + (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, + `gpt-image-2-2026-04-21`, or `chatgpt-image-latest`). Defaults to + `gpt-image-1.5`. n: The number of images to generate. Must be between 1 and 10. @@ -1292,10 +1310,10 @@ async def edit( Args: image: The image(s) to edit. Must be a supported image file or an array of images. - For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, and - `gpt-image-1.5`), each image should be a `png`, `webp`, or `jpg` file less than - 50MB. You can provide up to 16 images. `chatgpt-image-latest` follows the same - input constraints as GPT image models. + For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, + `gpt-image-2`, `gpt-image-2-2026-04-21`, and `chatgpt-image-latest`), each image + should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to + 16 images. For `dall-e-2`, you can only provide one image, and it should be a square `png` file less than 4MB. @@ -1325,7 +1343,10 @@ async def edit( the mask will be applied on the first image. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`. - model: The model to use for image generation. Defaults to `gpt-image-1.5`. + model: The model to use for image generation. One of `dall-e-2` or a GPT image model + (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, + `gpt-image-2-2026-04-21`, or `chatgpt-image-latest`). Defaults to + `gpt-image-1.5`. n: The number of images to generate. Must be between 1 and 10. @@ -1486,8 +1507,9 @@ async def generate( be set to either `png` (default value) or `webp`. model: The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or a GPT - image model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`). Defaults to - `dall-e-2` unless a parameter specific to the GPT image models is used. + image model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, + or `gpt-image-2-2026-04-21`). Defaults to `dall-e-2` unless a parameter specific + to the GPT image models is used. moderation: Control the content-moderation level for images generated by the GPT image models. Must be either `low` for less restrictive filtering or `auto` (default @@ -1601,8 +1623,9 @@ async def generate( be set to either `png` (default value) or `webp`. model: The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or a GPT - image model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`). Defaults to - `dall-e-2` unless a parameter specific to the GPT image models is used. + image model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, + or `gpt-image-2-2026-04-21`). Defaults to `dall-e-2` unless a parameter specific + to the GPT image models is used. moderation: Control the content-moderation level for images generated by the GPT image models. Must be either `low` for less restrictive filtering or `auto` (default @@ -1712,8 +1735,9 @@ async def generate( be set to either `png` (default value) or `webp`. model: The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or a GPT - image model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`). Defaults to - `dall-e-2` unless a parameter specific to the GPT image models is used. + image model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, + or `gpt-image-2-2026-04-21`). Defaults to `dall-e-2` unless a parameter specific + to the GPT image models is used. moderation: Control the content-moderation level for images generated by the GPT image models. Must be either `low` for less restrictive filtering or `auto` (default diff --git a/src/openai/types/image_edit_params.py b/src/openai/types/image_edit_params.py index 05f3401d2d..ab70789fe6 100644 --- a/src/openai/types/image_edit_params.py +++ b/src/openai/types/image_edit_params.py @@ -15,10 +15,10 @@ class ImageEditParamsBase(TypedDict, total=False): image: Required[Union[FileTypes, SequenceNotStr[FileTypes]]] """The image(s) to edit. Must be a supported image file or an array of images. - For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, and - `gpt-image-1.5`), each image should be a `png`, `webp`, or `jpg` file less than - 50MB. You can provide up to 16 images. `chatgpt-image-latest` follows the same - input constraints as GPT image models. + For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, + `gpt-image-2`, `gpt-image-2-2026-04-21`, and `chatgpt-image-latest`), each image + should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to + 16 images. For `dall-e-2`, you can only provide one image, and it should be a square `png` file less than 4MB. @@ -59,7 +59,12 @@ class ImageEditParamsBase(TypedDict, total=False): """ model: Union[str, ImageModel, None] - """The model to use for image generation. Defaults to `gpt-image-1.5`.""" + """The model to use for image generation. + + One of `dall-e-2` or a GPT image model (`gpt-image-1`, `gpt-image-1-mini`, + `gpt-image-1.5`, `gpt-image-2`, `gpt-image-2-2026-04-21`, or + `chatgpt-image-latest`). Defaults to `gpt-image-1.5`. + """ n: Optional[int] """The number of images to generate. Must be between 1 and 10.""" diff --git a/src/openai/types/image_generate_params.py b/src/openai/types/image_generate_params.py index 7a95b3dd3d..30a514cffb 100644 --- a/src/openai/types/image_generate_params.py +++ b/src/openai/types/image_generate_params.py @@ -33,8 +33,9 @@ class ImageGenerateParamsBase(TypedDict, total=False): """The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or a GPT image model (`gpt-image-1`, - `gpt-image-1-mini`, `gpt-image-1.5`). Defaults to `dall-e-2` unless a parameter - specific to the GPT image models is used. + `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, or + `gpt-image-2-2026-04-21`). Defaults to `dall-e-2` unless a parameter specific to + the GPT image models is used. """ moderation: Optional[Literal["low", "auto"]] diff --git a/src/openai/types/image_model.py b/src/openai/types/image_model.py index 8ea486fbb6..4586fdebdf 100644 --- a/src/openai/types/image_model.py +++ b/src/openai/types/image_model.py @@ -4,4 +4,13 @@ __all__ = ["ImageModel"] -ImageModel: TypeAlias = Literal["gpt-image-1.5", "dall-e-2", "dall-e-3", "gpt-image-1", "gpt-image-1-mini"] +ImageModel: TypeAlias = Literal[ + "gpt-image-1", + "gpt-image-1-mini", + "gpt-image-2", + "gpt-image-2-2026-04-21", + "gpt-image-1.5", + "chatgpt-image-latest", + "dall-e-2", + "dall-e-3", +] diff --git a/src/openai/types/realtime/translations/__init__.py b/src/openai/types/realtime/translations/__init__.py new file mode 100644 index 0000000000..f8ee8b14b1 --- /dev/null +++ b/src/openai/types/realtime/translations/__init__.py @@ -0,0 +1,3 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations diff --git a/src/openai/types/responses/tool.py b/src/openai/types/responses/tool.py index 34120a287e..90929123c6 100644 --- a/src/openai/types/responses/tool.py +++ b/src/openai/types/responses/tool.py @@ -267,7 +267,18 @@ class ImageGeneration(BaseModel): Contains `image_url` (string, optional) and `file_id` (string, optional). """ - model: Union[str, Literal["gpt-image-1", "gpt-image-1-mini", "gpt-image-1.5"], None] = None + model: Union[ + str, + Literal[ + "gpt-image-1", + "gpt-image-1-mini", + "gpt-image-2", + "gpt-image-2-2026-04-21", + "gpt-image-1.5", + "chatgpt-image-latest", + ], + None, + ] = None """The image generation model to use. Default: `gpt-image-1`.""" moderation: Optional[Literal["auto", "low"]] = None diff --git a/src/openai/types/responses/tool_param.py b/src/openai/types/responses/tool_param.py index c0f33c4513..8e6c6591a9 100644 --- a/src/openai/types/responses/tool_param.py +++ b/src/openai/types/responses/tool_param.py @@ -267,7 +267,17 @@ class ImageGeneration(TypedDict, total=False): Contains `image_url` (string, optional) and `file_id` (string, optional). """ - model: Union[str, Literal["gpt-image-1", "gpt-image-1-mini", "gpt-image-1.5"]] + model: Union[ + str, + Literal[ + "gpt-image-1", + "gpt-image-1-mini", + "gpt-image-2", + "gpt-image-2-2026-04-21", + "gpt-image-1.5", + "chatgpt-image-latest", + ], + ] """The image generation model to use. Default: `gpt-image-1`.""" moderation: Literal["auto", "low"] diff --git a/tests/api_resources/test_images.py b/tests/api_resources/test_images.py index 13cbc0acb7..6f6e700517 100644 --- a/tests/api_resources/test_images.py +++ b/tests/api_resources/test_images.py @@ -28,7 +28,7 @@ def test_method_create_variation(self, client: OpenAI) -> None: def test_method_create_variation_with_all_params(self, client: OpenAI) -> None: image = client.images.create_variation( image=b"Example data", - model="gpt-image-1.5", + model="gpt-image-1", n=1, response_format="url", size="1024x1024", @@ -76,7 +76,7 @@ def test_method_edit_with_all_params_overload_1(self, client: OpenAI) -> None: background="transparent", input_fidelity="high", mask=b"Example data", - model="gpt-image-1.5", + model="gpt-image-2", n=1, output_compression=100, output_format="png", @@ -133,7 +133,7 @@ def test_method_edit_with_all_params_overload_2(self, client: OpenAI) -> None: background="transparent", input_fidelity="high", mask=b"Example data", - model="gpt-image-1.5", + model="gpt-image-2", n=1, output_compression=100, output_format="png", @@ -184,7 +184,7 @@ def test_method_generate_with_all_params_overload_1(self, client: OpenAI) -> Non image = client.images.generate( prompt="A cute baby sea otter", background="transparent", - model="gpt-image-1.5", + model="gpt-image-2", moderation="low", n=1, output_compression=100, @@ -237,7 +237,7 @@ def test_method_generate_with_all_params_overload_2(self, client: OpenAI) -> Non prompt="A cute baby sea otter", stream=True, background="transparent", - model="gpt-image-1.5", + model="gpt-image-2", moderation="low", n=1, output_compression=100, @@ -293,7 +293,7 @@ async def test_method_create_variation(self, async_client: AsyncOpenAI) -> None: async def test_method_create_variation_with_all_params(self, async_client: AsyncOpenAI) -> None: image = await async_client.images.create_variation( image=b"Example data", - model="gpt-image-1.5", + model="gpt-image-1", n=1, response_format="url", size="1024x1024", @@ -341,7 +341,7 @@ async def test_method_edit_with_all_params_overload_1(self, async_client: AsyncO background="transparent", input_fidelity="high", mask=b"Example data", - model="gpt-image-1.5", + model="gpt-image-2", n=1, output_compression=100, output_format="png", @@ -398,7 +398,7 @@ async def test_method_edit_with_all_params_overload_2(self, async_client: AsyncO background="transparent", input_fidelity="high", mask=b"Example data", - model="gpt-image-1.5", + model="gpt-image-2", n=1, output_compression=100, output_format="png", @@ -449,7 +449,7 @@ async def test_method_generate_with_all_params_overload_1(self, async_client: As image = await async_client.images.generate( prompt="A cute baby sea otter", background="transparent", - model="gpt-image-1.5", + model="gpt-image-2", moderation="low", n=1, output_compression=100, @@ -502,7 +502,7 @@ async def test_method_generate_with_all_params_overload_2(self, async_client: As prompt="A cute baby sea otter", stream=True, background="transparent", - model="gpt-image-1.5", + model="gpt-image-2", moderation="low", n=1, output_compression=100, From 72bf67acbc9f030c20db3d5a1a74ea6d67d55f51 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 17:11:30 +0000 Subject: [PATCH 07/12] feat(api): manual updates --- .stats.yml | 4 +- src/openai/resources/images.py | 362 ++++++++++++------ src/openai/types/image_edit_params.py | 26 +- src/openai/types/image_generate_params.py | 29 +- .../types/realtime/translations/__init__.py | 3 - src/openai/types/responses/tool.py | 33 +- src/openai/types/responses/tool_param.py | 33 +- 7 files changed, 336 insertions(+), 154 deletions(-) delete mode 100644 src/openai/types/realtime/translations/__init__.py diff --git a/.stats.yml b/.stats.yml index 1dee1de615..e4dba3d576 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 233 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-5ae2eda70e6a4a375842fb8bf3e88deab8e0aad1b3871b86e73274f131bb37ce.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-5002c7ce1688cf372f6c268507494c5e6396f38db8d85d79029d949b7bb06fe3.yml openapi_spec_hash: 92713b0825f6b8760836778e6d27e837 -config_hash: c15a744b2771a3948032b2438475b330 +config_hash: c6cf65d9b19a16ce4313602a2204d48f diff --git a/src/openai/resources/images.py b/src/openai/resources/images.py index 1b3ade12c9..6ac622ee1e 100644 --- a/src/openai/resources/images.py +++ b/src/openai/resources/images.py @@ -141,7 +141,7 @@ def edit( partial_images: Optional[int] | Omit = omit, quality: Optional[Literal["standard", "low", "medium", "high", "auto"]] | Omit = omit, response_format: Optional[Literal["url", "b64_json"]] | Omit = omit, - size: Optional[Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"]] | Omit = omit, + size: Optional[str] | Omit = omit, stream: Optional[Literal[False]] | Omit = omit, user: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -172,9 +172,14 @@ def edit( characters for `dall-e-2`, and 32000 characters for the GPT image models. background: Allows to set transparency for the background of the generated image(s). This - parameter is only supported for the GPT image models. Must be one of - `transparent`, `opaque` or `auto` (default value). When `auto` is used, the - model will automatically determine the best background for the image. + parameter is only supported for GPT image models that support transparent + backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value). + When `auto` is used, the model will automatically determine the best background + for the image. + + `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent + backgrounds. Requests with `background` set to `transparent` will return an + error for these models; use `opaque` or `auto` instead. If `transparent`, the output format needs to support transparency, so it should be set to either `png` (default value) or `webp`. @@ -219,9 +224,17 @@ def edit( generated. This parameter is only supported for `dall-e-2` (default is `url` for `dall-e-2`), as GPT image models always return base64-encoded images. - size: The size of the generated images. Must be one of `1024x1024`, `1536x1024` - (landscape), `1024x1536` (portrait), or `auto` (default value) for the GPT image - models, and one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`. + size: The size of the generated images. For `gpt-image-2` and + `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` + strings, for example `1536x864`. Width and height must both be divisible by 16 + and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above + `2560x1440` are experimental, and the maximum supported resolution is + `3840x2160`. The requested size must also satisfy the model's current pixel and + edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are + supported by the GPT image models; `auto` is supported for models that allow + automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or + `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or + `1024x1792`. stream: Edit the image in streaming mode. Defaults to `false`. See the [Image generation guide](https://platform.openai.com/docs/guides/image-generation) @@ -258,7 +271,7 @@ def edit( partial_images: Optional[int] | Omit = omit, quality: Optional[Literal["standard", "low", "medium", "high", "auto"]] | Omit = omit, response_format: Optional[Literal["url", "b64_json"]] | Omit = omit, - size: Optional[Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"]] | Omit = omit, + size: Optional[str] | Omit = omit, user: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -292,9 +305,14 @@ def edit( for more information. background: Allows to set transparency for the background of the generated image(s). This - parameter is only supported for the GPT image models. Must be one of - `transparent`, `opaque` or `auto` (default value). When `auto` is used, the - model will automatically determine the best background for the image. + parameter is only supported for GPT image models that support transparent + backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value). + When `auto` is used, the model will automatically determine the best background + for the image. + + `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent + backgrounds. Requests with `background` set to `transparent` will return an + error for these models; use `opaque` or `auto` instead. If `transparent`, the output format needs to support transparency, so it should be set to either `png` (default value) or `webp`. @@ -339,9 +357,17 @@ def edit( generated. This parameter is only supported for `dall-e-2` (default is `url` for `dall-e-2`), as GPT image models always return base64-encoded images. - size: The size of the generated images. Must be one of `1024x1024`, `1536x1024` - (landscape), `1024x1536` (portrait), or `auto` (default value) for the GPT image - models, and one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`. + size: The size of the generated images. For `gpt-image-2` and + `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` + strings, for example `1536x864`. Width and height must both be divisible by 16 + and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above + `2560x1440` are experimental, and the maximum supported resolution is + `3840x2160`. The requested size must also satisfy the model's current pixel and + edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are + supported by the GPT image models; `auto` is supported for models that allow + automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or + `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or + `1024x1792`. user: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. @@ -374,7 +400,7 @@ def edit( partial_images: Optional[int] | Omit = omit, quality: Optional[Literal["standard", "low", "medium", "high", "auto"]] | Omit = omit, response_format: Optional[Literal["url", "b64_json"]] | Omit = omit, - size: Optional[Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"]] | Omit = omit, + size: Optional[str] | Omit = omit, user: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -408,9 +434,14 @@ def edit( for more information. background: Allows to set transparency for the background of the generated image(s). This - parameter is only supported for the GPT image models. Must be one of - `transparent`, `opaque` or `auto` (default value). When `auto` is used, the - model will automatically determine the best background for the image. + parameter is only supported for GPT image models that support transparent + backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value). + When `auto` is used, the model will automatically determine the best background + for the image. + + `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent + backgrounds. Requests with `background` set to `transparent` will return an + error for these models; use `opaque` or `auto` instead. If `transparent`, the output format needs to support transparency, so it should be set to either `png` (default value) or `webp`. @@ -455,9 +486,17 @@ def edit( generated. This parameter is only supported for `dall-e-2` (default is `url` for `dall-e-2`), as GPT image models always return base64-encoded images. - size: The size of the generated images. Must be one of `1024x1024`, `1536x1024` - (landscape), `1024x1536` (portrait), or `auto` (default value) for the GPT image - models, and one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`. + size: The size of the generated images. For `gpt-image-2` and + `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` + strings, for example `1536x864`. Width and height must both be divisible by 16 + and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above + `2560x1440` are experimental, and the maximum supported resolution is + `3840x2160`. The requested size must also satisfy the model's current pixel and + edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are + supported by the GPT image models; `auto` is supported for models that allow + automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or + `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or + `1024x1792`. user: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. @@ -489,7 +528,7 @@ def edit( partial_images: Optional[int] | Omit = omit, quality: Optional[Literal["standard", "low", "medium", "high", "auto"]] | Omit = omit, response_format: Optional[Literal["url", "b64_json"]] | Omit = omit, - size: Optional[Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"]] | Omit = omit, + size: Optional[str] | Omit = omit, stream: Optional[Literal[False]] | Literal[True] | Omit = omit, user: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -557,10 +596,7 @@ def generate( partial_images: Optional[int] | Omit = omit, quality: Optional[Literal["standard", "hd", "low", "medium", "high", "auto"]] | Omit = omit, response_format: Optional[Literal["url", "b64_json"]] | Omit = omit, - size: Optional[ - Literal["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"] - ] - | Omit = omit, + size: Optional[str] | Omit = omit, stream: Optional[Literal[False]] | Omit = omit, style: Optional[Literal["vivid", "natural"]] | Omit = omit, user: str | Omit = omit, @@ -581,9 +617,14 @@ def generate( characters for `dall-e-3`. background: Allows to set transparency for the background of the generated image(s). This - parameter is only supported for the GPT image models. Must be one of - `transparent`, `opaque` or `auto` (default value). When `auto` is used, the - model will automatically determine the best background for the image. + parameter is only supported for GPT image models that support transparent + backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value). + When `auto` is used, the model will automatically determine the best background + for the image. + + `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent + backgrounds. Requests with `background` set to `transparent` will return an + error for these models; use `opaque` or `auto` instead. If `transparent`, the output format needs to support transparency, so it should be set to either `png` (default value) or `webp`. @@ -627,10 +668,17 @@ def generate( after the image has been generated. This parameter isn't supported for the GPT image models, which always return base64-encoded images. - size: The size of the generated images. Must be one of `1024x1024`, `1536x1024` - (landscape), `1024x1536` (portrait), or `auto` (default value) for the GPT image - models, one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and one of - `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3`. + size: The size of the generated images. For `gpt-image-2` and + `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` + strings, for example `1536x864`. Width and height must both be divisible by 16 + and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above + `2560x1440` are experimental, and the maximum supported resolution is + `3840x2160`. The requested size must also satisfy the model's current pixel and + edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are + supported by the GPT image models; `auto` is supported for models that allow + automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or + `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or + `1024x1792`. stream: Generate the image in streaming mode. Defaults to `false`. See the [Image generation guide](https://platform.openai.com/docs/guides/image-generation) @@ -670,10 +718,7 @@ def generate( partial_images: Optional[int] | Omit = omit, quality: Optional[Literal["standard", "hd", "low", "medium", "high", "auto"]] | Omit = omit, response_format: Optional[Literal["url", "b64_json"]] | Omit = omit, - size: Optional[ - Literal["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"] - ] - | Omit = omit, + size: Optional[str] | Omit = omit, style: Optional[Literal["vivid", "natural"]] | Omit = omit, user: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -697,9 +742,14 @@ def generate( for more information. This parameter is only supported for the GPT image models. background: Allows to set transparency for the background of the generated image(s). This - parameter is only supported for the GPT image models. Must be one of - `transparent`, `opaque` or `auto` (default value). When `auto` is used, the - model will automatically determine the best background for the image. + parameter is only supported for GPT image models that support transparent + backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value). + When `auto` is used, the model will automatically determine the best background + for the image. + + `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent + backgrounds. Requests with `background` set to `transparent` will return an + error for these models; use `opaque` or `auto` instead. If `transparent`, the output format needs to support transparency, so it should be set to either `png` (default value) or `webp`. @@ -743,10 +793,17 @@ def generate( after the image has been generated. This parameter isn't supported for the GPT image models, which always return base64-encoded images. - size: The size of the generated images. Must be one of `1024x1024`, `1536x1024` - (landscape), `1024x1536` (portrait), or `auto` (default value) for the GPT image - models, one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and one of - `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3`. + size: The size of the generated images. For `gpt-image-2` and + `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` + strings, for example `1536x864`. Width and height must both be divisible by 16 + and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above + `2560x1440` are experimental, and the maximum supported resolution is + `3840x2160`. The requested size must also satisfy the model's current pixel and + edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are + supported by the GPT image models; `auto` is supported for models that allow + automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or + `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or + `1024x1792`. style: The style of the generated images. This parameter is only supported for `dall-e-3`. Must be one of `vivid` or `natural`. Vivid causes the model to lean @@ -782,10 +839,7 @@ def generate( partial_images: Optional[int] | Omit = omit, quality: Optional[Literal["standard", "hd", "low", "medium", "high", "auto"]] | Omit = omit, response_format: Optional[Literal["url", "b64_json"]] | Omit = omit, - size: Optional[ - Literal["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"] - ] - | Omit = omit, + size: Optional[str] | Omit = omit, style: Optional[Literal["vivid", "natural"]] | Omit = omit, user: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -809,9 +863,14 @@ def generate( for more information. This parameter is only supported for the GPT image models. background: Allows to set transparency for the background of the generated image(s). This - parameter is only supported for the GPT image models. Must be one of - `transparent`, `opaque` or `auto` (default value). When `auto` is used, the - model will automatically determine the best background for the image. + parameter is only supported for GPT image models that support transparent + backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value). + When `auto` is used, the model will automatically determine the best background + for the image. + + `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent + backgrounds. Requests with `background` set to `transparent` will return an + error for these models; use `opaque` or `auto` instead. If `transparent`, the output format needs to support transparency, so it should be set to either `png` (default value) or `webp`. @@ -855,10 +914,17 @@ def generate( after the image has been generated. This parameter isn't supported for the GPT image models, which always return base64-encoded images. - size: The size of the generated images. Must be one of `1024x1024`, `1536x1024` - (landscape), `1024x1536` (portrait), or `auto` (default value) for the GPT image - models, one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and one of - `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3`. + size: The size of the generated images. For `gpt-image-2` and + `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` + strings, for example `1536x864`. Width and height must both be divisible by 16 + and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above + `2560x1440` are experimental, and the maximum supported resolution is + `3840x2160`. The requested size must also satisfy the model's current pixel and + edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are + supported by the GPT image models; `auto` is supported for models that allow + automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or + `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or + `1024x1792`. style: The style of the generated images. This parameter is only supported for `dall-e-3`. Must be one of `vivid` or `natural`. Vivid causes the model to lean @@ -893,10 +959,7 @@ def generate( partial_images: Optional[int] | Omit = omit, quality: Optional[Literal["standard", "hd", "low", "medium", "high", "auto"]] | Omit = omit, response_format: Optional[Literal["url", "b64_json"]] | Omit = omit, - size: Optional[ - Literal["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"] - ] - | Omit = omit, + size: Optional[str] | Omit = omit, stream: Optional[Literal[False]] | Literal[True] | Omit = omit, style: Optional[Literal["vivid", "natural"]] | Omit = omit, user: str | Omit = omit, @@ -1059,7 +1122,7 @@ async def edit( partial_images: Optional[int] | Omit = omit, quality: Optional[Literal["standard", "low", "medium", "high", "auto"]] | Omit = omit, response_format: Optional[Literal["url", "b64_json"]] | Omit = omit, - size: Optional[Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"]] | Omit = omit, + size: Optional[str] | Omit = omit, stream: Optional[Literal[False]] | Omit = omit, user: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1090,9 +1153,14 @@ async def edit( characters for `dall-e-2`, and 32000 characters for the GPT image models. background: Allows to set transparency for the background of the generated image(s). This - parameter is only supported for the GPT image models. Must be one of - `transparent`, `opaque` or `auto` (default value). When `auto` is used, the - model will automatically determine the best background for the image. + parameter is only supported for GPT image models that support transparent + backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value). + When `auto` is used, the model will automatically determine the best background + for the image. + + `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent + backgrounds. Requests with `background` set to `transparent` will return an + error for these models; use `opaque` or `auto` instead. If `transparent`, the output format needs to support transparency, so it should be set to either `png` (default value) or `webp`. @@ -1137,9 +1205,17 @@ async def edit( generated. This parameter is only supported for `dall-e-2` (default is `url` for `dall-e-2`), as GPT image models always return base64-encoded images. - size: The size of the generated images. Must be one of `1024x1024`, `1536x1024` - (landscape), `1024x1536` (portrait), or `auto` (default value) for the GPT image - models, and one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`. + size: The size of the generated images. For `gpt-image-2` and + `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` + strings, for example `1536x864`. Width and height must both be divisible by 16 + and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above + `2560x1440` are experimental, and the maximum supported resolution is + `3840x2160`. The requested size must also satisfy the model's current pixel and + edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are + supported by the GPT image models; `auto` is supported for models that allow + automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or + `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or + `1024x1792`. stream: Edit the image in streaming mode. Defaults to `false`. See the [Image generation guide](https://platform.openai.com/docs/guides/image-generation) @@ -1176,7 +1252,7 @@ async def edit( partial_images: Optional[int] | Omit = omit, quality: Optional[Literal["standard", "low", "medium", "high", "auto"]] | Omit = omit, response_format: Optional[Literal["url", "b64_json"]] | Omit = omit, - size: Optional[Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"]] | Omit = omit, + size: Optional[str] | Omit = omit, user: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -1210,9 +1286,14 @@ async def edit( for more information. background: Allows to set transparency for the background of the generated image(s). This - parameter is only supported for the GPT image models. Must be one of - `transparent`, `opaque` or `auto` (default value). When `auto` is used, the - model will automatically determine the best background for the image. + parameter is only supported for GPT image models that support transparent + backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value). + When `auto` is used, the model will automatically determine the best background + for the image. + + `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent + backgrounds. Requests with `background` set to `transparent` will return an + error for these models; use `opaque` or `auto` instead. If `transparent`, the output format needs to support transparency, so it should be set to either `png` (default value) or `webp`. @@ -1257,9 +1338,17 @@ async def edit( generated. This parameter is only supported for `dall-e-2` (default is `url` for `dall-e-2`), as GPT image models always return base64-encoded images. - size: The size of the generated images. Must be one of `1024x1024`, `1536x1024` - (landscape), `1024x1536` (portrait), or `auto` (default value) for the GPT image - models, and one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`. + size: The size of the generated images. For `gpt-image-2` and + `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` + strings, for example `1536x864`. Width and height must both be divisible by 16 + and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above + `2560x1440` are experimental, and the maximum supported resolution is + `3840x2160`. The requested size must also satisfy the model's current pixel and + edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are + supported by the GPT image models; `auto` is supported for models that allow + automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or + `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or + `1024x1792`. user: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. @@ -1292,7 +1381,7 @@ async def edit( partial_images: Optional[int] | Omit = omit, quality: Optional[Literal["standard", "low", "medium", "high", "auto"]] | Omit = omit, response_format: Optional[Literal["url", "b64_json"]] | Omit = omit, - size: Optional[Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"]] | Omit = omit, + size: Optional[str] | Omit = omit, user: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -1326,9 +1415,14 @@ async def edit( for more information. background: Allows to set transparency for the background of the generated image(s). This - parameter is only supported for the GPT image models. Must be one of - `transparent`, `opaque` or `auto` (default value). When `auto` is used, the - model will automatically determine the best background for the image. + parameter is only supported for GPT image models that support transparent + backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value). + When `auto` is used, the model will automatically determine the best background + for the image. + + `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent + backgrounds. Requests with `background` set to `transparent` will return an + error for these models; use `opaque` or `auto` instead. If `transparent`, the output format needs to support transparency, so it should be set to either `png` (default value) or `webp`. @@ -1373,9 +1467,17 @@ async def edit( generated. This parameter is only supported for `dall-e-2` (default is `url` for `dall-e-2`), as GPT image models always return base64-encoded images. - size: The size of the generated images. Must be one of `1024x1024`, `1536x1024` - (landscape), `1024x1536` (portrait), or `auto` (default value) for the GPT image - models, and one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`. + size: The size of the generated images. For `gpt-image-2` and + `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` + strings, for example `1536x864`. Width and height must both be divisible by 16 + and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above + `2560x1440` are experimental, and the maximum supported resolution is + `3840x2160`. The requested size must also satisfy the model's current pixel and + edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are + supported by the GPT image models; `auto` is supported for models that allow + automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or + `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or + `1024x1792`. user: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. @@ -1407,7 +1509,7 @@ async def edit( partial_images: Optional[int] | Omit = omit, quality: Optional[Literal["standard", "low", "medium", "high", "auto"]] | Omit = omit, response_format: Optional[Literal["url", "b64_json"]] | Omit = omit, - size: Optional[Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"]] | Omit = omit, + size: Optional[str] | Omit = omit, stream: Optional[Literal[False]] | Literal[True] | Omit = omit, user: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1475,10 +1577,7 @@ async def generate( partial_images: Optional[int] | Omit = omit, quality: Optional[Literal["standard", "hd", "low", "medium", "high", "auto"]] | Omit = omit, response_format: Optional[Literal["url", "b64_json"]] | Omit = omit, - size: Optional[ - Literal["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"] - ] - | Omit = omit, + size: Optional[str] | Omit = omit, stream: Optional[Literal[False]] | Omit = omit, style: Optional[Literal["vivid", "natural"]] | Omit = omit, user: str | Omit = omit, @@ -1499,9 +1598,14 @@ async def generate( characters for `dall-e-3`. background: Allows to set transparency for the background of the generated image(s). This - parameter is only supported for the GPT image models. Must be one of - `transparent`, `opaque` or `auto` (default value). When `auto` is used, the - model will automatically determine the best background for the image. + parameter is only supported for GPT image models that support transparent + backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value). + When `auto` is used, the model will automatically determine the best background + for the image. + + `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent + backgrounds. Requests with `background` set to `transparent` will return an + error for these models; use `opaque` or `auto` instead. If `transparent`, the output format needs to support transparency, so it should be set to either `png` (default value) or `webp`. @@ -1545,10 +1649,17 @@ async def generate( after the image has been generated. This parameter isn't supported for the GPT image models, which always return base64-encoded images. - size: The size of the generated images. Must be one of `1024x1024`, `1536x1024` - (landscape), `1024x1536` (portrait), or `auto` (default value) for the GPT image - models, one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and one of - `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3`. + size: The size of the generated images. For `gpt-image-2` and + `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` + strings, for example `1536x864`. Width and height must both be divisible by 16 + and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above + `2560x1440` are experimental, and the maximum supported resolution is + `3840x2160`. The requested size must also satisfy the model's current pixel and + edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are + supported by the GPT image models; `auto` is supported for models that allow + automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or + `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or + `1024x1792`. stream: Generate the image in streaming mode. Defaults to `false`. See the [Image generation guide](https://platform.openai.com/docs/guides/image-generation) @@ -1588,10 +1699,7 @@ async def generate( partial_images: Optional[int] | Omit = omit, quality: Optional[Literal["standard", "hd", "low", "medium", "high", "auto"]] | Omit = omit, response_format: Optional[Literal["url", "b64_json"]] | Omit = omit, - size: Optional[ - Literal["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"] - ] - | Omit = omit, + size: Optional[str] | Omit = omit, style: Optional[Literal["vivid", "natural"]] | Omit = omit, user: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1615,9 +1723,14 @@ async def generate( for more information. This parameter is only supported for the GPT image models. background: Allows to set transparency for the background of the generated image(s). This - parameter is only supported for the GPT image models. Must be one of - `transparent`, `opaque` or `auto` (default value). When `auto` is used, the - model will automatically determine the best background for the image. + parameter is only supported for GPT image models that support transparent + backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value). + When `auto` is used, the model will automatically determine the best background + for the image. + + `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent + backgrounds. Requests with `background` set to `transparent` will return an + error for these models; use `opaque` or `auto` instead. If `transparent`, the output format needs to support transparency, so it should be set to either `png` (default value) or `webp`. @@ -1661,10 +1774,17 @@ async def generate( after the image has been generated. This parameter isn't supported for the GPT image models, which always return base64-encoded images. - size: The size of the generated images. Must be one of `1024x1024`, `1536x1024` - (landscape), `1024x1536` (portrait), or `auto` (default value) for the GPT image - models, one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and one of - `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3`. + size: The size of the generated images. For `gpt-image-2` and + `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` + strings, for example `1536x864`. Width and height must both be divisible by 16 + and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above + `2560x1440` are experimental, and the maximum supported resolution is + `3840x2160`. The requested size must also satisfy the model's current pixel and + edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are + supported by the GPT image models; `auto` is supported for models that allow + automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or + `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or + `1024x1792`. style: The style of the generated images. This parameter is only supported for `dall-e-3`. Must be one of `vivid` or `natural`. Vivid causes the model to lean @@ -1700,10 +1820,7 @@ async def generate( partial_images: Optional[int] | Omit = omit, quality: Optional[Literal["standard", "hd", "low", "medium", "high", "auto"]] | Omit = omit, response_format: Optional[Literal["url", "b64_json"]] | Omit = omit, - size: Optional[ - Literal["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"] - ] - | Omit = omit, + size: Optional[str] | Omit = omit, style: Optional[Literal["vivid", "natural"]] | Omit = omit, user: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1727,9 +1844,14 @@ async def generate( for more information. This parameter is only supported for the GPT image models. background: Allows to set transparency for the background of the generated image(s). This - parameter is only supported for the GPT image models. Must be one of - `transparent`, `opaque` or `auto` (default value). When `auto` is used, the - model will automatically determine the best background for the image. + parameter is only supported for GPT image models that support transparent + backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value). + When `auto` is used, the model will automatically determine the best background + for the image. + + `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent + backgrounds. Requests with `background` set to `transparent` will return an + error for these models; use `opaque` or `auto` instead. If `transparent`, the output format needs to support transparency, so it should be set to either `png` (default value) or `webp`. @@ -1773,10 +1895,17 @@ async def generate( after the image has been generated. This parameter isn't supported for the GPT image models, which always return base64-encoded images. - size: The size of the generated images. Must be one of `1024x1024`, `1536x1024` - (landscape), `1024x1536` (portrait), or `auto` (default value) for the GPT image - models, one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and one of - `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3`. + size: The size of the generated images. For `gpt-image-2` and + `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` + strings, for example `1536x864`. Width and height must both be divisible by 16 + and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above + `2560x1440` are experimental, and the maximum supported resolution is + `3840x2160`. The requested size must also satisfy the model's current pixel and + edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are + supported by the GPT image models; `auto` is supported for models that allow + automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or + `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or + `1024x1792`. style: The style of the generated images. This parameter is only supported for `dall-e-3`. Must be one of `vivid` or `natural`. Vivid causes the model to lean @@ -1811,10 +1940,7 @@ async def generate( partial_images: Optional[int] | Omit = omit, quality: Optional[Literal["standard", "hd", "low", "medium", "high", "auto"]] | Omit = omit, response_format: Optional[Literal["url", "b64_json"]] | Omit = omit, - size: Optional[ - Literal["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"] - ] - | Omit = omit, + size: Optional[str] | Omit = omit, stream: Optional[Literal[False]] | Literal[True] | Omit = omit, style: Optional[Literal["vivid", "natural"]] | Omit = omit, user: str | Omit = omit, diff --git a/src/openai/types/image_edit_params.py b/src/openai/types/image_edit_params.py index ab70789fe6..3c0e41d572 100644 --- a/src/openai/types/image_edit_params.py +++ b/src/openai/types/image_edit_params.py @@ -34,9 +34,14 @@ class ImageEditParamsBase(TypedDict, total=False): background: Optional[Literal["transparent", "opaque", "auto"]] """ Allows to set transparency for the background of the generated image(s). This - parameter is only supported for the GPT image models. Must be one of - `transparent`, `opaque` or `auto` (default value). When `auto` is used, the - model will automatically determine the best background for the image. + parameter is only supported for GPT image models that support transparent + backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value). + When `auto` is used, the model will automatically determine the best background + for the image. + + `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent + backgrounds. Requests with `background` set to `transparent` will return an + error for these models; use `opaque` or `auto` instead. If `transparent`, the output format needs to support transparency, so it should be set to either `png` (default value) or `webp`. @@ -109,12 +114,19 @@ class ImageEditParamsBase(TypedDict, total=False): base64-encoded images. """ - size: Optional[Literal["256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto"]] + size: Optional[str] """The size of the generated images. - Must be one of `1024x1024`, `1536x1024` (landscape), `1024x1536` (portrait), or - `auto` (default value) for the GPT image models, and one of `256x256`, - `512x512`, or `1024x1024` for `dall-e-2`. + For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are + supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height + must both be divisible by 16 and the requested aspect ratio must be between 1:3 + and 3:1. Resolutions above `2560x1440` are experimental, and the maximum + supported resolution is `3840x2160`. The requested size must also satisfy the + model's current pixel and edge limits. The standard sizes `1024x1024`, + `1536x1024`, and `1024x1536` are supported by the GPT image models; `auto` is + supported for models that allow automatic sizing. For `dall-e-2`, use one of + `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, + `1792x1024`, or `1024x1792`. """ user: str diff --git a/src/openai/types/image_generate_params.py b/src/openai/types/image_generate_params.py index 30a514cffb..4ac573ce61 100644 --- a/src/openai/types/image_generate_params.py +++ b/src/openai/types/image_generate_params.py @@ -21,9 +21,14 @@ class ImageGenerateParamsBase(TypedDict, total=False): background: Optional[Literal["transparent", "opaque", "auto"]] """ Allows to set transparency for the background of the generated image(s). This - parameter is only supported for the GPT image models. Must be one of - `transparent`, `opaque` or `auto` (default value). When `auto` is used, the - model will automatically determine the best background for the image. + parameter is only supported for GPT image models that support transparent + backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value). + When `auto` is used, the model will automatically determine the best background + for the image. + + `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent + backgrounds. Requests with `background` set to `transparent` will return an + error for these models; use `opaque` or `auto` instead. If `transparent`, the output format needs to support transparency, so it should be set to either `png` (default value) or `webp`. @@ -95,15 +100,19 @@ class ImageGenerateParamsBase(TypedDict, total=False): models, which always return base64-encoded images. """ - size: Optional[ - Literal["auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512", "1792x1024", "1024x1792"] - ] + size: Optional[str] """The size of the generated images. - Must be one of `1024x1024`, `1536x1024` (landscape), `1024x1536` (portrait), or - `auto` (default value) for the GPT image models, one of `256x256`, `512x512`, or - `1024x1024` for `dall-e-2`, and one of `1024x1024`, `1792x1024`, or `1024x1792` - for `dall-e-3`. + For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are + supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height + must both be divisible by 16 and the requested aspect ratio must be between 1:3 + and 3:1. Resolutions above `2560x1440` are experimental, and the maximum + supported resolution is `3840x2160`. The requested size must also satisfy the + model's current pixel and edge limits. The standard sizes `1024x1024`, + `1536x1024`, and `1024x1536` are supported by the GPT image models; `auto` is + supported for models that allow automatic sizing. For `dall-e-2`, use one of + `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, + `1792x1024`, or `1024x1792`. """ style: Optional[Literal["vivid", "natural"]] diff --git a/src/openai/types/realtime/translations/__init__.py b/src/openai/types/realtime/translations/__init__.py deleted file mode 100644 index f8ee8b14b1..0000000000 --- a/src/openai/types/realtime/translations/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations diff --git a/src/openai/types/responses/tool.py b/src/openai/types/responses/tool.py index 90929123c6..839ed26ba2 100644 --- a/src/openai/types/responses/tool.py +++ b/src/openai/types/responses/tool.py @@ -248,9 +248,19 @@ class ImageGeneration(BaseModel): """Whether to generate a new image or edit an existing image. Default: `auto`.""" background: Optional[Literal["transparent", "opaque", "auto"]] = None - """Background type for the generated image. - - One of `transparent`, `opaque`, or `auto`. Default: `auto`. + """ + Allows to set transparency for the background of the generated image(s). This + parameter is only supported for GPT image models that support transparent + backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value). + When `auto` is used, the model will automatically determine the best background + for the image. + + `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent + backgrounds. Requests with `background` set to `transparent` will return an + error for these models; use `opaque` or `auto` instead. + + If `transparent`, the output format needs to support transparency, so it should + be set to either `png` (default value) or `webp`. """ input_fidelity: Optional[Literal["high", "low"]] = None @@ -305,10 +315,19 @@ class ImageGeneration(BaseModel): One of `low`, `medium`, `high`, or `auto`. Default: `auto`. """ - size: Optional[Literal["1024x1024", "1024x1536", "1536x1024", "auto"]] = None - """The size of the generated image. - - One of `1024x1024`, `1024x1536`, `1536x1024`, or `auto`. Default: `auto`. + size: Optional[str] = None + """The size of the generated images. + + For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are + supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height + must both be divisible by 16 and the requested aspect ratio must be between 1:3 + and 3:1. Resolutions above `2560x1440` are experimental, and the maximum + supported resolution is `3840x2160`. The requested size must also satisfy the + model's current pixel and edge limits. The standard sizes `1024x1024`, + `1536x1024`, and `1024x1536` are supported by the GPT image models; `auto` is + supported for models that allow automatic sizing. For `dall-e-2`, use one of + `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, + `1792x1024`, or `1024x1792`. """ diff --git a/src/openai/types/responses/tool_param.py b/src/openai/types/responses/tool_param.py index 8e6c6591a9..cdbf5bd1ff 100644 --- a/src/openai/types/responses/tool_param.py +++ b/src/openai/types/responses/tool_param.py @@ -248,9 +248,19 @@ class ImageGeneration(TypedDict, total=False): """Whether to generate a new image or edit an existing image. Default: `auto`.""" background: Literal["transparent", "opaque", "auto"] - """Background type for the generated image. - - One of `transparent`, `opaque`, or `auto`. Default: `auto`. + """ + Allows to set transparency for the background of the generated image(s). This + parameter is only supported for GPT image models that support transparent + backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value). + When `auto` is used, the model will automatically determine the best background + for the image. + + `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent + backgrounds. Requests with `background` set to `transparent` will return an + error for these models; use `opaque` or `auto` instead. + + If `transparent`, the output format needs to support transparency, so it should + be set to either `png` (default value) or `webp`. """ input_fidelity: Optional[Literal["high", "low"]] @@ -304,10 +314,19 @@ class ImageGeneration(TypedDict, total=False): One of `low`, `medium`, `high`, or `auto`. Default: `auto`. """ - size: Literal["1024x1024", "1024x1536", "1536x1024", "auto"] - """The size of the generated image. - - One of `1024x1024`, `1024x1536`, `1536x1024`, or `auto`. Default: `auto`. + size: str + """The size of the generated images. + + For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are + supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height + must both be divisible by 16 and the requested aspect ratio must be between 1:3 + and 3:1. Resolutions above `2560x1440` are experimental, and the maximum + supported resolution is `3840x2160`. The requested size must also satisfy the + model's current pixel and edge limits. The standard sizes `1024x1024`, + `1536x1024`, and `1024x1536` are supported by the GPT image models; `auto` is + supported for models that allow automatic sizing. For `dall-e-2`, use one of + `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, + `1792x1024`, or `1024x1792`. """ From f9d339fcea63feaa1bdf918a4599f2b032c83517 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 6 May 2026 08:58:03 +0000 Subject: [PATCH 08/12] docs(api): update top_logprobs parameter description across chat and responses --- .stats.yml | 4 +-- .../resources/chat/completions/completions.py | 30 +++++++++++-------- src/openai/resources/responses/responses.py | 30 +++++++++++-------- .../usage_audio_speeches_response.py | 6 ++++ .../usage_audio_transcriptions_response.py | 6 ++++ ...sage_code_interpreter_sessions_response.py | 6 ++++ .../usage_completions_response.py | 6 ++++ .../organization/usage_costs_response.py | 6 ++++ .../organization/usage_embeddings_response.py | 6 ++++ .../organization/usage_images_response.py | 6 ++++ .../usage_moderations_response.py | 6 ++++ .../usage_vector_stores_response.py | 6 ++++ .../chat/chat_completion_token_logprob.py | 3 +- .../types/chat/completion_create_params.py | 5 ++-- src/openai/types/responses/response.py | 5 ++-- .../types/responses/response_create_params.py | 5 ++-- .../responses/response_text_delta_event.py | 2 +- .../responses/response_text_done_event.py | 2 +- .../types/responses/responses_client_event.py | 5 ++-- .../responses/responses_client_event_param.py | 5 ++-- 20 files changed, 110 insertions(+), 40 deletions(-) diff --git a/.stats.yml b/.stats.yml index e4dba3d576..201feabd36 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 233 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-5002c7ce1688cf372f6c268507494c5e6396f38db8d85d79029d949b7bb06fe3.yml -openapi_spec_hash: 92713b0825f6b8760836778e6d27e837 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-578515408e7ee6ac115f3768b358ff2cd4f5699cbfb527fe58b19806e7d1f713.yml +openapi_spec_hash: b2df68d6233a18b475590978f5682c04 config_hash: c6cf65d9b19a16ce4313602a2204d48f diff --git a/src/openai/resources/chat/completions/completions.py b/src/openai/resources/chat/completions/completions.py index 7a551e2459..c85ac45cdb 100644 --- a/src/openai/resources/chat/completions/completions.py +++ b/src/openai/resources/chat/completions/completions.py @@ -516,8 +516,9 @@ def create( [custom tools](https://platform.openai.com/docs/guides/function-calling#custom-tools) or [function tools](https://platform.openai.com/docs/guides/function-calling). - top_logprobs: An integer between 0 and 20 specifying the number of most likely tokens to - return at each token position, each with an associated log probability. + top_logprobs: An integer between 0 and 20 specifying the maximum number of most likely tokens + to return at each token position, each with an associated log probability. In + some cases, the number of returned tokens may be fewer than requested. `logprobs` must be set to `true` if this parameter is used. top_p: An alternative to sampling with temperature, called nucleus sampling, where the @@ -822,8 +823,9 @@ def create( [custom tools](https://platform.openai.com/docs/guides/function-calling#custom-tools) or [function tools](https://platform.openai.com/docs/guides/function-calling). - top_logprobs: An integer between 0 and 20 specifying the number of most likely tokens to - return at each token position, each with an associated log probability. + top_logprobs: An integer between 0 and 20 specifying the maximum number of most likely tokens + to return at each token position, each with an associated log probability. In + some cases, the number of returned tokens may be fewer than requested. `logprobs` must be set to `true` if this parameter is used. top_p: An alternative to sampling with temperature, called nucleus sampling, where the @@ -1128,8 +1130,9 @@ def create( [custom tools](https://platform.openai.com/docs/guides/function-calling#custom-tools) or [function tools](https://platform.openai.com/docs/guides/function-calling). - top_logprobs: An integer between 0 and 20 specifying the number of most likely tokens to - return at each token position, each with an associated log probability. + top_logprobs: An integer between 0 and 20 specifying the maximum number of most likely tokens + to return at each token position, each with an associated log probability. In + some cases, the number of returned tokens may be fewer than requested. `logprobs` must be set to `true` if this parameter is used. top_p: An alternative to sampling with temperature, called nucleus sampling, where the @@ -2037,8 +2040,9 @@ async def create( [custom tools](https://platform.openai.com/docs/guides/function-calling#custom-tools) or [function tools](https://platform.openai.com/docs/guides/function-calling). - top_logprobs: An integer between 0 and 20 specifying the number of most likely tokens to - return at each token position, each with an associated log probability. + top_logprobs: An integer between 0 and 20 specifying the maximum number of most likely tokens + to return at each token position, each with an associated log probability. In + some cases, the number of returned tokens may be fewer than requested. `logprobs` must be set to `true` if this parameter is used. top_p: An alternative to sampling with temperature, called nucleus sampling, where the @@ -2343,8 +2347,9 @@ async def create( [custom tools](https://platform.openai.com/docs/guides/function-calling#custom-tools) or [function tools](https://platform.openai.com/docs/guides/function-calling). - top_logprobs: An integer between 0 and 20 specifying the number of most likely tokens to - return at each token position, each with an associated log probability. + top_logprobs: An integer between 0 and 20 specifying the maximum number of most likely tokens + to return at each token position, each with an associated log probability. In + some cases, the number of returned tokens may be fewer than requested. `logprobs` must be set to `true` if this parameter is used. top_p: An alternative to sampling with temperature, called nucleus sampling, where the @@ -2649,8 +2654,9 @@ async def create( [custom tools](https://platform.openai.com/docs/guides/function-calling#custom-tools) or [function tools](https://platform.openai.com/docs/guides/function-calling). - top_logprobs: An integer between 0 and 20 specifying the number of most likely tokens to - return at each token position, each with an associated log probability. + top_logprobs: An integer between 0 and 20 specifying the maximum number of most likely tokens + to return at each token position, each with an associated log probability. In + some cases, the number of returned tokens may be fewer than requested. `logprobs` must be set to `true` if this parameter is used. top_p: An alternative to sampling with temperature, called nucleus sampling, where the diff --git a/src/openai/resources/responses/responses.py b/src/openai/resources/responses/responses.py index c0f9855bcf..4b8bd9af21 100644 --- a/src/openai/resources/responses/responses.py +++ b/src/openai/resources/responses/responses.py @@ -344,8 +344,9 @@ def create( [function calling](https://platform.openai.com/docs/guides/function-calling). You can also use custom tools to call your own code. - top_logprobs: An integer between 0 and 20 specifying the number of most likely tokens to - return at each token position, each with an associated log probability. + top_logprobs: An integer between 0 and 20 specifying the maximum number of most likely tokens + to return at each token position, each with an associated log probability. In + some cases, the number of returned tokens may be fewer than requested. top_p: An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 @@ -593,8 +594,9 @@ def create( [function calling](https://platform.openai.com/docs/guides/function-calling). You can also use custom tools to call your own code. - top_logprobs: An integer between 0 and 20 specifying the number of most likely tokens to - return at each token position, each with an associated log probability. + top_logprobs: An integer between 0 and 20 specifying the maximum number of most likely tokens + to return at each token position, each with an associated log probability. In + some cases, the number of returned tokens may be fewer than requested. top_p: An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 @@ -842,8 +844,9 @@ def create( [function calling](https://platform.openai.com/docs/guides/function-calling). You can also use custom tools to call your own code. - top_logprobs: An integer between 0 and 20 specifying the number of most likely tokens to - return at each token position, each with an associated log probability. + top_logprobs: An integer between 0 and 20 specifying the maximum number of most likely tokens + to return at each token position, each with an associated log probability. In + some cases, the number of returned tokens may be fewer than requested. top_p: An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 @@ -2043,8 +2046,9 @@ async def create( [function calling](https://platform.openai.com/docs/guides/function-calling). You can also use custom tools to call your own code. - top_logprobs: An integer between 0 and 20 specifying the number of most likely tokens to - return at each token position, each with an associated log probability. + top_logprobs: An integer between 0 and 20 specifying the maximum number of most likely tokens + to return at each token position, each with an associated log probability. In + some cases, the number of returned tokens may be fewer than requested. top_p: An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 @@ -2292,8 +2296,9 @@ async def create( [function calling](https://platform.openai.com/docs/guides/function-calling). You can also use custom tools to call your own code. - top_logprobs: An integer between 0 and 20 specifying the number of most likely tokens to - return at each token position, each with an associated log probability. + top_logprobs: An integer between 0 and 20 specifying the maximum number of most likely tokens + to return at each token position, each with an associated log probability. In + some cases, the number of returned tokens may be fewer than requested. top_p: An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 @@ -2541,8 +2546,9 @@ async def create( [function calling](https://platform.openai.com/docs/guides/function-calling). You can also use custom tools to call your own code. - top_logprobs: An integer between 0 and 20 specifying the number of most likely tokens to - return at each token position, each with an associated log probability. + top_logprobs: An integer between 0 and 20 specifying the maximum number of most likely tokens + to return at each token position, each with an associated log probability. In + some cases, the number of returned tokens may be fewer than requested. top_p: An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 diff --git a/src/openai/types/admin/organization/usage_audio_speeches_response.py b/src/openai/types/admin/organization/usage_audio_speeches_response.py index 90e17c89b0..e5fed36b03 100644 --- a/src/openai/types/admin/organization/usage_audio_speeches_response.py +++ b/src/openai/types/admin/organization/usage_audio_speeches_response.py @@ -353,6 +353,12 @@ class DataResultOrganizationCostsResult(BaseModel): costs result. """ + quantity: Optional[float] = None + """ + When `group_by=line_item`, this field provides the quantity of the grouped costs + result. + """ + DataResult: TypeAlias = Annotated[ Union[ diff --git a/src/openai/types/admin/organization/usage_audio_transcriptions_response.py b/src/openai/types/admin/organization/usage_audio_transcriptions_response.py index abd7c3fb90..c5b77f34e1 100644 --- a/src/openai/types/admin/organization/usage_audio_transcriptions_response.py +++ b/src/openai/types/admin/organization/usage_audio_transcriptions_response.py @@ -353,6 +353,12 @@ class DataResultOrganizationCostsResult(BaseModel): costs result. """ + quantity: Optional[float] = None + """ + When `group_by=line_item`, this field provides the quantity of the grouped costs + result. + """ + DataResult: TypeAlias = Annotated[ Union[ diff --git a/src/openai/types/admin/organization/usage_code_interpreter_sessions_response.py b/src/openai/types/admin/organization/usage_code_interpreter_sessions_response.py index 0cd6c2693c..aafda6f113 100644 --- a/src/openai/types/admin/organization/usage_code_interpreter_sessions_response.py +++ b/src/openai/types/admin/organization/usage_code_interpreter_sessions_response.py @@ -353,6 +353,12 @@ class DataResultOrganizationCostsResult(BaseModel): costs result. """ + quantity: Optional[float] = None + """ + When `group_by=line_item`, this field provides the quantity of the grouped costs + result. + """ + DataResult: TypeAlias = Annotated[ Union[ diff --git a/src/openai/types/admin/organization/usage_completions_response.py b/src/openai/types/admin/organization/usage_completions_response.py index d37634bca5..f179149995 100644 --- a/src/openai/types/admin/organization/usage_completions_response.py +++ b/src/openai/types/admin/organization/usage_completions_response.py @@ -353,6 +353,12 @@ class DataResultOrganizationCostsResult(BaseModel): costs result. """ + quantity: Optional[float] = None + """ + When `group_by=line_item`, this field provides the quantity of the grouped costs + result. + """ + DataResult: TypeAlias = Annotated[ Union[ diff --git a/src/openai/types/admin/organization/usage_costs_response.py b/src/openai/types/admin/organization/usage_costs_response.py index 68c1f639c1..fd1d344e26 100644 --- a/src/openai/types/admin/organization/usage_costs_response.py +++ b/src/openai/types/admin/organization/usage_costs_response.py @@ -353,6 +353,12 @@ class DataResultOrganizationCostsResult(BaseModel): costs result. """ + quantity: Optional[float] = None + """ + When `group_by=line_item`, this field provides the quantity of the grouped costs + result. + """ + DataResult: TypeAlias = Annotated[ Union[ diff --git a/src/openai/types/admin/organization/usage_embeddings_response.py b/src/openai/types/admin/organization/usage_embeddings_response.py index 905c8f5c6e..adbc389d89 100644 --- a/src/openai/types/admin/organization/usage_embeddings_response.py +++ b/src/openai/types/admin/organization/usage_embeddings_response.py @@ -353,6 +353,12 @@ class DataResultOrganizationCostsResult(BaseModel): costs result. """ + quantity: Optional[float] = None + """ + When `group_by=line_item`, this field provides the quantity of the grouped costs + result. + """ + DataResult: TypeAlias = Annotated[ Union[ diff --git a/src/openai/types/admin/organization/usage_images_response.py b/src/openai/types/admin/organization/usage_images_response.py index 55f8d80096..7c6a096c98 100644 --- a/src/openai/types/admin/organization/usage_images_response.py +++ b/src/openai/types/admin/organization/usage_images_response.py @@ -353,6 +353,12 @@ class DataResultOrganizationCostsResult(BaseModel): costs result. """ + quantity: Optional[float] = None + """ + When `group_by=line_item`, this field provides the quantity of the grouped costs + result. + """ + DataResult: TypeAlias = Annotated[ Union[ diff --git a/src/openai/types/admin/organization/usage_moderations_response.py b/src/openai/types/admin/organization/usage_moderations_response.py index 87919b50a9..5e40ef1164 100644 --- a/src/openai/types/admin/organization/usage_moderations_response.py +++ b/src/openai/types/admin/organization/usage_moderations_response.py @@ -353,6 +353,12 @@ class DataResultOrganizationCostsResult(BaseModel): costs result. """ + quantity: Optional[float] = None + """ + When `group_by=line_item`, this field provides the quantity of the grouped costs + result. + """ + DataResult: TypeAlias = Annotated[ Union[ diff --git a/src/openai/types/admin/organization/usage_vector_stores_response.py b/src/openai/types/admin/organization/usage_vector_stores_response.py index d3cd853653..089aa23119 100644 --- a/src/openai/types/admin/organization/usage_vector_stores_response.py +++ b/src/openai/types/admin/organization/usage_vector_stores_response.py @@ -353,6 +353,12 @@ class DataResultOrganizationCostsResult(BaseModel): costs result. """ + quantity: Optional[float] = None + """ + When `group_by=line_item`, this field provides the quantity of the grouped costs + result. + """ + DataResult: TypeAlias = Annotated[ Union[ diff --git a/src/openai/types/chat/chat_completion_token_logprob.py b/src/openai/types/chat/chat_completion_token_logprob.py index c69e258910..4ce582366a 100644 --- a/src/openai/types/chat/chat_completion_token_logprob.py +++ b/src/openai/types/chat/chat_completion_token_logprob.py @@ -52,6 +52,5 @@ class ChatCompletionTokenLogprob(BaseModel): """List of the most likely tokens and their log probability, at this token position. - In rare cases, there may be fewer than the number of requested `top_logprobs` - returned. + The number of entries may be fewer than the requested `top_logprobs`. """ diff --git a/src/openai/types/chat/completion_create_params.py b/src/openai/types/chat/completion_create_params.py index 0379ee0865..3c541b96b4 100644 --- a/src/openai/types/chat/completion_create_params.py +++ b/src/openai/types/chat/completion_create_params.py @@ -311,8 +311,9 @@ class CompletionCreateParamsBase(TypedDict, total=False): top_logprobs: Optional[int] """ - An integer between 0 and 20 specifying the number of most likely tokens to - return at each token position, each with an associated log probability. + An integer between 0 and 20 specifying the maximum number of most likely tokens + to return at each token position, each with an associated log probability. In + some cases, the number of returned tokens may be fewer than requested. `logprobs` must be set to `true` if this parameter is used. """ diff --git a/src/openai/types/responses/response.py b/src/openai/types/responses/response.py index 0d2491ea7c..dac3e09a89 100644 --- a/src/openai/types/responses/response.py +++ b/src/openai/types/responses/response.py @@ -276,8 +276,9 @@ class Response(BaseModel): top_logprobs: Optional[int] = None """ - An integer between 0 and 20 specifying the number of most likely tokens to - return at each token position, each with an associated log probability. + An integer between 0 and 20 specifying the maximum number of most likely tokens + to return at each token position, each with an associated log probability. In + some cases, the number of returned tokens may be fewer than requested. """ truncation: Optional[Literal["auto", "disabled"]] = None diff --git a/src/openai/types/responses/response_create_params.py b/src/openai/types/responses/response_create_params.py index a04495f40a..5f9b948ae9 100644 --- a/src/openai/types/responses/response_create_params.py +++ b/src/openai/types/responses/response_create_params.py @@ -251,8 +251,9 @@ class ResponseCreateParamsBase(TypedDict, total=False): top_logprobs: Optional[int] """ - An integer between 0 and 20 specifying the number of most likely tokens to - return at each token position, each with an associated log probability. + An integer between 0 and 20 specifying the maximum number of most likely tokens + to return at each token position, each with an associated log probability. In + some cases, the number of returned tokens may be fewer than requested. """ top_p: Optional[float] diff --git a/src/openai/types/responses/response_text_delta_event.py b/src/openai/types/responses/response_text_delta_event.py index 4f802abfd2..9b0b83de59 100644 --- a/src/openai/types/responses/response_text_delta_event.py +++ b/src/openai/types/responses/response_text_delta_event.py @@ -30,7 +30,7 @@ class Logprob(BaseModel): """The log probability of this token.""" top_logprobs: Optional[List[LogprobTopLogprob]] = None - """The log probability of the top 20 most likely tokens.""" + """The log probabilities of up to 20 of the most likely tokens.""" class ResponseTextDeltaEvent(BaseModel): diff --git a/src/openai/types/responses/response_text_done_event.py b/src/openai/types/responses/response_text_done_event.py index 75bd479870..3a202af67a 100644 --- a/src/openai/types/responses/response_text_done_event.py +++ b/src/openai/types/responses/response_text_done_event.py @@ -30,7 +30,7 @@ class Logprob(BaseModel): """The log probability of this token.""" top_logprobs: Optional[List[LogprobTopLogprob]] = None - """The log probability of the top 20 most likely tokens.""" + """The log probabilities of up to 20 of the most likely tokens.""" class ResponseTextDoneEvent(BaseModel): diff --git a/src/openai/types/responses/responses_client_event.py b/src/openai/types/responses/responses_client_event.py index 5f9e73c61f..0a5dcb4ddd 100644 --- a/src/openai/types/responses/responses_client_event.py +++ b/src/openai/types/responses/responses_client_event.py @@ -293,8 +293,9 @@ class ResponsesClientEvent(BaseModel): top_logprobs: Optional[int] = None """ - An integer between 0 and 20 specifying the number of most likely tokens to - return at each token position, each with an associated log probability. + An integer between 0 and 20 specifying the maximum number of most likely tokens + to return at each token position, each with an associated log probability. In + some cases, the number of returned tokens may be fewer than requested. """ top_p: Optional[float] = None diff --git a/src/openai/types/responses/responses_client_event_param.py b/src/openai/types/responses/responses_client_event_param.py index 249c812116..59d8f205ae 100644 --- a/src/openai/types/responses/responses_client_event_param.py +++ b/src/openai/types/responses/responses_client_event_param.py @@ -294,8 +294,9 @@ class ResponsesClientEventParam(TypedDict, total=False): top_logprobs: Optional[int] """ - An integer between 0 and 20 specifying the number of most likely tokens to - return at each token position, each with an associated log probability. + An integer between 0 and 20 specifying the maximum number of most likely tokens + to return at each token position, each with an associated log probability. In + some cases, the number of returned tokens may be fewer than requested. """ top_p: Optional[float] From a3b182d6d2c2e6fe1d53ca7550b2d43e0f8b2cd3 Mon Sep 17 00:00:00 2001 From: Alex Chang Date: Wed, 6 May 2026 10:06:24 -0400 Subject: [PATCH 09/12] chore: rename legacy python cli entrypoint --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7fbf3bd49b..38314d2869 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,7 @@ Homepage = "https://github.com/openai/openai-python" Repository = "https://github.com/openai/openai-python" [project.scripts] -openai = "openai.cli:main" +openai-python = "openai.cli:main" [project.optional-dependencies] aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.9"] From 32f36e447d02c3124af8ab48fcc3537df2fed66e Mon Sep 17 00:00:00 2001 From: Alex Chang Date: Wed, 6 May 2026 10:43:49 -0400 Subject: [PATCH 10/12] chore: remove legacy python cli --- pyproject.toml | 3 - src/openai/__main__.py | 3 - src/openai/cli/__init__.py | 1 - src/openai/cli/_api/__init__.py | 1 - src/openai/cli/_api/_main.py | 17 -- src/openai/cli/_api/audio.py | 108 --------- src/openai/cli/_api/chat/__init__.py | 13 -- src/openai/cli/_api/chat/completions.py | 160 -------------- src/openai/cli/_api/completions.py | 173 --------------- src/openai/cli/_api/files.py | 80 ------- src/openai/cli/_api/fine_tuning/__init__.py | 13 -- src/openai/cli/_api/fine_tuning/jobs.py | 170 -------------- src/openai/cli/_api/image.py | 139 ------------ src/openai/cli/_api/models.py | 45 ---- src/openai/cli/_cli.py | 233 -------------------- src/openai/cli/_errors.py | 21 -- src/openai/cli/_models.py | 17 -- src/openai/cli/_progress.py | 59 ----- src/openai/cli/_tools/__init__.py | 1 - src/openai/cli/_tools/_main.py | 17 -- src/openai/cli/_tools/fine_tunes.py | 63 ------ src/openai/cli/_tools/migrate.py | 164 -------------- src/openai/cli/_utils.py | 45 ---- 23 files changed, 1546 deletions(-) delete mode 100644 src/openai/__main__.py delete mode 100644 src/openai/cli/__init__.py delete mode 100644 src/openai/cli/_api/__init__.py delete mode 100644 src/openai/cli/_api/_main.py delete mode 100644 src/openai/cli/_api/audio.py delete mode 100644 src/openai/cli/_api/chat/__init__.py delete mode 100644 src/openai/cli/_api/chat/completions.py delete mode 100644 src/openai/cli/_api/completions.py delete mode 100644 src/openai/cli/_api/files.py delete mode 100644 src/openai/cli/_api/fine_tuning/__init__.py delete mode 100644 src/openai/cli/_api/fine_tuning/jobs.py delete mode 100644 src/openai/cli/_api/image.py delete mode 100644 src/openai/cli/_api/models.py delete mode 100644 src/openai/cli/_cli.py delete mode 100644 src/openai/cli/_errors.py delete mode 100644 src/openai/cli/_models.py delete mode 100644 src/openai/cli/_progress.py delete mode 100644 src/openai/cli/_tools/__init__.py delete mode 100644 src/openai/cli/_tools/_main.py delete mode 100644 src/openai/cli/_tools/fine_tunes.py delete mode 100644 src/openai/cli/_tools/migrate.py delete mode 100644 src/openai/cli/_utils.py diff --git a/pyproject.toml b/pyproject.toml index 38314d2869..1f7c145039 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,9 +42,6 @@ classifiers = [ Homepage = "https://github.com/openai/openai-python" Repository = "https://github.com/openai/openai-python" -[project.scripts] -openai-python = "openai.cli:main" - [project.optional-dependencies] aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.9"] realtime = ["websockets >= 13, < 16"] diff --git a/src/openai/__main__.py b/src/openai/__main__.py deleted file mode 100644 index 4e28416e10..0000000000 --- a/src/openai/__main__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .cli import main - -main() diff --git a/src/openai/cli/__init__.py b/src/openai/cli/__init__.py deleted file mode 100644 index d453d5e179..0000000000 --- a/src/openai/cli/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from ._cli import main as main diff --git a/src/openai/cli/_api/__init__.py b/src/openai/cli/_api/__init__.py deleted file mode 100644 index 56a0260a6d..0000000000 --- a/src/openai/cli/_api/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from ._main import register_commands as register_commands diff --git a/src/openai/cli/_api/_main.py b/src/openai/cli/_api/_main.py deleted file mode 100644 index b04a3e52a4..0000000000 --- a/src/openai/cli/_api/_main.py +++ /dev/null @@ -1,17 +0,0 @@ -from __future__ import annotations - -from argparse import ArgumentParser - -from . import chat, audio, files, image, models, completions, fine_tuning - - -def register_commands(parser: ArgumentParser) -> None: - subparsers = parser.add_subparsers(help="All API subcommands") - - chat.register(subparsers) - image.register(subparsers) - audio.register(subparsers) - files.register(subparsers) - models.register(subparsers) - completions.register(subparsers) - fine_tuning.register(subparsers) diff --git a/src/openai/cli/_api/audio.py b/src/openai/cli/_api/audio.py deleted file mode 100644 index e7c3734e75..0000000000 --- a/src/openai/cli/_api/audio.py +++ /dev/null @@ -1,108 +0,0 @@ -from __future__ import annotations - -import sys -from typing import TYPE_CHECKING, Any, Optional, cast -from argparse import ArgumentParser - -from .._utils import get_client, print_model -from ..._types import omit -from .._models import BaseModel -from .._progress import BufferReader -from ...types.audio import Transcription - -if TYPE_CHECKING: - from argparse import _SubParsersAction - - -def register(subparser: _SubParsersAction[ArgumentParser]) -> None: - # transcriptions - sub = subparser.add_parser("audio.transcriptions.create") - - # Required - sub.add_argument("-m", "--model", type=str, default="whisper-1") - sub.add_argument("-f", "--file", type=str, required=True) - # Optional - sub.add_argument("--response-format", type=str) - sub.add_argument("--language", type=str) - sub.add_argument("-t", "--temperature", type=float) - sub.add_argument("--prompt", type=str) - sub.set_defaults(func=CLIAudio.transcribe, args_model=CLITranscribeArgs) - - # translations - sub = subparser.add_parser("audio.translations.create") - - # Required - sub.add_argument("-f", "--file", type=str, required=True) - # Optional - sub.add_argument("-m", "--model", type=str, default="whisper-1") - sub.add_argument("--response-format", type=str) - # TODO: doesn't seem to be supported by the API - # sub.add_argument("--language", type=str) - sub.add_argument("-t", "--temperature", type=float) - sub.add_argument("--prompt", type=str) - sub.set_defaults(func=CLIAudio.translate, args_model=CLITranslationArgs) - - -class CLITranscribeArgs(BaseModel): - model: str - file: str - response_format: Optional[str] = None - language: Optional[str] = None - temperature: Optional[float] = None - prompt: Optional[str] = None - - -class CLITranslationArgs(BaseModel): - model: str - file: str - response_format: Optional[str] = None - language: Optional[str] = None - temperature: Optional[float] = None - prompt: Optional[str] = None - - -class CLIAudio: - @staticmethod - def transcribe(args: CLITranscribeArgs) -> None: - with open(args.file, "rb") as file_reader: - buffer_reader = BufferReader(file_reader.read(), desc="Upload progress") - - model = cast( - "Transcription | str", - get_client().audio.transcriptions.create( - file=(args.file, buffer_reader), - model=args.model, - language=args.language or omit, - temperature=args.temperature or omit, - prompt=args.prompt or omit, - # casts required because the API is typed for enums - # but we don't want to validate that here for forwards-compat - response_format=cast(Any, args.response_format), - ), - ) - if isinstance(model, str): - sys.stdout.write(model + "\n") - else: - print_model(model) - - @staticmethod - def translate(args: CLITranslationArgs) -> None: - with open(args.file, "rb") as file_reader: - buffer_reader = BufferReader(file_reader.read(), desc="Upload progress") - - model = cast( - "Transcription | str", - get_client().audio.translations.create( - file=(args.file, buffer_reader), - model=args.model, - temperature=args.temperature or omit, - prompt=args.prompt or omit, - # casts required because the API is typed for enums - # but we don't want to validate that here for forwards-compat - response_format=cast(Any, args.response_format), - ), - ) - if isinstance(model, str): - sys.stdout.write(model + "\n") - else: - print_model(model) diff --git a/src/openai/cli/_api/chat/__init__.py b/src/openai/cli/_api/chat/__init__.py deleted file mode 100644 index 87d971630a..0000000000 --- a/src/openai/cli/_api/chat/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -from __future__ import annotations - -from typing import TYPE_CHECKING -from argparse import ArgumentParser - -from . import completions - -if TYPE_CHECKING: - from argparse import _SubParsersAction - - -def register(subparser: _SubParsersAction[ArgumentParser]) -> None: - completions.register(subparser) diff --git a/src/openai/cli/_api/chat/completions.py b/src/openai/cli/_api/chat/completions.py deleted file mode 100644 index 344eeff37c..0000000000 --- a/src/openai/cli/_api/chat/completions.py +++ /dev/null @@ -1,160 +0,0 @@ -from __future__ import annotations - -import sys -from typing import TYPE_CHECKING, List, Optional, cast -from argparse import ArgumentParser -from typing_extensions import Literal, NamedTuple - -from ..._utils import get_client -from ..._models import BaseModel -from ...._streaming import Stream -from ....types.chat import ( - ChatCompletionRole, - ChatCompletionChunk, - CompletionCreateParams, -) -from ....types.chat.completion_create_params import ( - CompletionCreateParamsStreaming, - CompletionCreateParamsNonStreaming, -) - -if TYPE_CHECKING: - from argparse import _SubParsersAction - - -def register(subparser: _SubParsersAction[ArgumentParser]) -> None: - sub = subparser.add_parser("chat.completions.create") - - sub._action_groups.pop() - req = sub.add_argument_group("required arguments") - opt = sub.add_argument_group("optional arguments") - - req.add_argument( - "-g", - "--message", - action="append", - nargs=2, - metavar=("ROLE", "CONTENT"), - help="A message in `{role} {content}` format. Use this argument multiple times to add multiple messages.", - required=True, - ) - req.add_argument( - "-m", - "--model", - help="The model to use.", - required=True, - ) - - opt.add_argument( - "-n", - "--n", - help="How many completions to generate for the conversation.", - type=int, - ) - opt.add_argument("-M", "--max-tokens", help="The maximum number of tokens to generate.", type=int) - opt.add_argument( - "-t", - "--temperature", - help="""What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. - -Mutually exclusive with `top_p`.""", - type=float, - ) - opt.add_argument( - "-P", - "--top_p", - help="""An alternative to sampling with temperature, called nucleus sampling, where the considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10%% probability mass are considered. - - Mutually exclusive with `temperature`.""", - type=float, - ) - opt.add_argument( - "--stop", - help="A stop sequence at which to stop generating tokens for the message.", - ) - opt.add_argument("--stream", help="Stream messages as they're ready.", action="store_true") - sub.set_defaults(func=CLIChatCompletion.create, args_model=CLIChatCompletionCreateArgs) - - -class CLIMessage(NamedTuple): - role: ChatCompletionRole - content: str - - -class CLIChatCompletionCreateArgs(BaseModel): - message: List[CLIMessage] - model: str - n: Optional[int] = None - max_tokens: Optional[int] = None - temperature: Optional[float] = None - top_p: Optional[float] = None - stop: Optional[str] = None - stream: bool = False - - -class CLIChatCompletion: - @staticmethod - def create(args: CLIChatCompletionCreateArgs) -> None: - params: CompletionCreateParams = { - "model": args.model, - "messages": [ - {"role": cast(Literal["user"], message.role), "content": message.content} for message in args.message - ], - # type checkers are not good at inferring union types so we have to set stream afterwards - "stream": False, - } - if args.temperature is not None: - params["temperature"] = args.temperature - if args.stop is not None: - params["stop"] = args.stop - if args.top_p is not None: - params["top_p"] = args.top_p - if args.n is not None: - params["n"] = args.n - if args.stream: - params["stream"] = args.stream # type: ignore - if args.max_tokens is not None: - params["max_tokens"] = args.max_tokens - - if args.stream: - return CLIChatCompletion._stream_create(cast(CompletionCreateParamsStreaming, params)) - - return CLIChatCompletion._create(cast(CompletionCreateParamsNonStreaming, params)) - - @staticmethod - def _create(params: CompletionCreateParamsNonStreaming) -> None: - completion = get_client().chat.completions.create(**params) - should_print_header = len(completion.choices) > 1 - for choice in completion.choices: - if should_print_header: - sys.stdout.write("===== Chat Completion {} =====\n".format(choice.index)) - - content = choice.message.content if choice.message.content is not None else "None" - sys.stdout.write(content) - - if should_print_header or not content.endswith("\n"): - sys.stdout.write("\n") - - sys.stdout.flush() - - @staticmethod - def _stream_create(params: CompletionCreateParamsStreaming) -> None: - # cast is required for mypy - stream = cast( # pyright: ignore[reportUnnecessaryCast] - Stream[ChatCompletionChunk], get_client().chat.completions.create(**params) - ) - for chunk in stream: - should_print_header = len(chunk.choices) > 1 - for choice in chunk.choices: - if should_print_header: - sys.stdout.write("===== Chat Completion {} =====\n".format(choice.index)) - - content = choice.delta.content or "" - sys.stdout.write(content) - - if should_print_header: - sys.stdout.write("\n") - - sys.stdout.flush() - - sys.stdout.write("\n") diff --git a/src/openai/cli/_api/completions.py b/src/openai/cli/_api/completions.py deleted file mode 100644 index b22ecde9ef..0000000000 --- a/src/openai/cli/_api/completions.py +++ /dev/null @@ -1,173 +0,0 @@ -from __future__ import annotations - -import sys -from typing import TYPE_CHECKING, Optional, cast -from argparse import ArgumentParser -from functools import partial - -from openai.types.completion import Completion - -from .._utils import get_client -from ..._types import Omittable, omit -from ..._utils import is_given -from .._errors import CLIError -from .._models import BaseModel -from ..._streaming import Stream - -if TYPE_CHECKING: - from argparse import _SubParsersAction - - -def register(subparser: _SubParsersAction[ArgumentParser]) -> None: - sub = subparser.add_parser("completions.create") - - # Required - sub.add_argument( - "-m", - "--model", - help="The model to use", - required=True, - ) - - # Optional - sub.add_argument("-p", "--prompt", help="An optional prompt to complete from") - sub.add_argument("--stream", help="Stream tokens as they're ready.", action="store_true") - sub.add_argument("-M", "--max-tokens", help="The maximum number of tokens to generate", type=int) - sub.add_argument( - "-t", - "--temperature", - help="""What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. - -Mutually exclusive with `top_p`.""", - type=float, - ) - sub.add_argument( - "-P", - "--top_p", - help="""An alternative to sampling with temperature, called nucleus sampling, where the considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10%% probability mass are considered. - - Mutually exclusive with `temperature`.""", - type=float, - ) - sub.add_argument( - "-n", - "--n", - help="How many sub-completions to generate for each prompt.", - type=int, - ) - sub.add_argument( - "--logprobs", - help="Include the log probabilities on the `logprobs` most likely tokens, as well the chosen tokens. So for example, if `logprobs` is 10, the API will return a list of the 10 most likely tokens. If `logprobs` is 0, only the chosen tokens will have logprobs returned.", - type=int, - ) - sub.add_argument( - "--best_of", - help="Generates `best_of` completions server-side and returns the 'best' (the one with the highest log probability per token). Results cannot be streamed.", - type=int, - ) - sub.add_argument( - "--echo", - help="Echo back the prompt in addition to the completion", - action="store_true", - ) - sub.add_argument( - "--frequency_penalty", - help="Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.", - type=float, - ) - sub.add_argument( - "--presence_penalty", - help="Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.", - type=float, - ) - sub.add_argument("--suffix", help="The suffix that comes after a completion of inserted text.") - sub.add_argument("--stop", help="A stop sequence at which to stop generating tokens.") - sub.add_argument( - "--user", - help="A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.", - ) - # TODO: add support for logit_bias - sub.set_defaults(func=CLICompletions.create, args_model=CLICompletionCreateArgs) - - -class CLICompletionCreateArgs(BaseModel): - model: str - stream: bool = False - - prompt: Optional[str] = None - n: Omittable[int] = omit - stop: Omittable[str] = omit - user: Omittable[str] = omit - echo: Omittable[bool] = omit - suffix: Omittable[str] = omit - best_of: Omittable[int] = omit - top_p: Omittable[float] = omit - logprobs: Omittable[int] = omit - max_tokens: Omittable[int] = omit - temperature: Omittable[float] = omit - presence_penalty: Omittable[float] = omit - frequency_penalty: Omittable[float] = omit - - -class CLICompletions: - @staticmethod - def create(args: CLICompletionCreateArgs) -> None: - if is_given(args.n) and args.n > 1 and args.stream: - raise CLIError("Can't stream completions with n>1 with the current CLI") - - make_request = partial( - get_client().completions.create, - n=args.n, - echo=args.echo, - stop=args.stop, - user=args.user, - model=args.model, - top_p=args.top_p, - prompt=args.prompt, - suffix=args.suffix, - best_of=args.best_of, - logprobs=args.logprobs, - max_tokens=args.max_tokens, - temperature=args.temperature, - presence_penalty=args.presence_penalty, - frequency_penalty=args.frequency_penalty, - ) - - if args.stream: - return CLICompletions._stream_create( - # mypy doesn't understand the `partial` function but pyright does - cast(Stream[Completion], make_request(stream=True)) # pyright: ignore[reportUnnecessaryCast] - ) - - return CLICompletions._create(make_request()) - - @staticmethod - def _create(completion: Completion) -> None: - should_print_header = len(completion.choices) > 1 - for choice in completion.choices: - if should_print_header: - sys.stdout.write("===== Completion {} =====\n".format(choice.index)) - - sys.stdout.write(choice.text) - - if should_print_header or not choice.text.endswith("\n"): - sys.stdout.write("\n") - - sys.stdout.flush() - - @staticmethod - def _stream_create(stream: Stream[Completion]) -> None: - for completion in stream: - should_print_header = len(completion.choices) > 1 - for choice in sorted(completion.choices, key=lambda c: c.index): - if should_print_header: - sys.stdout.write("===== Chat Completion {} =====\n".format(choice.index)) - - sys.stdout.write(choice.text) - - if should_print_header: - sys.stdout.write("\n") - - sys.stdout.flush() - - sys.stdout.write("\n") diff --git a/src/openai/cli/_api/files.py b/src/openai/cli/_api/files.py deleted file mode 100644 index 5f3631b284..0000000000 --- a/src/openai/cli/_api/files.py +++ /dev/null @@ -1,80 +0,0 @@ -from __future__ import annotations - -from typing import TYPE_CHECKING, Any, cast -from argparse import ArgumentParser - -from .._utils import get_client, print_model -from .._models import BaseModel -from .._progress import BufferReader - -if TYPE_CHECKING: - from argparse import _SubParsersAction - - -def register(subparser: _SubParsersAction[ArgumentParser]) -> None: - sub = subparser.add_parser("files.create") - - sub.add_argument( - "-f", - "--file", - required=True, - help="File to upload", - ) - sub.add_argument( - "-p", - "--purpose", - help="Why are you uploading this file? (see https://platform.openai.com/docs/api-reference/ for purposes)", - required=True, - ) - sub.set_defaults(func=CLIFile.create, args_model=CLIFileCreateArgs) - - sub = subparser.add_parser("files.retrieve") - sub.add_argument("-i", "--id", required=True, help="The files ID") - sub.set_defaults(func=CLIFile.get, args_model=CLIFileCreateArgs) - - sub = subparser.add_parser("files.delete") - sub.add_argument("-i", "--id", required=True, help="The files ID") - sub.set_defaults(func=CLIFile.delete, args_model=CLIFileCreateArgs) - - sub = subparser.add_parser("files.list") - sub.set_defaults(func=CLIFile.list) - - -class CLIFileIDArgs(BaseModel): - id: str - - -class CLIFileCreateArgs(BaseModel): - file: str - purpose: str - - -class CLIFile: - @staticmethod - def create(args: CLIFileCreateArgs) -> None: - with open(args.file, "rb") as file_reader: - buffer_reader = BufferReader(file_reader.read(), desc="Upload progress") - - file = get_client().files.create( - file=(args.file, buffer_reader), - # casts required because the API is typed for enums - # but we don't want to validate that here for forwards-compat - purpose=cast(Any, args.purpose), - ) - print_model(file) - - @staticmethod - def get(args: CLIFileIDArgs) -> None: - file = get_client().files.retrieve(file_id=args.id) - print_model(file) - - @staticmethod - def delete(args: CLIFileIDArgs) -> None: - file = get_client().files.delete(file_id=args.id) - print_model(file) - - @staticmethod - def list() -> None: - files = get_client().files.list() - for file in files: - print_model(file) diff --git a/src/openai/cli/_api/fine_tuning/__init__.py b/src/openai/cli/_api/fine_tuning/__init__.py deleted file mode 100644 index 11a2dfccbd..0000000000 --- a/src/openai/cli/_api/fine_tuning/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -from __future__ import annotations - -from typing import TYPE_CHECKING -from argparse import ArgumentParser - -from . import jobs - -if TYPE_CHECKING: - from argparse import _SubParsersAction - - -def register(subparser: _SubParsersAction[ArgumentParser]) -> None: - jobs.register(subparser) diff --git a/src/openai/cli/_api/fine_tuning/jobs.py b/src/openai/cli/_api/fine_tuning/jobs.py deleted file mode 100644 index a4e429108a..0000000000 --- a/src/openai/cli/_api/fine_tuning/jobs.py +++ /dev/null @@ -1,170 +0,0 @@ -from __future__ import annotations - -import json -from typing import TYPE_CHECKING -from argparse import ArgumentParser - -from ..._utils import get_client, print_model -from ...._types import Omittable, omit -from ...._utils import is_given -from ..._models import BaseModel -from ....pagination import SyncCursorPage -from ....types.fine_tuning import ( - FineTuningJob, - FineTuningJobEvent, -) - -if TYPE_CHECKING: - from argparse import _SubParsersAction - - -def register(subparser: _SubParsersAction[ArgumentParser]) -> None: - sub = subparser.add_parser("fine_tuning.jobs.create") - sub.add_argument( - "-m", - "--model", - help="The model to fine-tune.", - required=True, - ) - sub.add_argument( - "-F", - "--training-file", - help="The training file to fine-tune the model on.", - required=True, - ) - sub.add_argument( - "-H", - "--hyperparameters", - help="JSON string of hyperparameters to use for fine-tuning.", - type=str, - ) - sub.add_argument( - "-s", - "--suffix", - help="A suffix to add to the fine-tuned model name.", - ) - sub.add_argument( - "-V", - "--validation-file", - help="The validation file to use for fine-tuning.", - ) - sub.set_defaults(func=CLIFineTuningJobs.create, args_model=CLIFineTuningJobsCreateArgs) - - sub = subparser.add_parser("fine_tuning.jobs.retrieve") - sub.add_argument( - "-i", - "--id", - help="The ID of the fine-tuning job to retrieve.", - required=True, - ) - sub.set_defaults(func=CLIFineTuningJobs.retrieve, args_model=CLIFineTuningJobsRetrieveArgs) - - sub = subparser.add_parser("fine_tuning.jobs.list") - sub.add_argument( - "-a", - "--after", - help="Identifier for the last job from the previous pagination request. If provided, only jobs created after this job will be returned.", - ) - sub.add_argument( - "-l", - "--limit", - help="Number of fine-tuning jobs to retrieve.", - type=int, - ) - sub.set_defaults(func=CLIFineTuningJobs.list, args_model=CLIFineTuningJobsListArgs) - - sub = subparser.add_parser("fine_tuning.jobs.cancel") - sub.add_argument( - "-i", - "--id", - help="The ID of the fine-tuning job to cancel.", - required=True, - ) - sub.set_defaults(func=CLIFineTuningJobs.cancel, args_model=CLIFineTuningJobsCancelArgs) - - sub = subparser.add_parser("fine_tuning.jobs.list_events") - sub.add_argument( - "-i", - "--id", - help="The ID of the fine-tuning job to list events for.", - required=True, - ) - sub.add_argument( - "-a", - "--after", - help="Identifier for the last event from the previous pagination request. If provided, only events created after this event will be returned.", - ) - sub.add_argument( - "-l", - "--limit", - help="Number of fine-tuning job events to retrieve.", - type=int, - ) - sub.set_defaults(func=CLIFineTuningJobs.list_events, args_model=CLIFineTuningJobsListEventsArgs) - - -class CLIFineTuningJobsCreateArgs(BaseModel): - model: str - training_file: str - hyperparameters: Omittable[str] = omit - suffix: Omittable[str] = omit - validation_file: Omittable[str] = omit - - -class CLIFineTuningJobsRetrieveArgs(BaseModel): - id: str - - -class CLIFineTuningJobsListArgs(BaseModel): - after: Omittable[str] = omit - limit: Omittable[int] = omit - - -class CLIFineTuningJobsCancelArgs(BaseModel): - id: str - - -class CLIFineTuningJobsListEventsArgs(BaseModel): - id: str - after: Omittable[str] = omit - limit: Omittable[int] = omit - - -class CLIFineTuningJobs: - @staticmethod - def create(args: CLIFineTuningJobsCreateArgs) -> None: - hyperparameters = json.loads(str(args.hyperparameters)) if is_given(args.hyperparameters) else omit - fine_tuning_job: FineTuningJob = get_client().fine_tuning.jobs.create( - model=args.model, - training_file=args.training_file, - hyperparameters=hyperparameters, - suffix=args.suffix, - validation_file=args.validation_file, - ) - print_model(fine_tuning_job) - - @staticmethod - def retrieve(args: CLIFineTuningJobsRetrieveArgs) -> None: - fine_tuning_job: FineTuningJob = get_client().fine_tuning.jobs.retrieve(fine_tuning_job_id=args.id) - print_model(fine_tuning_job) - - @staticmethod - def list(args: CLIFineTuningJobsListArgs) -> None: - fine_tuning_jobs: SyncCursorPage[FineTuningJob] = get_client().fine_tuning.jobs.list( - after=args.after or omit, limit=args.limit or omit - ) - print_model(fine_tuning_jobs) - - @staticmethod - def cancel(args: CLIFineTuningJobsCancelArgs) -> None: - fine_tuning_job: FineTuningJob = get_client().fine_tuning.jobs.cancel(fine_tuning_job_id=args.id) - print_model(fine_tuning_job) - - @staticmethod - def list_events(args: CLIFineTuningJobsListEventsArgs) -> None: - fine_tuning_job_events: SyncCursorPage[FineTuningJobEvent] = get_client().fine_tuning.jobs.list_events( - fine_tuning_job_id=args.id, - after=args.after or omit, - limit=args.limit or omit, - ) - print_model(fine_tuning_job_events) diff --git a/src/openai/cli/_api/image.py b/src/openai/cli/_api/image.py deleted file mode 100644 index 1d0cf810c1..0000000000 --- a/src/openai/cli/_api/image.py +++ /dev/null @@ -1,139 +0,0 @@ -from __future__ import annotations - -from typing import TYPE_CHECKING, Any, cast -from argparse import ArgumentParser - -from .._utils import get_client, print_model -from ..._types import Omit, Omittable, omit -from .._models import BaseModel -from .._progress import BufferReader - -if TYPE_CHECKING: - from argparse import _SubParsersAction - - -def register(subparser: _SubParsersAction[ArgumentParser]) -> None: - sub = subparser.add_parser("images.generate") - sub.add_argument("-m", "--model", type=str) - sub.add_argument("-p", "--prompt", type=str, required=True) - sub.add_argument("-n", "--num-images", type=int, default=1) - sub.add_argument("-s", "--size", type=str, default="1024x1024", help="Size of the output image") - sub.add_argument("--response-format", type=str, default="url") - sub.set_defaults(func=CLIImage.create, args_model=CLIImageCreateArgs) - - sub = subparser.add_parser("images.edit") - sub.add_argument("-m", "--model", type=str) - sub.add_argument("-p", "--prompt", type=str, required=True) - sub.add_argument("-n", "--num-images", type=int, default=1) - sub.add_argument( - "-I", - "--image", - type=str, - required=True, - help="Image to modify. Should be a local path and a PNG encoded image.", - ) - sub.add_argument("-s", "--size", type=str, default="1024x1024", help="Size of the output image") - sub.add_argument("--response-format", type=str, default="url") - sub.add_argument( - "-M", - "--mask", - type=str, - required=False, - help="Path to a mask image. It should be the same size as the image you're editing and a RGBA PNG image. The Alpha channel acts as the mask.", - ) - sub.set_defaults(func=CLIImage.edit, args_model=CLIImageEditArgs) - - sub = subparser.add_parser("images.create_variation") - sub.add_argument("-m", "--model", type=str) - sub.add_argument("-n", "--num-images", type=int, default=1) - sub.add_argument( - "-I", - "--image", - type=str, - required=True, - help="Image to modify. Should be a local path and a PNG encoded image.", - ) - sub.add_argument("-s", "--size", type=str, default="1024x1024", help="Size of the output image") - sub.add_argument("--response-format", type=str, default="url") - sub.set_defaults(func=CLIImage.create_variation, args_model=CLIImageCreateVariationArgs) - - -class CLIImageCreateArgs(BaseModel): - prompt: str - num_images: int - size: str - response_format: str - model: Omittable[str] = omit - - -class CLIImageCreateVariationArgs(BaseModel): - image: str - num_images: int - size: str - response_format: str - model: Omittable[str] = omit - - -class CLIImageEditArgs(BaseModel): - image: str - num_images: int - size: str - response_format: str - prompt: str - mask: Omittable[str] = omit - model: Omittable[str] = omit - - -class CLIImage: - @staticmethod - def create(args: CLIImageCreateArgs) -> None: - image = get_client().images.generate( - model=args.model, - prompt=args.prompt, - n=args.num_images, - # casts required because the API is typed for enums - # but we don't want to validate that here for forwards-compat - size=cast(Any, args.size), - response_format=cast(Any, args.response_format), - ) - print_model(image) - - @staticmethod - def create_variation(args: CLIImageCreateVariationArgs) -> None: - with open(args.image, "rb") as file_reader: - buffer_reader = BufferReader(file_reader.read(), desc="Upload progress") - - image = get_client().images.create_variation( - model=args.model, - image=("image", buffer_reader), - n=args.num_images, - # casts required because the API is typed for enums - # but we don't want to validate that here for forwards-compat - size=cast(Any, args.size), - response_format=cast(Any, args.response_format), - ) - print_model(image) - - @staticmethod - def edit(args: CLIImageEditArgs) -> None: - with open(args.image, "rb") as file_reader: - buffer_reader = BufferReader(file_reader.read(), desc="Image upload progress") - - if isinstance(args.mask, Omit): - mask: Omittable[BufferReader] = omit - else: - with open(args.mask, "rb") as file_reader: - mask = BufferReader(file_reader.read(), desc="Mask progress") - - image = get_client().images.edit( - model=args.model, - prompt=args.prompt, - image=("image", buffer_reader), - n=args.num_images, - mask=("mask", mask) if not isinstance(mask, Omit) else mask, - # casts required because the API is typed for enums - # but we don't want to validate that here for forwards-compat - size=cast(Any, args.size), - response_format=cast(Any, args.response_format), - ) - print_model(image) diff --git a/src/openai/cli/_api/models.py b/src/openai/cli/_api/models.py deleted file mode 100644 index 017218fa6e..0000000000 --- a/src/openai/cli/_api/models.py +++ /dev/null @@ -1,45 +0,0 @@ -from __future__ import annotations - -from typing import TYPE_CHECKING -from argparse import ArgumentParser - -from .._utils import get_client, print_model -from .._models import BaseModel - -if TYPE_CHECKING: - from argparse import _SubParsersAction - - -def register(subparser: _SubParsersAction[ArgumentParser]) -> None: - sub = subparser.add_parser("models.list") - sub.set_defaults(func=CLIModels.list) - - sub = subparser.add_parser("models.retrieve") - sub.add_argument("-i", "--id", required=True, help="The model ID") - sub.set_defaults(func=CLIModels.get, args_model=CLIModelIDArgs) - - sub = subparser.add_parser("models.delete") - sub.add_argument("-i", "--id", required=True, help="The model ID") - sub.set_defaults(func=CLIModels.delete, args_model=CLIModelIDArgs) - - -class CLIModelIDArgs(BaseModel): - id: str - - -class CLIModels: - @staticmethod - def get(args: CLIModelIDArgs) -> None: - model = get_client().models.retrieve(model=args.id) - print_model(model) - - @staticmethod - def delete(args: CLIModelIDArgs) -> None: - model = get_client().models.delete(model=args.id) - print_model(model) - - @staticmethod - def list() -> None: - models = get_client().models.list() - for model in models: - print_model(model) diff --git a/src/openai/cli/_cli.py b/src/openai/cli/_cli.py deleted file mode 100644 index d31196da50..0000000000 --- a/src/openai/cli/_cli.py +++ /dev/null @@ -1,233 +0,0 @@ -from __future__ import annotations - -import sys -import logging -import argparse -from typing import Any, List, Type, Optional -from typing_extensions import ClassVar - -import httpx -import pydantic - -import openai - -from . import _tools -from .. import _ApiType, __version__ -from ._api import register_commands -from ._utils import can_use_http2 -from ._errors import CLIError, display_error -from .._compat import PYDANTIC_V1, ConfigDict, model_parse -from .._models import BaseModel -from .._exceptions import APIError - -logger = logging.getLogger() -formatter = logging.Formatter("[%(asctime)s] %(message)s") -handler = logging.StreamHandler(sys.stderr) -handler.setFormatter(formatter) -logger.addHandler(handler) - - -class Arguments(BaseModel): - if PYDANTIC_V1: - - class Config(pydantic.BaseConfig): # type: ignore - extra: Any = pydantic.Extra.ignore # type: ignore - else: - model_config: ClassVar[ConfigDict] = ConfigDict( - extra="ignore", - ) - - verbosity: int - version: Optional[str] = None - - api_key: Optional[str] - api_base: Optional[str] - organization: Optional[str] - proxy: Optional[List[str]] - api_type: Optional[_ApiType] = None - api_version: Optional[str] = None - - # azure - azure_endpoint: Optional[str] = None - azure_ad_token: Optional[str] = None - - # internal, set by subparsers to parse their specific args - args_model: Optional[Type[BaseModel]] = None - - # internal, used so that subparsers can forward unknown arguments - unknown_args: List[str] = [] - allow_unknown_args: bool = False - - -def _build_parser() -> argparse.ArgumentParser: - parser = argparse.ArgumentParser(description=None, prog="openai") - parser.add_argument( - "-v", - "--verbose", - action="count", - dest="verbosity", - default=0, - help="Set verbosity.", - ) - parser.add_argument("-b", "--api-base", help="What API base url to use.") - parser.add_argument("-k", "--api-key", help="What API key to use.") - parser.add_argument("-p", "--proxy", nargs="+", help="What proxy to use.") - parser.add_argument( - "-o", - "--organization", - help="Which organization to run as (will use your default organization if not specified)", - ) - parser.add_argument( - "-t", - "--api-type", - type=str, - choices=("openai", "azure"), - help="The backend API to call, must be `openai` or `azure`", - ) - parser.add_argument( - "--api-version", - help="The Azure API version, e.g. 'https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#rest-api-versioning'", - ) - - # azure - parser.add_argument( - "--azure-endpoint", - help="The Azure endpoint, e.g. 'https://endpoint.openai.azure.com'", - ) - parser.add_argument( - "--azure-ad-token", - help="A token from Azure Active Directory, https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id", - ) - - # prints the package version - parser.add_argument( - "-V", - "--version", - action="version", - version="%(prog)s " + __version__, - ) - - def help() -> None: - parser.print_help() - - parser.set_defaults(func=help) - - subparsers = parser.add_subparsers() - sub_api = subparsers.add_parser("api", help="Direct API calls") - - register_commands(sub_api) - - sub_tools = subparsers.add_parser("tools", help="Client side tools for convenience") - _tools.register_commands(sub_tools, subparsers) - - return parser - - -def main() -> int: - try: - _main() - except (APIError, CLIError, pydantic.ValidationError) as err: - display_error(err) - return 1 - except KeyboardInterrupt: - sys.stderr.write("\n") - return 1 - return 0 - - -def _parse_args(parser: argparse.ArgumentParser) -> tuple[argparse.Namespace, Arguments, list[str]]: - # argparse by default will strip out the `--` but we want to keep it for unknown arguments - if "--" in sys.argv: - idx = sys.argv.index("--") - known_args = sys.argv[1:idx] - unknown_args = sys.argv[idx:] - else: - known_args = sys.argv[1:] - unknown_args = [] - - parsed, remaining_unknown = parser.parse_known_args(known_args) - - # append any remaining unknown arguments from the initial parsing - remaining_unknown.extend(unknown_args) - - args = model_parse(Arguments, vars(parsed)) - if not args.allow_unknown_args: - # we have to parse twice to ensure any unknown arguments - # result in an error if that behaviour is desired - parser.parse_args() - - return parsed, args, remaining_unknown - - -def _main() -> None: - parser = _build_parser() - parsed, args, unknown = _parse_args(parser) - - if args.verbosity != 0: - sys.stderr.write("Warning: --verbosity isn't supported yet\n") - - proxies: dict[str, httpx.BaseTransport] = {} - if args.proxy is not None: - for proxy in args.proxy: - key = "https://" if proxy.startswith("https") else "http://" - if key in proxies: - raise CLIError(f"Multiple {key} proxies given - only the last one would be used") - - proxies[key] = httpx.HTTPTransport(proxy=httpx.Proxy(httpx.URL(proxy))) - - http_client = httpx.Client( - mounts=proxies or None, - http2=can_use_http2(), - ) - openai.http_client = http_client - - if args.organization: - openai.organization = args.organization - - if args.api_key: - openai.api_key = args.api_key - - if args.api_base: - openai.base_url = args.api_base - - # azure - if args.api_type is not None: - openai.api_type = args.api_type - - if args.azure_endpoint is not None: - openai.azure_endpoint = args.azure_endpoint - - if args.api_version is not None: - openai.api_version = args.api_version - - if args.azure_ad_token is not None: - openai.azure_ad_token = args.azure_ad_token - - try: - if args.args_model: - parsed.func( - model_parse( - args.args_model, - { - **{ - # we omit None values so that they can be defaulted to `NotGiven` - # and we'll strip it from the API request - key: value - for key, value in vars(parsed).items() - if value is not None - }, - "unknown_args": unknown, - }, - ) - ) - else: - parsed.func() - finally: - try: - http_client.close() - except Exception: - pass - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/src/openai/cli/_errors.py b/src/openai/cli/_errors.py deleted file mode 100644 index 7d0292dab2..0000000000 --- a/src/openai/cli/_errors.py +++ /dev/null @@ -1,21 +0,0 @@ -from __future__ import annotations - -import sys - -import pydantic - -from ._utils import Colors, organization_info -from .._exceptions import APIError, OpenAIError - - -class CLIError(OpenAIError): ... - - -class SilentCLIError(CLIError): ... - - -def display_error(err: CLIError | APIError | pydantic.ValidationError) -> None: - if isinstance(err, SilentCLIError): - return - - sys.stderr.write("{}{}Error:{} {}\n".format(organization_info(), Colors.FAIL, Colors.ENDC, err)) diff --git a/src/openai/cli/_models.py b/src/openai/cli/_models.py deleted file mode 100644 index a88608961b..0000000000 --- a/src/openai/cli/_models.py +++ /dev/null @@ -1,17 +0,0 @@ -from typing import Any -from typing_extensions import ClassVar - -import pydantic - -from .. import _models -from .._compat import PYDANTIC_V1, ConfigDict - - -class BaseModel(_models.BaseModel): - if PYDANTIC_V1: - - class Config(pydantic.BaseConfig): # type: ignore - extra: Any = pydantic.Extra.ignore # type: ignore - arbitrary_types_allowed: bool = True - else: - model_config: ClassVar[ConfigDict] = ConfigDict(extra="ignore", arbitrary_types_allowed=True) diff --git a/src/openai/cli/_progress.py b/src/openai/cli/_progress.py deleted file mode 100644 index 8a7f2525de..0000000000 --- a/src/openai/cli/_progress.py +++ /dev/null @@ -1,59 +0,0 @@ -from __future__ import annotations - -import io -from typing import Callable -from typing_extensions import override - - -class CancelledError(Exception): - def __init__(self, msg: str) -> None: - self.msg = msg - super().__init__(msg) - - @override - def __str__(self) -> str: - return self.msg - - __repr__ = __str__ - - -class BufferReader(io.BytesIO): - def __init__(self, buf: bytes = b"", desc: str | None = None) -> None: - super().__init__(buf) - self._len = len(buf) - self._progress = 0 - self._callback = progress(len(buf), desc=desc) - - def __len__(self) -> int: - return self._len - - @override - def read(self, n: int | None = -1) -> bytes: - chunk = io.BytesIO.read(self, n) - self._progress += len(chunk) - - try: - self._callback(self._progress) - except Exception as e: # catches exception from the callback - raise CancelledError("The upload was cancelled: {}".format(e)) from e - - return chunk - - -def progress(total: float, desc: str | None) -> Callable[[float], None]: - import tqdm - - meter = tqdm.tqdm(total=total, unit_scale=True, desc=desc) - - def incr(progress: float) -> None: - meter.n = progress - if progress == total: - meter.close() - else: - meter.refresh() - - return incr - - -def MB(i: int) -> int: - return int(i // 1024**2) diff --git a/src/openai/cli/_tools/__init__.py b/src/openai/cli/_tools/__init__.py deleted file mode 100644 index 56a0260a6d..0000000000 --- a/src/openai/cli/_tools/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from ._main import register_commands as register_commands diff --git a/src/openai/cli/_tools/_main.py b/src/openai/cli/_tools/_main.py deleted file mode 100644 index bd6cda408f..0000000000 --- a/src/openai/cli/_tools/_main.py +++ /dev/null @@ -1,17 +0,0 @@ -from __future__ import annotations - -from typing import TYPE_CHECKING -from argparse import ArgumentParser - -from . import migrate, fine_tunes - -if TYPE_CHECKING: - from argparse import _SubParsersAction - - -def register_commands(parser: ArgumentParser, subparser: _SubParsersAction[ArgumentParser]) -> None: - migrate.register(subparser) - - namespaced = parser.add_subparsers(title="Tools", help="Convenience client side tools") - - fine_tunes.register(namespaced) diff --git a/src/openai/cli/_tools/fine_tunes.py b/src/openai/cli/_tools/fine_tunes.py deleted file mode 100644 index 2128b88952..0000000000 --- a/src/openai/cli/_tools/fine_tunes.py +++ /dev/null @@ -1,63 +0,0 @@ -from __future__ import annotations - -import sys -from typing import TYPE_CHECKING -from argparse import ArgumentParser - -from .._models import BaseModel -from ...lib._validators import ( - get_validators, - write_out_file, - read_any_format, - apply_validators, - apply_necessary_remediation, -) - -if TYPE_CHECKING: - from argparse import _SubParsersAction - - -def register(subparser: _SubParsersAction[ArgumentParser]) -> None: - sub = subparser.add_parser("fine_tunes.prepare_data") - sub.add_argument( - "-f", - "--file", - required=True, - help="JSONL, JSON, CSV, TSV, TXT or XLSX file containing prompt-completion examples to be analyzed." - "This should be the local file path.", - ) - sub.add_argument( - "-q", - "--quiet", - required=False, - action="store_true", - help="Auto accepts all suggestions, without asking for user input. To be used within scripts.", - ) - sub.set_defaults(func=prepare_data, args_model=PrepareDataArgs) - - -class PrepareDataArgs(BaseModel): - file: str - - quiet: bool - - -def prepare_data(args: PrepareDataArgs) -> None: - sys.stdout.write("Analyzing...\n") - fname = args.file - auto_accept = args.quiet - df, remediation = read_any_format(fname) - apply_necessary_remediation(None, remediation) - - validators = get_validators() - - assert df is not None - - apply_validators( - df, - fname, - remediation, - validators, - auto_accept, - write_out_file_func=write_out_file, - ) diff --git a/src/openai/cli/_tools/migrate.py b/src/openai/cli/_tools/migrate.py deleted file mode 100644 index 841b777528..0000000000 --- a/src/openai/cli/_tools/migrate.py +++ /dev/null @@ -1,164 +0,0 @@ -from __future__ import annotations - -import os -import sys -import shutil -import tarfile -import platform -import subprocess -from typing import TYPE_CHECKING, List -from pathlib import Path -from argparse import ArgumentParser - -import httpx - -from .._errors import CLIError, SilentCLIError -from .._models import BaseModel - -if TYPE_CHECKING: - from argparse import _SubParsersAction - - -def register(subparser: _SubParsersAction[ArgumentParser]) -> None: - sub = subparser.add_parser("migrate") - sub.set_defaults(func=migrate, args_model=MigrateArgs, allow_unknown_args=True) - - sub = subparser.add_parser("grit") - sub.set_defaults(func=grit, args_model=GritArgs, allow_unknown_args=True) - - -class GritArgs(BaseModel): - # internal - unknown_args: List[str] = [] - - -def grit(args: GritArgs) -> None: - grit_path = install() - - try: - subprocess.check_call([grit_path, *args.unknown_args]) - except subprocess.CalledProcessError: - # stdout and stderr are forwarded by subprocess so an error will already - # have been displayed - raise SilentCLIError() from None - - -class MigrateArgs(BaseModel): - # internal - unknown_args: List[str] = [] - - -def migrate(args: MigrateArgs) -> None: - grit_path = install() - - try: - subprocess.check_call([grit_path, "apply", "openai", *args.unknown_args]) - except subprocess.CalledProcessError: - # stdout and stderr are forwarded by subprocess so an error will already - # have been displayed - raise SilentCLIError() from None - - -# handles downloading the Grit CLI until they provide their own PyPi package - -KEYGEN_ACCOUNT = "custodian-dev" - - -def _cache_dir() -> Path: - xdg = os.environ.get("XDG_CACHE_HOME") - if xdg is not None: - return Path(xdg) - - return Path.home() / ".cache" - - -def _debug(message: str) -> None: - if not os.environ.get("DEBUG"): - return - - sys.stdout.write(f"[DEBUG]: {message}\n") - - -def install() -> Path: - """Installs the Grit CLI and returns the location of the binary""" - if sys.platform == "win32": - raise CLIError("Windows is not supported yet in the migration CLI") - - _debug("Using Grit installer from GitHub") - - platform = "apple-darwin" if sys.platform == "darwin" else "unknown-linux-gnu" - - dir_name = _cache_dir() / "openai-python" - install_dir = dir_name / ".install" - target_dir = install_dir / "bin" - - target_path = target_dir / "grit" - temp_file = target_dir / "grit.tmp" - - if target_path.exists(): - _debug(f"{target_path} already exists") - sys.stdout.flush() - return target_path - - _debug(f"Using Grit CLI path: {target_path}") - - target_dir.mkdir(parents=True, exist_ok=True) - - if temp_file.exists(): - temp_file.unlink() - - arch = _get_arch() - _debug(f"Using architecture {arch}") - - file_name = f"grit-{arch}-{platform}" - download_url = f"https://github.com/getgrit/gritql/releases/latest/download/{file_name}.tar.gz" - - sys.stdout.write(f"Downloading Grit CLI from {download_url}\n") - with httpx.Client() as client: - download_response = client.get(download_url, follow_redirects=True) - if download_response.status_code != 200: - raise CLIError(f"Failed to download Grit CLI from {download_url}") - with open(temp_file, "wb") as file: - for chunk in download_response.iter_bytes(): - file.write(chunk) - - unpacked_dir = target_dir / "cli-bin" - unpacked_dir.mkdir(parents=True, exist_ok=True) - - with tarfile.open(temp_file, "r:gz") as archive: - if sys.version_info >= (3, 12): - archive.extractall(unpacked_dir, filter="data") - else: - archive.extractall(unpacked_dir) - - _move_files_recursively(unpacked_dir, target_dir) - - shutil.rmtree(unpacked_dir) - os.remove(temp_file) - os.chmod(target_path, 0o755) - - sys.stdout.flush() - - return target_path - - -def _move_files_recursively(source_dir: Path, target_dir: Path) -> None: - for item in source_dir.iterdir(): - if item.is_file(): - item.rename(target_dir / item.name) - elif item.is_dir(): - _move_files_recursively(item, target_dir) - - -def _get_arch() -> str: - architecture = platform.machine().lower() - - # Map the architecture names to Grit equivalents - arch_map = { - "x86_64": "x86_64", - "amd64": "x86_64", - "armv7l": "aarch64", - "arm64": "aarch64", - } - - return arch_map.get(architecture, architecture) diff --git a/src/openai/cli/_utils.py b/src/openai/cli/_utils.py deleted file mode 100644 index 673eed613c..0000000000 --- a/src/openai/cli/_utils.py +++ /dev/null @@ -1,45 +0,0 @@ -from __future__ import annotations - -import sys - -import openai - -from .. import OpenAI, _load_client -from .._compat import model_json -from .._models import BaseModel - - -class Colors: - HEADER = "\033[95m" - OKBLUE = "\033[94m" - OKGREEN = "\033[92m" - WARNING = "\033[93m" - FAIL = "\033[91m" - ENDC = "\033[0m" - BOLD = "\033[1m" - UNDERLINE = "\033[4m" - - -def get_client() -> OpenAI: - return _load_client() - - -def organization_info() -> str: - organization = openai.organization - if organization is not None: - return "[organization={}] ".format(organization) - - return "" - - -def print_model(model: BaseModel) -> None: - sys.stdout.write(model_json(model, indent=2) + "\n") - - -def can_use_http2() -> bool: - try: - import h2 # type: ignore # noqa - except ImportError: - return False - - return True From d07d4a8b1611cea5cd2e345dbc09882d61bdcab4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 6 May 2026 14:48:00 +0000 Subject: [PATCH 11/12] release: 2.35.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 20 ++++++++++++++++++++ pyproject.toml | 2 +- src/openai/_version.py | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 7a1c4674e4..517b0cf98a 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.34.0" + ".": "2.35.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 237a8c00a4..462cb2c24d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Changelog +## 2.35.0 (2026-05-06) + +Full Changelog: [v2.34.0...v2.35.0](https://github.com/openai/openai-python/compare/v2.34.0...v2.35.0) + +### Features + +* **api:** launch realtime translate + update image 2 ([0ba55d7](https://github.com/openai/openai-python/commit/0ba55d7569565045426e1587906a70d5682a4bba)) +* **api:** manual updates ([72bf67a](https://github.com/openai/openai-python/commit/72bf67acbc9f030c20db3d5a1a74ea6d67d55f51)) + + +### Chores + +* remove legacy python cli ([32f36e4](https://github.com/openai/openai-python/commit/32f36e447d02c3124af8ab48fcc3537df2fed66e)) +* rename legacy python cli entrypoint ([a3b182d](https://github.com/openai/openai-python/commit/a3b182d6d2c2e6fe1d53ca7550b2d43e0f8b2cd3)) + + +### Documentation + +* **api:** update top_logprobs parameter description across chat and responses ([f9d339f](https://github.com/openai/openai-python/commit/f9d339fcea63feaa1bdf918a4599f2b032c83517)) + ## 2.34.0 (2026-05-04) Full Changelog: [v2.33.0...v2.34.0](https://github.com/openai/openai-python/compare/v2.33.0...v2.34.0) diff --git a/pyproject.toml b/pyproject.toml index 1f7c145039..1313a78507 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openai" -version = "2.34.0" +version = "2.35.0" description = "The official Python library for the openai API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/openai/_version.py b/src/openai/_version.py index 857aeb7dff..e2c1c47531 100644 --- a/src/openai/_version.py +++ b/src/openai/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "openai" -__version__ = "2.34.0" # x-release-please-version +__version__ = "2.35.0" # x-release-please-version From 45ac986243ac038f12b47ada0578b25e6e94523b Mon Sep 17 00:00:00 2001 From: Alex Chang Date: Wed, 6 May 2026 11:46:19 -0400 Subject: [PATCH 12/12] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 462cb2c24d..add3d25f2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Full Changelog: [v2.34.0...v2.35.0](https://github.com/openai/openai-python/comp ### Features -* **api:** launch realtime translate + update image 2 ([0ba55d7](https://github.com/openai/openai-python/commit/0ba55d7569565045426e1587906a70d5682a4bba)) +* **api:** update image 2 ([0ba55d7](https://github.com/openai/openai-python/commit/0ba55d7569565045426e1587906a70d5682a4bba)) * **api:** manual updates ([72bf67a](https://github.com/openai/openai-python/commit/72bf67acbc9f030c20db3d5a1a74ea6d67d55f51))