Skip to content

Commit 1c3180c

Browse files
Merge branch 'main' into main
2 parents d5f8921 + 41ee03f commit 1c3180c

File tree

185 files changed

+7662
-627
lines changed

Some content is hidden

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

185 files changed

+7662
-627
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-
".": "2.1.0"
2+
".": "2.8.1"
33
}

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 123
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-fadefdc7c7e30df47c09df323669b242ff90ee08e51f304175ace5274e0aab49.yml
3-
openapi_spec_hash: 6d20f639d9ff8a097a34962da6218231
4-
config_hash: 902654e60f5d659f2bfcfd903e17c46d
1+
configured_endpoints: 136
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-a7e92d12ebe89ca019a7ac5b29759064eefa2c38fe08d03516f2620e66abb32b.yml
3+
openapi_spec_hash: acbc703b2739447abc6312b2d753631c
4+
config_hash: b876221dfb213df9f0a999e75d38a65e

CHANGELOG.md

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

3+
## 2.8.1 (2025-11-17)
4+
5+
Full Changelog: [v2.8.0...v2.8.1](https://github.com/openai/openai-python/compare/v2.8.0...v2.8.1)
6+
7+
### Bug Fixes
8+
9+
* **api:** align types of input items / output items for typescript ([64c9fb3](https://github.com/openai/openai-python/commit/64c9fb3fcc79f0049b3a36bd429faf0600d969f6))
10+
11+
## 2.8.0 (2025-11-13)
12+
13+
Full Changelog: [v2.7.2...v2.8.0](https://github.com/openai/openai-python/compare/v2.7.2...v2.8.0)
14+
15+
### Features
16+
17+
* **api:** gpt 5.1 ([8d9f2ca](https://github.com/openai/openai-python/commit/8d9f2cab4cb2e12f6e2ab1de967f858736a656ac))
18+
19+
20+
### Bug Fixes
21+
22+
* **compat:** update signatures of `model_dump` and `model_dump_json` for Pydantic v1 ([c7bd234](https://github.com/openai/openai-python/commit/c7bd234b18239fcdbf0edb1b51ca9116c0ac7251))
23+
24+
## 2.7.2 (2025-11-10)
25+
26+
Full Changelog: [v2.7.1...v2.7.2](https://github.com/openai/openai-python/compare/v2.7.1...v2.7.2)
27+
28+
### Bug Fixes
29+
30+
* compat with Python 3.14 ([15a7ec8](https://github.com/openai/openai-python/commit/15a7ec8a753d7f57d525fca60c547fd5331cb214))
31+
32+
33+
### Chores
34+
35+
* **package:** drop Python 3.8 support ([afc14f2](https://github.com/openai/openai-python/commit/afc14f2e42e7a8174f2ff1a5672829b808a716bf))
36+
37+
## 2.7.1 (2025-11-04)
38+
39+
Full Changelog: [v2.7.0...v2.7.1](https://github.com/openai/openai-python/compare/v2.7.0...v2.7.1)
40+
41+
### Bug Fixes
42+
43+
* **api:** fix nullability of logprobs ([373b7f6](https://github.com/openai/openai-python/commit/373b7f6e4255dfef3ccd92520011e8ba44e8b7f0))
44+
45+
## 2.7.0 (2025-11-03)
46+
47+
Full Changelog: [v2.6.1...v2.7.0](https://github.com/openai/openai-python/compare/v2.6.1...v2.7.0)
48+
49+
### Features
50+
51+
* **api:** Realtime API token_limits, Hybrid searching ranking options ([5b43992](https://github.com/openai/openai-python/commit/5b4399219d7ed326411aec524d25ef2b8e3152fc))
52+
* **api:** remove InputAudio from ResponseInputContent ([bd70a33](https://github.com/openai/openai-python/commit/bd70a33234741fa68c185105e4f53cc0275a2a50))
53+
54+
55+
### Bug Fixes
56+
57+
* **client:** close streams without requiring full consumption ([d8bb7d6](https://github.com/openai/openai-python/commit/d8bb7d6d728c5481de4198eebe668b67803ae14a))
58+
* **readme:** update realtime examples ([#2714](https://github.com/openai/openai-python/issues/2714)) ([d0370a8](https://github.com/openai/openai-python/commit/d0370a8d61fc2f710a34d8aad48f649a9683106d))
59+
* **uploads:** avoid file handle leak ([4f1b691](https://github.com/openai/openai-python/commit/4f1b691ab4db41aebd397ec41942b43fb0f0743c))
60+
61+
62+
### Chores
63+
64+
* **internal/tests:** avoid race condition with implicit client cleanup ([933d23b](https://github.com/openai/openai-python/commit/933d23bd8d7809c77e0796becfe052167d44d40a))
65+
* **internal:** grammar fix (it's -> its) ([f7e9e9e](https://github.com/openai/openai-python/commit/f7e9e9e4f43039f19a41375a6d2b2bdc2264dad7))
66+
67+
## 2.6.1 (2025-10-24)
68+
69+
Full Changelog: [v2.6.0...v2.6.1](https://github.com/openai/openai-python/compare/v2.6.0...v2.6.1)
70+
71+
### Bug Fixes
72+
73+
* **api:** docs updates ([d01a0c9](https://github.com/openai/openai-python/commit/d01a0c96ecb94c78b7e16546790c573704b7515b))
74+
75+
76+
### Chores
77+
78+
* **client:** clean up custom translations code ([cfb9e25](https://github.com/openai/openai-python/commit/cfb9e25855b8eb020abe02cdd99566adf474e821))
79+
80+
## 2.6.0 (2025-10-20)
81+
82+
Full Changelog: [v2.5.0...v2.6.0](https://github.com/openai/openai-python/compare/v2.5.0...v2.6.0)
83+
84+
### Features
85+
86+
* **api:** Add responses.input_tokens.count ([6dd09e2](https://github.com/openai/openai-python/commit/6dd09e2829f385f72b28620888d91a4493c96772))
87+
88+
89+
### Bug Fixes
90+
91+
* **api:** internal openapi updates ([caabd7c](https://github.com/openai/openai-python/commit/caabd7c81f0f557f66dc0089af460185a5816c11))
92+
93+
## 2.5.0 (2025-10-17)
94+
95+
Full Changelog: [v2.4.0...v2.5.0](https://github.com/openai/openai-python/compare/v2.4.0...v2.5.0)
96+
97+
### Features
98+
99+
* **api:** api update ([8b280d5](https://github.com/openai/openai-python/commit/8b280d57d6d361bc3a032e030158f6859c445291))
100+
101+
102+
### Chores
103+
104+
* bump `httpx-aiohttp` version to 0.1.9 ([67f2f0a](https://github.com/openai/openai-python/commit/67f2f0afe51dab9d5899fe18b1a4e86b2c774d10))
105+
106+
## 2.4.0 (2025-10-16)
107+
108+
Full Changelog: [v2.3.0...v2.4.0](https://github.com/openai/openai-python/compare/v2.3.0...v2.4.0)
109+
110+
### Features
111+
112+
* **api:** Add support for gpt-4o-transcribe-diarize on audio/transcriptions endpoint ([bdbe9b8](https://github.com/openai/openai-python/commit/bdbe9b8f440209afa2979db4a9eda9579b3d2550))
113+
114+
115+
### Chores
116+
117+
* fix dangling comment ([da14e99](https://github.com/openai/openai-python/commit/da14e9960608f7ade6f5cdf91967830c8a6c1657))
118+
* **internal:** detect missing future annotations with ruff ([2672b8f](https://github.com/openai/openai-python/commit/2672b8f0726300f7c62c356f25545ef0b3c0bb2e))
119+
120+
## 2.3.0 (2025-10-10)
121+
122+
Full Changelog: [v2.2.0...v2.3.0](https://github.com/openai/openai-python/compare/v2.2.0...v2.3.0)
123+
124+
### Features
125+
126+
* **api:** comparison filter in/not in ([aa49f62](https://github.com/openai/openai-python/commit/aa49f626a6ea9d77ad008badfb3741e16232d62f))
127+
128+
129+
### Chores
130+
131+
* **package:** bump jiter to >=0.10.0 to support Python 3.14 ([#2618](https://github.com/openai/openai-python/issues/2618)) ([aa445ca](https://github.com/openai/openai-python/commit/aa445cab5c93c6908697fe98e73e16963330b141))
132+
133+
## 2.2.0 (2025-10-06)
134+
135+
Full Changelog: [v2.1.0...v2.2.0](https://github.com/openai/openai-python/compare/v2.1.0...v2.2.0)
136+
137+
### Features
138+
139+
* **api:** dev day 2025 launches ([38ac009](https://github.com/openai/openai-python/commit/38ac0093ebb3419b1e2280d0dc2d26c74a2bbbec))
140+
141+
142+
### Bug Fixes
143+
144+
* **client:** add chatkit to beta resource ([de3e561](https://github.com/openai/openai-python/commit/de3e5619d0a85b17906a9416039ef309e820dc0f))
145+
3146
## 2.1.0 (2025-10-02)
4147

5148
Full Changelog: [v2.0.1...v2.1.0](https://github.com/openai/openai-python/compare/v2.0.1...v2.1.0)

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<!-- prettier-ignore -->
44
[![PyPI version](https://img.shields.io/pypi/v/openai.svg?label=pypi%20(stable))](https://pypi.org/project/openai/)
55

6-
The OpenAI Python library provides convenient access to the OpenAI REST API from any Python 3.8+
6+
The OpenAI Python library provides convenient access to the OpenAI REST API from any Python 3.9+
77
application. The library includes type definitions for all request params and response fields,
88
and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).
99

@@ -244,7 +244,9 @@ async def main():
244244
client = AsyncOpenAI()
245245

246246
async with client.realtime.connect(model="gpt-realtime") as connection:
247-
await connection.session.update(session={'modalities': ['text']})
247+
await connection.session.update(
248+
session={"type": "realtime", "output_modalities": ["text"]}
249+
)
248250

249251
await connection.conversation.item.create(
250252
item={
@@ -256,10 +258,10 @@ async def main():
256258
await connection.response.create()
257259

258260
async for event in connection:
259-
if event.type == 'response.text.delta':
261+
if event.type == "response.output_text.delta":
260262
print(event.delta, flush=True, end="")
261263

262-
elif event.type == 'response.text.done':
264+
elif event.type == "response.output_text.done":
263265
print()
264266

265267
elif event.type == "response.done":
@@ -861,7 +863,7 @@ print(openai.__version__)
861863

862864
## Requirements
863865

864-
Python 3.8 or higher.
866+
Python 3.9 or higher.
865867

866868
## Contributing
867869

api.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,14 @@ Types:
171171
```python
172172
from openai.types.audio import (
173173
Transcription,
174+
TranscriptionDiarized,
175+
TranscriptionDiarizedSegment,
174176
TranscriptionInclude,
175177
TranscriptionSegment,
176178
TranscriptionStreamEvent,
177179
TranscriptionTextDeltaEvent,
178180
TranscriptionTextDoneEvent,
181+
TranscriptionTextSegmentEvent,
179182
TranscriptionVerbose,
180183
TranscriptionWord,
181184
TranscriptionCreateResponse,
@@ -729,12 +732,16 @@ Types:
729732

730733
```python
731734
from openai.types.responses import (
735+
ApplyPatchTool,
732736
ComputerTool,
733737
CustomTool,
734738
EasyInputMessage,
735739
FileSearchTool,
740+
FunctionShellTool,
736741
FunctionTool,
737742
Response,
743+
ResponseApplyPatchToolCall,
744+
ResponseApplyPatchToolCallOutput,
738745
ResponseAudioDeltaEvent,
739746
ResponseAudioDoneEvent,
740747
ResponseAudioTranscriptDeltaEvent,
@@ -771,6 +778,9 @@ from openai.types.responses import (
771778
ResponseFunctionCallArgumentsDoneEvent,
772779
ResponseFunctionCallOutputItem,
773780
ResponseFunctionCallOutputItemList,
781+
ResponseFunctionShellCallOutputContent,
782+
ResponseFunctionShellToolCall,
783+
ResponseFunctionShellToolCallOutput,
774784
ResponseFunctionToolCall,
775785
ResponseFunctionToolCallItem,
776786
ResponseFunctionToolCallOutputItem,
@@ -833,10 +843,12 @@ from openai.types.responses import (
833843
ResponseWebSearchCallSearchingEvent,
834844
Tool,
835845
ToolChoiceAllowed,
846+
ToolChoiceApplyPatch,
836847
ToolChoiceCustom,
837848
ToolChoiceFunction,
838849
ToolChoiceMcp,
839850
ToolChoiceOptions,
851+
ToolChoiceShell,
840852
ToolChoiceTypes,
841853
WebSearchPreviewTool,
842854
WebSearchTool,
@@ -862,6 +874,18 @@ Methods:
862874

863875
- <code title="get /responses/{response_id}/input_items">client.responses.input_items.<a href="./src/openai/resources/responses/input_items.py">list</a>(response_id, \*\*<a href="src/openai/types/responses/input_item_list_params.py">params</a>) -> <a href="./src/openai/types/responses/response_item.py">SyncCursorPage[ResponseItem]</a></code>
864876

877+
## InputTokens
878+
879+
Types:
880+
881+
```python
882+
from openai.types.responses import InputTokenCountResponse
883+
```
884+
885+
Methods:
886+
887+
- <code title="post /responses/input_tokens">client.responses.input_tokens.<a href="./src/openai/resources/responses/input_tokens.py">count</a>(\*\*<a href="src/openai/types/responses/input_token_count_params.py">params</a>) -> <a href="./src/openai/types/responses/input_token_count_response.py">InputTokenCountResponse</a></code>
888+
865889
# Realtime
866890

867891
Types:
@@ -1139,3 +1163,29 @@ Methods:
11391163
Methods:
11401164

11411165
- <code title="get /containers/{container_id}/files/{file_id}/content">client.containers.files.content.<a href="./src/openai/resources/containers/files/content.py">retrieve</a>(file_id, \*, container_id) -> HttpxBinaryResponseContent</code>
1166+
1167+
# Videos
1168+
1169+
Types:
1170+
1171+
```python
1172+
from openai.types import (
1173+
Video,
1174+
VideoCreateError,
1175+
VideoModel,
1176+
VideoSeconds,
1177+
VideoSize,
1178+
VideoDeleteResponse,
1179+
)
1180+
```
1181+
1182+
Methods:
1183+
1184+
- <code title="post /videos">client.videos.<a href="./src/openai/resources/videos.py">create</a>(\*\*<a href="src/openai/types/video_create_params.py">params</a>) -> <a href="./src/openai/types/video.py">Video</a></code>
1185+
- <code title="get /videos/{video_id}">client.videos.<a href="./src/openai/resources/videos.py">retrieve</a>(video_id) -> <a href="./src/openai/types/video.py">Video</a></code>
1186+
- <code title="get /videos">client.videos.<a href="./src/openai/resources/videos.py">list</a>(\*\*<a href="src/openai/types/video_list_params.py">params</a>) -> <a href="./src/openai/types/video.py">SyncConversationCursorPage[Video]</a></code>
1187+
- <code title="delete /videos/{video_id}">client.videos.<a href="./src/openai/resources/videos.py">delete</a>(video_id) -> <a href="./src/openai/types/video_delete_response.py">VideoDeleteResponse</a></code>
1188+
- <code title="get /videos/{video_id}/content">client.videos.<a href="./src/openai/resources/videos.py">download_content</a>(video_id, \*\*<a href="src/openai/types/video_download_content_params.py">params</a>) -> HttpxBinaryResponseContent</code>
1189+
- <code title="post /videos/{video_id}/remix">client.videos.<a href="./src/openai/resources/videos.py">remix</a>(video_id, \*\*<a href="src/openai/types/video_remix_params.py">params</a>) -> <a href="./src/openai/types/video.py">Video</a></code>
1190+
- <code>client.videos.<a href="./src/openai/resources/videos.py">create_and_poll</a>(\*args) -> Video</code>
1191+

examples/responses_input_tokens.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from typing import List
2+
3+
from openai import OpenAI
4+
from openai.types.responses.tool_param import ToolParam
5+
from openai.types.responses.response_input_item_param import ResponseInputItemParam
6+
7+
8+
def main() -> None:
9+
client = OpenAI()
10+
tools: List[ToolParam] = [
11+
{
12+
"type": "function",
13+
"name": "get_current_weather",
14+
"description": "Get current weather in a given location",
15+
"parameters": {
16+
"type": "object",
17+
"properties": {
18+
"location": {
19+
"type": "string",
20+
"description": "City and state, e.g. San Francisco, CA",
21+
},
22+
"unit": {
23+
"type": "string",
24+
"enum": ["c", "f"],
25+
"description": "Temperature unit to use",
26+
},
27+
},
28+
"required": ["location", "unit"],
29+
"additionalProperties": False,
30+
},
31+
"strict": True,
32+
}
33+
]
34+
35+
input_items: List[ResponseInputItemParam] = [
36+
{
37+
"type": "message",
38+
"role": "user",
39+
"content": [{"type": "input_text", "text": "What's the weather in San Francisco today?"}],
40+
}
41+
]
42+
43+
response = client.responses.input_tokens.count(
44+
model="gpt-5",
45+
instructions="You are a concise assistant.",
46+
input=input_items,
47+
tools=tools,
48+
tool_choice={"type": "function", "name": "get_current_weather"},
49+
)
50+
print(f"input tokens: {response.input_tokens}")
51+
52+
53+
if __name__ == "__main__":
54+
main()

examples/video.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env -S poetry run python
2+
3+
import asyncio
4+
5+
from openai import AsyncOpenAI
6+
7+
client = AsyncOpenAI()
8+
9+
10+
async def main() -> None:
11+
video = await client.videos.create_and_poll(
12+
model="sora-2",
13+
prompt="A video of the words 'Thank you' in sparkling letters",
14+
)
15+
16+
if video.status == "completed":
17+
print("Video successfully completed: ", video)
18+
else:
19+
print("Video creation failed. Status: ", video.status)
20+
21+
22+
asyncio.run(main())

helpers.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,4 +514,5 @@ client.beta.vector_stores.files.upload_and_poll(...)
514514
client.beta.vector_stores.files.create_and_poll(...)
515515
client.beta.vector_stores.file_batches.create_and_poll(...)
516516
client.beta.vector_stores.file_batches.upload_and_poll(...)
517+
client.videos.create_and_poll(...)
517518
```

0 commit comments

Comments
 (0)