Skip to content
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.73.0"
".": "1.74.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 97
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-44b20fa9d24544217fe6bb48852037537030a1ad29b202936425110744fe66fb.yml
openapi_spec_hash: ea86343b5e9858a74e85da8ab2c532f6
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-a555f81249cb084f463dcefa4aba069f9341fdaf3dd6ac27d7f237fc90e8f488.yml
openapi_spec_hash: 8e590296cd1a54b9508510b0c7a2c45a
config_hash: 5ea32de61ff42fcf5e66cff8d9e247ea
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## 1.74.0 (2025-04-14)

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

### Features

* **api:** adding gpt-4.1 family of model IDs ([d4dae55](https://github.com/openai/openai-python/commit/d4dae5553ff3a2879b9ab79a6423661b212421f9))


### Bug Fixes

* **chat:** skip azure async filter events ([#2255](https://github.com/openai/openai-python/issues/2255)) ([fd3a38b](https://github.com/openai/openai-python/commit/fd3a38b1ed30af0a9f3302c1cfc6be6b352e65de))


### Chores

* **client:** minor internal fixes ([6071ae5](https://github.com/openai/openai-python/commit/6071ae5e8b4faa465afc8d07370737e66901900a))
* **internal:** update pyright settings ([c8f8beb](https://github.com/openai/openai-python/commit/c8f8bebf852380a224701bc36826291d6387c53d))

## 1.73.0 (2025-04-12)

Full Changelog: [v1.72.0...v1.73.0](https://github.com/openai/openai-python/compare/v1.72.0...v1.73.0)
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "openai"
version = "1.73.0"
version = "1.74.0"
description = "The official Python library for the openai API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down Expand Up @@ -166,6 +166,7 @@ exclude = [
]

reportImplicitOverride = true
reportOverlappingOverload = false

reportImportCycles = false
reportPrivateUsage = false
Expand Down
11 changes: 10 additions & 1 deletion src/openai/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,8 @@ def _build_headers(self, options: FinalRequestOptions, *, retries_taken: int = 0

idempotency_header = self._idempotency_header
if idempotency_header and options.method.lower() != "get" and idempotency_header not in headers:
headers[idempotency_header] = options.idempotency_key or self._idempotency_key()
options.idempotency_key = options.idempotency_key or self._idempotency_key()
headers[idempotency_header] = options.idempotency_key

# Don't set these headers if they were already set or removed by the caller. We check
# `custom_headers`, which can contain `Omit()`, instead of `headers` to account for the removal case.
Expand Down Expand Up @@ -945,6 +946,10 @@ def _request(
request = self._build_request(options, retries_taken=retries_taken)
self._prepare_request(request)

if options.idempotency_key:
# ensure the idempotency key is reused between requests
input_options.idempotency_key = options.idempotency_key

kwargs: HttpxSendArgs = {}
if self.custom_auth is not None:
kwargs["auth"] = self.custom_auth
Expand Down Expand Up @@ -1492,6 +1497,10 @@ async def _request(
request = self._build_request(options, retries_taken=retries_taken)
await self._prepare_request(request)

if options.idempotency_key:
# ensure the idempotency key is reused between requests
input_options.idempotency_key = options.idempotency_key

kwargs: HttpxSendArgs = {}
if self.custom_auth is not None:
kwargs["auth"] = self.custom_auth
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.73.0" # x-release-please-version
__version__ = "1.74.0" # x-release-please-version
13 changes: 13 additions & 0 deletions src/openai/lib/streaming/chat/_completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ def current_completion_snapshot(self) -> ParsedChatCompletionSnapshot:

def __stream__(self) -> Iterator[ChatCompletionStreamEvent[ResponseFormatT]]:
for sse_event in self._raw_stream:
if not _is_valid_chat_completion_chunk_weak(sse_event):
continue
events_to_fire = self._state.handle_chunk(sse_event)
for event in events_to_fire:
yield event
Expand Down Expand Up @@ -234,6 +236,8 @@ def current_completion_snapshot(self) -> ParsedChatCompletionSnapshot:

async def __stream__(self) -> AsyncIterator[ChatCompletionStreamEvent[ResponseFormatT]]:
async for sse_event in self._raw_stream:
if not _is_valid_chat_completion_chunk_weak(sse_event):
continue
events_to_fire = self._state.handle_chunk(sse_event)
for event in events_to_fire:
yield event
Expand Down Expand Up @@ -753,3 +757,12 @@ def _convert_initial_chunk_into_snapshot(chunk: ChatCompletionChunk) -> ParsedCh
},
),
)


def _is_valid_chat_completion_chunk_weak(sse_event: ChatCompletionChunk) -> bool:
# Although the _raw_stream is always supposed to contain only objects adhering to ChatCompletionChunk schema,
# this is broken by the Azure OpenAI in case of Asynchronous Filter enabled.
# An easy filter is to check for the "object" property:
# - should be "chat.completion.chunk" for a ChatCompletionChunk;
# - is an empty string for Asynchronous Filter events.
return sse_event.object == "chat.completion.chunk" # type: ignore # pylance reports this as a useless check
12 changes: 12 additions & 0 deletions src/openai/resources/beta/assistants.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ def update(
model: Union[
str,
Literal[
"gpt-4.1",
"gpt-4.1-mini",
"gpt-4.1-nano",
"gpt-4.1-2025-04-14",
"gpt-4.1-mini-2025-04-14",
"gpt-4.1-nano-2025-04-14",
"o3-mini",
"o3-mini-2025-01-31",
"o1",
Expand Down Expand Up @@ -666,6 +672,12 @@ async def update(
model: Union[
str,
Literal[
"gpt-4.1",
"gpt-4.1-mini",
"gpt-4.1-nano",
"gpt-4.1-2025-04-14",
"gpt-4.1-mini-2025-04-14",
"gpt-4.1-nano-2025-04-14",
"o3-mini",
"o3-mini-2025-01-31",
"o1",
Expand Down
6 changes: 6 additions & 0 deletions src/openai/types/beta/assistant_update_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ class AssistantUpdateParams(TypedDict, total=False):
model: Union[
str,
Literal[
"gpt-4.1",
"gpt-4.1-mini",
"gpt-4.1-nano",
"gpt-4.1-2025-04-14",
"gpt-4.1-mini-2025-04-14",
"gpt-4.1-nano-2025-04-14",
"o3-mini",
"o3-mini-2025-01-31",
"o1",
Expand Down
6 changes: 6 additions & 0 deletions src/openai/types/shared/chat_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
__all__ = ["ChatModel"]

ChatModel: TypeAlias = Literal[
"gpt-4.1",
"gpt-4.1-mini",
"gpt-4.1-nano",
"gpt-4.1-2025-04-14",
"gpt-4.1-mini-2025-04-14",
"gpt-4.1-nano-2025-04-14",
"o3-mini",
"o3-mini-2025-01-31",
"o1",
Expand Down
6 changes: 6 additions & 0 deletions src/openai/types/shared_params/chat_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
__all__ = ["ChatModel"]

ChatModel: TypeAlias = Literal[
"gpt-4.1",
"gpt-4.1-mini",
"gpt-4.1-nano",
"gpt-4.1-2025-04-14",
"gpt-4.1-mini-2025-04-14",
"gpt-4.1-nano-2025-04-14",
"o3-mini",
"o3-mini-2025-01-31",
"o1",
Expand Down