Skip to content

release: 1.97.0 #2473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.96.1"
".": "1.97.0"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 111
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-c7dacca97e28bceff218684bb429481a70aa47aadad983ed9178bfda75ff4cd2.yml
openapi_spec_hash: 28eb1bb901ca10d2e37db4606d2bcfa7
config_hash: 167ad0ca036d0f023c78e6496b4311e8
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-670ea0d2cc44f52a87dd3cadea45632953283e0636ba30788fdbdb22a232ccac.yml
openapi_spec_hash: d8b7d38911fead545adf3e4297956410
config_hash: 5525bda35e48ea6387c6175c4d1651fa
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 1.97.0 (2025-07-16)

Full Changelog: [v1.96.1...v1.97.0](https://github.com/openai/openai-python/compare/v1.96.1...v1.97.0)

### Features

* **api:** manual updates ([ed8e899](https://github.com/openai/openai-python/commit/ed8e89953d11bd5f44fa531422bdbb7a577ab426))

## 1.96.1 (2025-07-15)

Full Changelog: [v1.96.0...v1.96.1](https://github.com/openai/openai-python/compare/v1.96.0...v1.96.1)
Expand Down
12 changes: 11 additions & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,17 @@ Methods:
Types:

```python
from openai.types import Image, ImageModel, ImagesResponse
from openai.types import (
Image,
ImageEditCompletedEvent,
ImageEditPartialImageEvent,
ImageEditStreamEvent,
ImageGenCompletedEvent,
ImageGenPartialImageEvent,
ImageGenStreamEvent,
ImageModel,
ImagesResponse,
)
```

Methods:
Expand Down
53 changes: 53 additions & 0 deletions examples/image_stream.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python

import base64
from pathlib import Path

from openai import OpenAI

client = OpenAI()


def main() -> None:
"""Example of OpenAI image streaming with partial images."""
stream = client.images.generate(
model="gpt-image-1",
prompt="A cute baby sea otter",
n=1,
size="1024x1024",
stream=True,
partial_images=3,
)

for event in stream:
if event.type == "image_generation.partial_image":
print(f" Partial image {event.partial_image_index + 1}/3 received")
print(f" Size: {len(event.b64_json)} characters (base64)")

# Save partial image to file
filename = f"partial_{event.partial_image_index + 1}.png"
image_data = base64.b64decode(event.b64_json)
with open(filename, "wb") as f:
f.write(image_data)
print(f" 💾 Saved to: {Path(filename).resolve()}")

elif event.type == "image_generation.completed":
print(f"\n✅ Final image completed!")
print(f" Size: {len(event.b64_json)} characters (base64)")

# Save final image to file
filename = "final_image.png"
image_data = base64.b64decode(event.b64_json)
with open(filename, "wb") as f:
f.write(image_data)
print(f" 💾 Saved to: {Path(filename).resolve()}")

else:
print(f"❓ Unknown event: {event}") # type: ignore[unreachable]


if __name__ == "__main__":
try:
main()
except Exception as error:
print(f"Error generating image: {error}")
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "openai"
version = "1.96.1"
version = "1.97.0"
description = "The official Python library for the openai API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
7 changes: 6 additions & 1 deletion src/openai/_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ def __stream__(self) -> Iterator[_T]:
if sse.data.startswith("[DONE]"):
break

if sse.event is None or sse.event.startswith("response.") or sse.event.startswith("transcript."):
if sse.event is None or (
sse.event.startswith("response.") or
sse.event.startswith("transcript.") or
sse.event.startswith("image_edit.") or
sse.event.startswith("image_generation.")
):
data = sse.json()
if is_mapping(data) and data.get("error"):
message = None
Expand Down
2 changes: 1 addition & 1 deletion src/openai/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "openai"
__version__ = "1.96.1" # x-release-please-version
__version__ = "1.97.0" # x-release-please-version
Loading