Skip to content

Commit a71c60d

Browse files
authored
Merge branch 'main' into main
2 parents 0d9e4a0 + e6c6757 commit a71c60d

File tree

97 files changed

+2681
-472
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+2681
-472
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "1.93.1"
2+
".": "1.97.1"
33
}

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 111
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-a473967d1766dc155994d932fbc4a5bcbd1c140a37c20d0a4065e1bf0640536d.yml
3-
openapi_spec_hash: 67cdc62b0d6c8b1de29b7dc54b265749
4-
config_hash: 7b53f96f897ca1b3407a5341a6f820db
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-b2a451656ca64d30d174391ebfd94806b4de3ab76dc55b92843cfb7f1a54ecb6.yml
3+
openapi_spec_hash: 27d9691b400f28c17ef063a1374048b0
4+
config_hash: e822d0c9082c8b312264403949243179

CHANGELOG.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,94 @@
11
# Changelog
22

3+
## 1.97.1 (2025-07-22)
4+
5+
Full Changelog: [v1.97.0...v1.97.1](https://github.com/openai/openai-python/compare/v1.97.0...v1.97.1)
6+
7+
### Bug Fixes
8+
9+
* **parsing:** ignore empty metadata ([58c359f](https://github.com/openai/openai-python/commit/58c359ff67fd6103268e4405600fd58844b6f27b))
10+
* **parsing:** parse extra field types ([d524b7e](https://github.com/openai/openai-python/commit/d524b7e201418ccc9b5c2206da06d1be011808e5))
11+
12+
13+
### Chores
14+
15+
* **api:** event shapes more accurate ([f3a9a92](https://github.com/openai/openai-python/commit/f3a9a9229280ecb7e0b2779dd44290df6d9824ef))
16+
17+
## 1.97.0 (2025-07-16)
18+
19+
Full Changelog: [v1.96.1...v1.97.0](https://github.com/openai/openai-python/compare/v1.96.1...v1.97.0)
20+
21+
### Features
22+
23+
* **api:** manual updates ([ed8e899](https://github.com/openai/openai-python/commit/ed8e89953d11bd5f44fa531422bdbb7a577ab426))
24+
25+
## 1.96.1 (2025-07-15)
26+
27+
Full Changelog: [v1.96.0...v1.96.1](https://github.com/openai/openai-python/compare/v1.96.0...v1.96.1)
28+
29+
### Chores
30+
31+
* **api:** update realtime specs ([b68b71b](https://github.com/openai/openai-python/commit/b68b71b178719e0b49ecfe34486b9d9ac0627924))
32+
33+
## 1.96.0 (2025-07-15)
34+
35+
Full Changelog: [v1.95.1...v1.96.0](https://github.com/openai/openai-python/compare/v1.95.1...v1.96.0)
36+
37+
### Features
38+
39+
* clean up environment call outs ([87c2e97](https://github.com/openai/openai-python/commit/87c2e979e0ec37347b7f595c2696408acd25fe20))
40+
41+
42+
### Chores
43+
44+
* **api:** update realtime specs, build config ([bf06d88](https://github.com/openai/openai-python/commit/bf06d88b33f9af82a51d9a8af5b7a38925906f7a))
45+
46+
## 1.95.1 (2025-07-11)
47+
48+
Full Changelog: [v1.95.0...v1.95.1](https://github.com/openai/openai-python/compare/v1.95.0...v1.95.1)
49+
50+
### Bug Fixes
51+
52+
* **client:** don't send Content-Type header on GET requests ([182b763](https://github.com/openai/openai-python/commit/182b763065fbaaf68491a7e4a15fcb23cac361de))
53+
54+
## 1.95.0 (2025-07-10)
55+
56+
Full Changelog: [v1.94.0...v1.95.0](https://github.com/openai/openai-python/compare/v1.94.0...v1.95.0)
57+
58+
### Features
59+
60+
* **api:** add file_url, fix event ID ([265e216](https://github.com/openai/openai-python/commit/265e216396196d66cdfb5f92c5ef1a2a6ff27b5b))
61+
62+
63+
### Chores
64+
65+
* **readme:** fix version rendering on pypi ([1eee5ca](https://github.com/openai/openai-python/commit/1eee5cabf2fd93877cd3ba85d0c6ed2ffd5f159f))
66+
67+
## 1.94.0 (2025-07-10)
68+
69+
Full Changelog: [v1.93.3...v1.94.0](https://github.com/openai/openai-python/compare/v1.93.3...v1.94.0)
70+
71+
### Features
72+
73+
* **api:** return better error message on missing embedding ([#2369](https://github.com/openai/openai-python/issues/2369)) ([e53464a](https://github.com/openai/openai-python/commit/e53464ae95f6a041f3267762834e6156c5ce1b57))
74+
75+
## 1.93.3 (2025-07-09)
76+
77+
Full Changelog: [v1.93.2...v1.93.3](https://github.com/openai/openai-python/compare/v1.93.2...v1.93.3)
78+
79+
### Bug Fixes
80+
81+
* **parsing:** correctly handle nested discriminated unions ([fc8a677](https://github.com/openai/openai-python/commit/fc8a67715d8f1b45d8639b8b6f9f6590fe358734))
82+
83+
## 1.93.2 (2025-07-08)
84+
85+
Full Changelog: [v1.93.1...v1.93.2](https://github.com/openai/openai-python/compare/v1.93.1...v1.93.2)
86+
87+
### Chores
88+
89+
* **internal:** bump pinned h11 dep ([4fca6ae](https://github.com/openai/openai-python/commit/4fca6ae2d0d7f27cbac8d06c3917932767c8c6b8))
90+
* **package:** mark python 3.13 as supported ([2229047](https://github.com/openai/openai-python/commit/2229047b8a549df16c617bddfe3b4521cfd257a5))
91+
392
## 1.93.1 (2025-07-07)
493

594
Full Changelog: [v1.93.0...v1.93.1](https://github.com/openai/openai-python/compare/v1.93.0...v1.93.1)

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# OpenAI Python API library
22

3-
[![PyPI version](<https://img.shields.io/pypi/v/openai.svg?label=pypi%20(stable)>)](https://pypi.org/project/openai/)
3+
<!-- prettier-ignore -->
4+
[![PyPI version](https://img.shields.io/pypi/v/openai.svg?label=pypi%20(stable))](https://pypi.org/project/openai/)
45

56
The OpenAI Python library provides convenient access to the OpenAI REST API from any Python 3.8+
67
application. The library includes type definitions for all request params and response fields,
@@ -159,15 +160,14 @@ pip install openai[aiohttp]
159160
Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
160161

161162
```python
162-
import os
163163
import asyncio
164164
from openai import DefaultAioHttpClient
165165
from openai import AsyncOpenAI
166166

167167

168168
async def main() -> None:
169169
async with AsyncOpenAI(
170-
api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
170+
api_key="My API Key",
171171
http_client=DefaultAioHttpClient(),
172172
) as client:
173173
chat_completion = await client.chat.completions.create(

api.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,17 @@ Methods:
127127
Types:
128128

129129
```python
130-
from openai.types import Image, ImageModel, ImagesResponse
130+
from openai.types import (
131+
Image,
132+
ImageEditCompletedEvent,
133+
ImageEditPartialImageEvent,
134+
ImageEditStreamEvent,
135+
ImageGenCompletedEvent,
136+
ImageGenPartialImageEvent,
137+
ImageGenStreamEvent,
138+
ImageModel,
139+
ImagesResponse,
140+
)
131141
```
132142

133143
Methods:
@@ -781,8 +791,6 @@ from openai.types.responses import (
781791
ResponseOutputTextAnnotationAddedEvent,
782792
ResponsePrompt,
783793
ResponseQueuedEvent,
784-
ResponseReasoningDeltaEvent,
785-
ResponseReasoningDoneEvent,
786794
ResponseReasoningItem,
787795
ResponseReasoningSummaryDeltaEvent,
788796
ResponseReasoningSummaryDoneEvent,

examples/image_stream.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env python
2+
3+
import base64
4+
from pathlib import Path
5+
6+
from openai import OpenAI
7+
8+
client = OpenAI()
9+
10+
11+
def main() -> None:
12+
"""Example of OpenAI image streaming with partial images."""
13+
stream = client.images.generate(
14+
model="gpt-image-1",
15+
prompt="A cute baby sea otter",
16+
n=1,
17+
size="1024x1024",
18+
stream=True,
19+
partial_images=3,
20+
)
21+
22+
for event in stream:
23+
if event.type == "image_generation.partial_image":
24+
print(f" Partial image {event.partial_image_index + 1}/3 received")
25+
print(f" Size: {len(event.b64_json)} characters (base64)")
26+
27+
# Save partial image to file
28+
filename = f"partial_{event.partial_image_index + 1}.png"
29+
image_data = base64.b64decode(event.b64_json)
30+
with open(filename, "wb") as f:
31+
f.write(image_data)
32+
print(f" 💾 Saved to: {Path(filename).resolve()}")
33+
34+
elif event.type == "image_generation.completed":
35+
print(f"\n✅ Final image completed!")
36+
print(f" Size: {len(event.b64_json)} characters (base64)")
37+
38+
# Save final image to file
39+
filename = "final_image.png"
40+
image_data = base64.b64decode(event.b64_json)
41+
with open(filename, "wb") as f:
42+
f.write(image_data)
43+
print(f" 💾 Saved to: {Path(filename).resolve()}")
44+
45+
else:
46+
print(f"❓ Unknown event: {event}") # type: ignore[unreachable]
47+
48+
49+
if __name__ == "__main__":
50+
try:
51+
main()
52+
except Exception as error:
53+
print(f"Error generating image: {error}")

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "openai"
3-
version = "1.93.1"
3+
version = "1.97.1"
44
description = "The official Python library for the openai API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"
@@ -26,6 +26,7 @@ classifiers = [
2626
"Programming Language :: Python :: 3.10",
2727
"Programming Language :: Python :: 3.11",
2828
"Programming Language :: Python :: 3.12",
29+
"Programming Language :: Python :: 3.13",
2930
"Operating System :: OS Independent",
3031
"Operating System :: POSIX",
3132
"Operating System :: MacOS",
@@ -43,7 +44,7 @@ Repository = "https://github.com/openai/openai-python"
4344
openai = "openai.cli:main"
4445

4546
[project.optional-dependencies]
46-
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.6"]
47+
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.8"]
4748
realtime = ["websockets >= 13, < 16"]
4849
datalib = ["numpy >= 1", "pandas >= 1.2.3", "pandas-stubs >= 1.1.0.11"]
4950
voice_helpers = ["sounddevice>=0.5.1", "numpy>=2.0.2"]

requirements-dev.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ filelock==3.12.4
7373
frozenlist==1.7.0
7474
# via aiohttp
7575
# via aiosignal
76-
h11==0.14.0
76+
h11==0.16.0
7777
# via httpcore
78-
httpcore==1.0.2
78+
httpcore==1.0.9
7979
# via httpx
8080
httpx==0.28.1
8181
# via httpx-aiohttp

requirements.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ exceptiongroup==1.2.2
3838
frozenlist==1.7.0
3939
# via aiohttp
4040
# via aiosignal
41-
h11==0.14.0
41+
h11==0.16.0
4242
# via httpcore
43-
httpcore==1.0.2
43+
httpcore==1.0.9
4444
# via httpx
4545
httpx==0.28.1
4646
# via httpx-aiohttp

src/openai/_base_client.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,15 @@ def _build_request(
531531
# work around https://github.com/encode/httpx/discussions/2880
532532
kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")}
533533

534+
is_body_allowed = options.method.lower() != "get"
535+
536+
if is_body_allowed:
537+
kwargs["json"] = json_data if is_given(json_data) else None
538+
kwargs["files"] = files
539+
else:
540+
headers.pop("Content-Type", None)
541+
kwargs.pop("data", None)
542+
534543
# TODO: report this error to httpx
535544
return self._client.build_request( # pyright: ignore[reportUnknownMemberType]
536545
headers=headers,
@@ -542,8 +551,6 @@ def _build_request(
542551
# so that passing a `TypedDict` doesn't cause an error.
543552
# https://github.com/microsoft/pyright/issues/3526#event-6715453066
544553
params=self.qs.stringify(cast(Mapping[str, Any], params)) if params else None,
545-
json=json_data if is_given(json_data) else None,
546-
files=files,
547554
**kwargs,
548555
)
549556

0 commit comments

Comments
 (0)