Skip to content

Commit 18a49e6

Browse files
authored
Merge branch 'main' into chore/client-comment-fix
2 parents f6de1a0 + a3315d9 commit 18a49e6

File tree

109 files changed

+3192
-558
lines changed

Some content is hidden

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

109 files changed

+3192
-558
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
timeout-minutes: 10
1818
name: lint
1919
runs-on: ${{ github.repository == 'stainless-sdks/openai-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
20+
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
2021
steps:
2122
- uses: actions/checkout@v4
2223

@@ -34,17 +35,31 @@ jobs:
3435
- name: Run lints
3536
run: ./scripts/lint
3637

37-
upload:
38-
if: github.repository == 'stainless-sdks/openai-python'
38+
build:
39+
if: github.repository == 'stainless-sdks/openai-python' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork)
3940
timeout-minutes: 10
40-
name: upload
41+
name: build
4142
permissions:
4243
contents: read
4344
id-token: write
4445
runs-on: depot-ubuntu-24.04
4546
steps:
4647
- uses: actions/checkout@v4
4748

49+
- name: Install Rye
50+
run: |
51+
curl -sSf https://rye.astral.sh/get | bash
52+
echo "$HOME/.rye/shims" >> $GITHUB_PATH
53+
env:
54+
RYE_VERSION: '0.44.0'
55+
RYE_INSTALL_OPTION: '--yes'
56+
57+
- name: Install dependencies
58+
run: rye sync --all-features
59+
60+
- name: Run build
61+
run: rye build
62+
4863
- name: Get GitHub OIDC Token
4964
id: github-oidc
5065
uses: actions/github-script@v6
@@ -62,6 +77,7 @@ jobs:
6277
timeout-minutes: 10
6378
name: test
6479
runs-on: ${{ github.repository == 'stainless-sdks/openai-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
80+
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
6581
steps:
6682
- uses: actions/checkout@v4
6783

@@ -83,7 +99,7 @@ jobs:
8399
timeout-minutes: 10
84100
name: examples
85101
runs-on: ${{ github.repository == 'stainless-sdks/openai-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
86-
if: github.repository == 'openai/openai-python'
102+
if: github.repository == 'openai/openai-python' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork)
87103

88104
steps:
89105
- uses: actions/checkout@v4

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.prism.log
2-
.vscode
32
_dev
43

54
__pycache__

.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.0"
2+
".": "1.98.0"
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-721e6ccaa72205ee14c71f8163129920464fb814b95d3df9567a9476bbd9b7fb.yml
3+
openapi_spec_hash: 2115413a21df8b5bf9e4552a74df4312
4+
config_hash: 9606bb315a193bfd8da0459040143242

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.analysis.importFormat": "relative",
3+
}

CHANGELOG.md

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

3+
## 1.98.0 (2025-07-30)
4+
5+
Full Changelog: [v1.97.2...v1.98.0](https://github.com/openai/openai-python/compare/v1.97.2...v1.98.0)
6+
7+
### Features
8+
9+
* **api:** manual updates ([88a8036](https://github.com/openai/openai-python/commit/88a8036c5ea186f36c57029ef4501a0833596f56))
10+
11+
## 1.97.2 (2025-07-30)
12+
13+
Full Changelog: [v1.97.1...v1.97.2](https://github.com/openai/openai-python/compare/v1.97.1...v1.97.2)
14+
15+
### Chores
16+
17+
* **client:** refactor streaming slightly to better future proof it ([71c0c74](https://github.com/openai/openai-python/commit/71c0c747132221b798e419bc5a37baf67173d34e))
18+
* **project:** add settings file for vscode ([29c22c9](https://github.com/openai/openai-python/commit/29c22c90fd229983355089f95d0bba9de15efedb))
19+
20+
## 1.97.1 (2025-07-22)
21+
22+
Full Changelog: [v1.97.0...v1.97.1](https://github.com/openai/openai-python/compare/v1.97.0...v1.97.1)
23+
24+
### Bug Fixes
25+
26+
* **parsing:** ignore empty metadata ([58c359f](https://github.com/openai/openai-python/commit/58c359ff67fd6103268e4405600fd58844b6f27b))
27+
* **parsing:** parse extra field types ([d524b7e](https://github.com/openai/openai-python/commit/d524b7e201418ccc9b5c2206da06d1be011808e5))
28+
29+
30+
### Chores
31+
32+
* **api:** event shapes more accurate ([f3a9a92](https://github.com/openai/openai-python/commit/f3a9a9229280ecb7e0b2779dd44290df6d9824ef))
33+
34+
## 1.97.0 (2025-07-16)
35+
36+
Full Changelog: [v1.96.1...v1.97.0](https://github.com/openai/openai-python/compare/v1.96.1...v1.97.0)
37+
38+
### Features
39+
40+
* **api:** manual updates ([ed8e899](https://github.com/openai/openai-python/commit/ed8e89953d11bd5f44fa531422bdbb7a577ab426))
41+
42+
## 1.96.1 (2025-07-15)
43+
44+
Full Changelog: [v1.96.0...v1.96.1](https://github.com/openai/openai-python/compare/v1.96.0...v1.96.1)
45+
46+
### Chores
47+
48+
* **api:** update realtime specs ([b68b71b](https://github.com/openai/openai-python/commit/b68b71b178719e0b49ecfe34486b9d9ac0627924))
49+
50+
## 1.96.0 (2025-07-15)
51+
52+
Full Changelog: [v1.95.1...v1.96.0](https://github.com/openai/openai-python/compare/v1.95.1...v1.96.0)
53+
54+
### Features
55+
56+
* clean up environment call outs ([87c2e97](https://github.com/openai/openai-python/commit/87c2e979e0ec37347b7f595c2696408acd25fe20))
57+
58+
59+
### Chores
60+
61+
* **api:** update realtime specs, build config ([bf06d88](https://github.com/openai/openai-python/commit/bf06d88b33f9af82a51d9a8af5b7a38925906f7a))
62+
63+
## 1.95.1 (2025-07-11)
64+
65+
Full Changelog: [v1.95.0...v1.95.1](https://github.com/openai/openai-python/compare/v1.95.0...v1.95.1)
66+
67+
### Bug Fixes
68+
69+
* **client:** don't send Content-Type header on GET requests ([182b763](https://github.com/openai/openai-python/commit/182b763065fbaaf68491a7e4a15fcb23cac361de))
70+
71+
## 1.95.0 (2025-07-10)
72+
73+
Full Changelog: [v1.94.0...v1.95.0](https://github.com/openai/openai-python/compare/v1.94.0...v1.95.0)
74+
75+
### Features
76+
77+
* **api:** add file_url, fix event ID ([265e216](https://github.com/openai/openai-python/commit/265e216396196d66cdfb5f92c5ef1a2a6ff27b5b))
78+
79+
80+
### Chores
81+
82+
* **readme:** fix version rendering on pypi ([1eee5ca](https://github.com/openai/openai-python/commit/1eee5cabf2fd93877cd3ba85d0c6ed2ffd5f159f))
83+
84+
## 1.94.0 (2025-07-10)
85+
86+
Full Changelog: [v1.93.3...v1.94.0](https://github.com/openai/openai-python/compare/v1.93.3...v1.94.0)
87+
88+
### Features
89+
90+
* **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))
91+
92+
## 1.93.3 (2025-07-09)
93+
94+
Full Changelog: [v1.93.2...v1.93.3](https://github.com/openai/openai-python/compare/v1.93.2...v1.93.3)
95+
96+
### Bug Fixes
97+
98+
* **parsing:** correctly handle nested discriminated unions ([fc8a677](https://github.com/openai/openai-python/commit/fc8a67715d8f1b45d8639b8b6f9f6590fe358734))
99+
100+
## 1.93.2 (2025-07-08)
101+
102+
Full Changelog: [v1.93.1...v1.93.2](https://github.com/openai/openai-python/compare/v1.93.1...v1.93.2)
103+
104+
### Chores
105+
106+
* **internal:** bump pinned h11 dep ([4fca6ae](https://github.com/openai/openai-python/commit/4fca6ae2d0d7f27cbac8d06c3917932767c8c6b8))
107+
* **package:** mark python 3.13 as supported ([2229047](https://github.com/openai/openai-python/commit/2229047b8a549df16c617bddfe3b4521cfd257a5))
108+
109+
## 1.93.1 (2025-07-07)
110+
111+
Full Changelog: [v1.93.0...v1.93.1](https://github.com/openai/openai-python/compare/v1.93.0...v1.93.1)
112+
113+
### Bug Fixes
114+
115+
* **ci:** correct conditional ([de6a9ce](https://github.com/openai/openai-python/commit/de6a9ce078731d60b0bdc42a9322548c575f11a3))
116+
* **responses:** add missing arguments to parse ([05590ec](https://github.com/openai/openai-python/commit/05590ec2a96399afd05baf5a3ee1d9a744f09c40))
117+
* **vector stores:** add missing arguments to files.create_and_poll ([3152134](https://github.com/openai/openai-python/commit/3152134510532ec7c522d6b50a820deea205b602))
118+
* **vector stores:** add missing arguments to files.upload_and_poll ([9d4f425](https://github.com/openai/openai-python/commit/9d4f42569d5b59311453b1b11ee1dd2e8a271268))
119+
120+
121+
### Chores
122+
123+
* **ci:** change upload type ([cd4aa88](https://github.com/openai/openai-python/commit/cd4aa889c50581d861728c9606327992485f0d0d))
124+
* **ci:** only run for pushes and fork pull requests ([f89c7eb](https://github.com/openai/openai-python/commit/f89c7eb46c6f081254715d75543cbee3ffa83822))
125+
* **internal:** codegen related update ([bddb8d2](https://github.com/openai/openai-python/commit/bddb8d2091455920e8526068d64f3f8a5cac7ae6))
126+
* **tests:** ensure parse method is in sync with create ([4f58e18](https://github.com/openai/openai-python/commit/4f58e187c12dc8b2c33e9cca284b0429e5cc4de5))
127+
* **tests:** ensure vector store files create and poll method is in sync ([0fe75a2](https://github.com/openai/openai-python/commit/0fe75a28f6109b2d25b015dc99472a06693e0e9f))
128+
3129
## 1.93.0 (2025-06-27)
4130

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

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.0"
3+
version = "1.98.0"
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"]

0 commit comments

Comments
 (0)