Skip to content
Open
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 @@
{
".": "2.21.0"
".": "2.21.1"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 148
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-0db5326a0fb6a30ffad9242c72872c3388ef927e8a4549ddd20aec3420541209.yml
openapi_spec_hash: 9523fe30739802e15c88f4e7aac44e7f
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-46434d15307c0a84fad213c705ba29ab7342f27aa377e302d506a51cb784613b.yml
openapi_spec_hash: 4a64f88af6142d69d6e01dc9207f232a
config_hash: 948733484caf41e71093c6582dbc319c
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## 2.21.1 (2026-02-23)

Full Changelog: [v2.21.0...v2.21.1](https://github.com/openai/openai-python/compare/v2.21.0...v2.21.1)

### Chores

* **internal:** add request options to SSE classes ([cdb4315](https://github.com/openai/openai-python/commit/cdb4315ee29d5260bb373625d74cb523b4e3859c))
* update mock server docs ([91f4da8](https://github.com/openai/openai-python/commit/91f4da80ec3dba5d3566961560dfd6feb9c2feb0))


### Documentation

* **api:** add batch size limit to file_batches parameter descriptions ([16ae76a](https://github.com/openai/openai-python/commit/16ae76a20a47f94c91ee2ca0b2ada274633abab3))
* **api:** enhance method descriptions across audio, chat, realtime, skills, uploads, videos ([21f9e5a](https://github.com/openai/openai-python/commit/21f9e5aaf6ae27f0235fddb3ffa30fe73337f59b))
* **api:** update safety_identifier documentation in chat completions and responses ([d74bfff](https://github.com/openai/openai-python/commit/d74bfff62c1c2b32d4dc88fd47ae7b1b2a962017))

## 2.21.0 (2026-02-13)

Full Changelog: [v2.20.0...v2.21.0](https://github.com/openai/openai-python/compare/v2.20.0...v2.21.0)
Expand Down
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ $ pip install ./path-to-wheel-file.whl
Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests.

```sh
# you will need npm installed
$ npx prism mock path/to/your/openapi.yml
$ ./scripts/mock
```

```sh
Expand Down
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 = "2.21.0"
version = "2.21.1"
description = "The official Python library for the openai API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
3 changes: 3 additions & 0 deletions src/openai/_legacy_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
),
response=self.http_response,
client=cast(Any, self._client),
options=self._options,
),
)

Expand All @@ -231,6 +232,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
cast_to=extract_stream_chunk_type(self._stream_cls),
response=self.http_response,
client=cast(Any, self._client),
options=self._options,
),
)

Expand All @@ -244,6 +246,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
cast_to=cast_to,
response=self.http_response,
client=cast(Any, self._client),
options=self._options,
),
)

Expand Down
3 changes: 3 additions & 0 deletions src/openai/_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
),
response=self.http_response,
client=cast(Any, self._client),
options=self._options,
),
)

Expand All @@ -162,6 +163,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
cast_to=extract_stream_chunk_type(self._stream_cls),
response=self.http_response,
client=cast(Any, self._client),
options=self._options,
),
)

Expand All @@ -175,6 +177,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
cast_to=cast_to,
response=self.http_response,
client=cast(Any, self._client),
options=self._options,
),
)

Expand Down
11 changes: 8 additions & 3 deletions src/openai/_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
import inspect
from types import TracebackType
from typing import TYPE_CHECKING, Any, Generic, TypeVar, Iterator, AsyncIterator, cast
from typing import TYPE_CHECKING, Any, Generic, TypeVar, Iterator, Optional, AsyncIterator, cast
from typing_extensions import Self, Protocol, TypeGuard, override, get_origin, runtime_checkable

import httpx
Expand All @@ -14,6 +14,7 @@

if TYPE_CHECKING:
from ._client import OpenAI, AsyncOpenAI
from ._models import FinalRequestOptions


_T = TypeVar("_T")
Expand All @@ -23,7 +24,7 @@ class Stream(Generic[_T]):
"""Provides the core interface to iterate over a synchronous stream response."""

response: httpx.Response

_options: Optional[FinalRequestOptions] = None
_decoder: SSEBytesDecoder

def __init__(
Expand All @@ -32,10 +33,12 @@ def __init__(
cast_to: type[_T],
response: httpx.Response,
client: OpenAI,
options: Optional[FinalRequestOptions] = None,
) -> None:
self.response = response
self._cast_to = cast_to
self._client = client
self._options = options
self._decoder = client._make_sse_decoder()
self._iterator = self.__stream__()

Expand Down Expand Up @@ -125,7 +128,7 @@ class AsyncStream(Generic[_T]):
"""Provides the core interface to iterate over an asynchronous stream response."""

response: httpx.Response

_options: Optional[FinalRequestOptions] = None
_decoder: SSEDecoder | SSEBytesDecoder

def __init__(
Expand All @@ -134,10 +137,12 @@ def __init__(
cast_to: type[_T],
response: httpx.Response,
client: AsyncOpenAI,
options: Optional[FinalRequestOptions] = None,
) -> None:
self.response = response
self._cast_to = cast_to
self._client = client
self._options = options
self._decoder = client._make_sse_decoder()
self._iterator = self.__stream__()

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__ = "2.21.0" # x-release-please-version
__version__ = "2.21.1" # x-release-please-version
4 changes: 4 additions & 0 deletions src/openai/resources/audio/speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def create(
"""
Generates audio from the input text.

Returns the audio file content, or a stream of audio events.

Args:
input: The text to generate audio for. The maximum length is 4096 characters.

Expand Down Expand Up @@ -164,6 +166,8 @@ async def create(
"""
Generates audio from the input text.

Returns the audio file content, or a stream of audio events.

Args:
input: The text to generate audio for. The maximum length is 4096 characters.

Expand Down
18 changes: 18 additions & 0 deletions src/openai/resources/audio/transcriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ def create(
"""
Transcribes audio into the input language.

Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
format, or a stream of transcript events.

Args:
file:
The audio file object (not file name) to transcribe, in one of these formats:
Expand Down Expand Up @@ -235,6 +238,9 @@ def create(
"""
Transcribes audio into the input language.

Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
format, or a stream of transcript events.

Args:
file:
The audio file object (not file name) to transcribe, in one of these formats:
Expand Down Expand Up @@ -343,6 +349,9 @@ def create(
"""
Transcribes audio into the input language.

Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
format, or a stream of transcript events.

Args:
file:
The audio file object (not file name) to transcribe, in one of these formats:
Expand Down Expand Up @@ -533,6 +542,9 @@ async def create(
"""
Transcribes audio into the input language.

Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
format, or a stream of transcript events.

Args:
file:
The audio file object (not file name) to transcribe, in one of these formats:
Expand Down Expand Up @@ -678,6 +690,9 @@ async def create(
"""
Transcribes audio into the input language.

Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
format, or a stream of transcript events.

Args:
file:
The audio file object (not file name) to transcribe, in one of these formats:
Expand Down Expand Up @@ -786,6 +801,9 @@ async def create(
"""
Transcribes audio into the input language.

Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
format, or a stream of transcript events.

Args:
file:
The audio file object (not file name) to transcribe, in one of these formats:
Expand Down
12 changes: 8 additions & 4 deletions src/openai/resources/beta/chatkit/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def create(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ChatSession:
"""
Create a ChatKit session
Create a ChatKit session.

Args:
user: A free-form string that identifies your end user; ensures this Session can
Expand Down Expand Up @@ -117,7 +117,9 @@ def cancel(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ChatSession:
"""
Cancel a ChatKit session
Cancel an active ChatKit session and return its most recent metadata.

Cancelling prevents new requests from using the issued client secret.

Args:
extra_headers: Send extra headers
Expand Down Expand Up @@ -176,7 +178,7 @@ async def create(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ChatSession:
"""
Create a ChatKit session
Create a ChatKit session.

Args:
user: A free-form string that identifies your end user; ensures this Session can
Expand Down Expand Up @@ -230,7 +232,9 @@ async def cancel(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ChatSession:
"""
Cancel a ChatKit session
Cancel an active ChatKit session and return its most recent metadata.

Cancelling prevents new requests from using the issued client secret.

Args:
extra_headers: Send extra headers
Expand Down
16 changes: 8 additions & 8 deletions src/openai/resources/beta/chatkit/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def retrieve(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ChatKitThread:
"""
Retrieve a ChatKit thread
Retrieve a ChatKit thread by its identifier.

Args:
extra_headers: Send extra headers
Expand Down Expand Up @@ -93,7 +93,7 @@ def list(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncConversationCursorPage[ChatKitThread]:
"""
List ChatKit threads
List ChatKit threads with optional pagination and user filters.

Args:
after: List items created after this thread item ID. Defaults to null for the first
Expand Down Expand Up @@ -152,7 +152,7 @@ def delete(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ThreadDeleteResponse:
"""
Delete a ChatKit thread
Delete a ChatKit thread along with its items and stored attachments.

Args:
extra_headers: Send extra headers
Expand Down Expand Up @@ -190,7 +190,7 @@ def list_items(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncConversationCursorPage[Data]:
"""
List ChatKit thread items
List items that belong to a ChatKit thread.

Args:
after: List items created after this thread item ID. Defaults to null for the first
Expand Down Expand Up @@ -268,7 +268,7 @@ async def retrieve(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ChatKitThread:
"""
Retrieve a ChatKit thread
Retrieve a ChatKit thread by its identifier.

Args:
extra_headers: Send extra headers
Expand Down Expand Up @@ -306,7 +306,7 @@ def list(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[ChatKitThread, AsyncConversationCursorPage[ChatKitThread]]:
"""
List ChatKit threads
List ChatKit threads with optional pagination and user filters.

Args:
after: List items created after this thread item ID. Defaults to null for the first
Expand Down Expand Up @@ -365,7 +365,7 @@ async def delete(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ThreadDeleteResponse:
"""
Delete a ChatKit thread
Delete a ChatKit thread along with its items and stored attachments.

Args:
extra_headers: Send extra headers
Expand Down Expand Up @@ -403,7 +403,7 @@ def list_items(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncPaginator[Data, AsyncConversationCursorPage[Data]]:
"""
List ChatKit thread items
List items that belong to a ChatKit thread.

Args:
after: List items created after this thread item ID. Defaults to null for the first
Expand Down
Loading