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 @@
{
".": "2.5.0"
".": "2.6.0"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 135
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-f59befea071ed7729cbb7bce219e7f837eccfdb57e01698514e6a0bd6052ff60.yml
openapi_spec_hash: 49da48619d37932b2e257c532078b2bb
config_hash: 1af83449a09a3b4f276444dbcdd3eb67
configured_endpoints: 136
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-812a10f8fb54c584efc914422b574cb3f43dc238b5733b13f6a0b2308b7d9910.yml
openapi_spec_hash: 0222041ba12a5ff6b94924a834fa91a2
config_hash: 50ee3382a63c021a9f821a935950e926
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 2.6.0 (2025-10-20)

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

### Features

* **api:** Add responses.input_tokens.count ([6dd09e2](https://github.com/openai/openai-python/commit/6dd09e2829f385f72b28620888d91a4493c96772))


### Bug Fixes

* **api:** internal openapi updates ([caabd7c](https://github.com/openai/openai-python/commit/caabd7c81f0f557f66dc0089af460185a5816c11))

## 2.5.0 (2025-10-17)

Full Changelog: [v2.4.0...v2.5.0](https://github.com/openai/openai-python/compare/v2.4.0...v2.5.0)
Expand Down
12 changes: 12 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,18 @@ Methods:

- <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>

## InputTokens

Types:

```python
from openai.types.responses import InputTokenCountResponse
```

Methods:

- <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>

# Realtime

Types:
Expand Down
54 changes: 54 additions & 0 deletions examples/responses_input_tokens.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from typing import List

from openai import OpenAI
from openai.types.responses.tool_param import ToolParam
from openai.types.responses.response_input_item_param import ResponseInputItemParam


def main() -> None:
client = OpenAI()
tools: List[ToolParam] = [
{
"type": "function",
"name": "get_current_weather",
"description": "Get current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City and state, e.g. San Francisco, CA",
},
"unit": {
"type": "string",
"enum": ["c", "f"],
"description": "Temperature unit to use",
},
},
"required": ["location", "unit"],
"additionalProperties": False,
},
"strict": True,
}
]

input_items: List[ResponseInputItemParam] = [
{
"type": "message",
"role": "user",
"content": [{"type": "input_text", "text": "What's the weather in San Francisco today?"}],
}
]

response = client.responses.input_tokens.count(
model="gpt-5",
instructions="You are a concise assistant.",
input=input_items,
tools=tools,
tool_choice={"type": "function", "name": "get_current_weather"},
)
print(f"input tokens: {response.input_tokens}")


if __name__ == "__main__":
main()
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.5.0"
version = "2.6.0"
description = "The official Python library for the openai API"
dynamic = ["readme"]
license = "Apache-2.0"
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.5.0" # x-release-please-version
__version__ = "2.6.0" # x-release-please-version
30 changes: 6 additions & 24 deletions src/openai/resources/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,7 @@ def edit(
If `transparent`, the output format needs to support transparency, so it should
be set to either `png` (default value) or `webp`.

input_fidelity: Control how much effort the model will exert to match the style and features,
especially facial features, of input images. This parameter is only supported
for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and
`low`. Defaults to `low`.
input_fidelity: Control how much effort the model will exert to match the style and features, especially facial features, of input images. This parameter is only supported for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and `low`. Defaults to `low`.

mask: An additional image whose fully transparent areas (e.g. where alpha is zero)
indicate where `image` should be edited. If there are multiple images provided,
Expand Down Expand Up @@ -285,10 +282,7 @@ def edit(
If `transparent`, the output format needs to support transparency, so it should
be set to either `png` (default value) or `webp`.

input_fidelity: Control how much effort the model will exert to match the style and features,
especially facial features, of input images. This parameter is only supported
for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and
`low`. Defaults to `low`.
input_fidelity: Control how much effort the model will exert to match the style and features, especially facial features, of input images. This parameter is only supported for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and `low`. Defaults to `low`.

mask: An additional image whose fully transparent areas (e.g. where alpha is zero)
indicate where `image` should be edited. If there are multiple images provided,
Expand Down Expand Up @@ -398,10 +392,7 @@ def edit(
If `transparent`, the output format needs to support transparency, so it should
be set to either `png` (default value) or `webp`.

input_fidelity: Control how much effort the model will exert to match the style and features,
especially facial features, of input images. This parameter is only supported
for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and
`low`. Defaults to `low`.
input_fidelity: Control how much effort the model will exert to match the style and features, especially facial features, of input images. This parameter is only supported for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and `low`. Defaults to `low`.

mask: An additional image whose fully transparent areas (e.g. where alpha is zero)
indicate where `image` should be edited. If there are multiple images provided,
Expand Down Expand Up @@ -1055,10 +1046,7 @@ async def edit(
If `transparent`, the output format needs to support transparency, so it should
be set to either `png` (default value) or `webp`.

input_fidelity: Control how much effort the model will exert to match the style and features,
especially facial features, of input images. This parameter is only supported
for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and
`low`. Defaults to `low`.
input_fidelity: Control how much effort the model will exert to match the style and features, especially facial features, of input images. This parameter is only supported for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and `low`. Defaults to `low`.

mask: An additional image whose fully transparent areas (e.g. where alpha is zero)
indicate where `image` should be edited. If there are multiple images provided,
Expand Down Expand Up @@ -1172,10 +1160,7 @@ async def edit(
If `transparent`, the output format needs to support transparency, so it should
be set to either `png` (default value) or `webp`.

input_fidelity: Control how much effort the model will exert to match the style and features,
especially facial features, of input images. This parameter is only supported
for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and
`low`. Defaults to `low`.
input_fidelity: Control how much effort the model will exert to match the style and features, especially facial features, of input images. This parameter is only supported for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and `low`. Defaults to `low`.

mask: An additional image whose fully transparent areas (e.g. where alpha is zero)
indicate where `image` should be edited. If there are multiple images provided,
Expand Down Expand Up @@ -1285,10 +1270,7 @@ async def edit(
If `transparent`, the output format needs to support transparency, so it should
be set to either `png` (default value) or `webp`.

input_fidelity: Control how much effort the model will exert to match the style and features,
especially facial features, of input images. This parameter is only supported
for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and
`low`. Defaults to `low`.
input_fidelity: Control how much effort the model will exert to match the style and features, especially facial features, of input images. This parameter is only supported for `gpt-image-1`. Unsupported for `gpt-image-1-mini`. Supports `high` and `low`. Defaults to `low`.

mask: An additional image whose fully transparent areas (e.g. where alpha is zero)
indicate where `image` should be edited. If there are multiple images provided,
Expand Down
14 changes: 14 additions & 0 deletions src/openai/resources/responses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
InputItemsWithStreamingResponse,
AsyncInputItemsWithStreamingResponse,
)
from .input_tokens import (
InputTokens,
AsyncInputTokens,
InputTokensWithRawResponse,
AsyncInputTokensWithRawResponse,
InputTokensWithStreamingResponse,
AsyncInputTokensWithStreamingResponse,
)

__all__ = [
"InputItems",
Expand All @@ -24,6 +32,12 @@
"AsyncInputItemsWithRawResponse",
"InputItemsWithStreamingResponse",
"AsyncInputItemsWithStreamingResponse",
"InputTokens",
"AsyncInputTokens",
"InputTokensWithRawResponse",
"AsyncInputTokensWithRawResponse",
"InputTokensWithStreamingResponse",
"AsyncInputTokensWithStreamingResponse",
"Responses",
"AsyncResponses",
"ResponsesWithRawResponse",
Expand Down
Loading