Skip to content

feat(api): update usage APIs and documentation - #3779

Merged
apcha-oai merged 2 commits into
mainfrom
castiron/promotions/pr-74
Sep 2, 2026
Merged

feat(api): update usage APIs and documentation#3779
apcha-oai merged 2 commits into
mainfrom
castiron/promotions/pr-74

Conversation

@apcha-oai

@apcha-oai apcha-oai commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Updates organization usage filtering, Responses and Chat Completions usage types, and API documentation.

Changes

  • Add optional line_items filtering to organization cost usage requests, allowing results to be limited to exact cost line-item names
  • Remove the unlaunched compute_units field from Responses and Chat Completions usage types
  • Refresh model examples, documentation links, and reasoning-model guidance across affected API documentation

Castiron-Internal-PR: openai/openai-python-internal#74
Castiron-Source-SHA: 32e4345bf0fe2dd35455774de84b8d07d1e6879e
Castiron-Public-Base-SHA: b19c216
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Castiron custom code

✅ No new custom-code files detected.

34 mixed files remain; 0 existing customizations changed; 4 generated baselines changed.

Compared b19c2161b1ea93586687533f. Generated baselines verified.

File Result Current custom patch
src/openai/resources/beta/responses/responses.py Generated baseline changed +12 / −11
src/openai/resources/chat/completions/completions.py Generated baseline changed +600 / −1
src/openai/resources/responses/responses.py Generated baseline changed +851 / −18
src/openai/types/responses/response.py Generated baseline changed +15 / −0
30 existing customizations unchanged
  • api.md
  • scripts/castiron/README.md
  • scripts/castiron/custom_code_report.py
  • scripts/castiron/test_custom_code_report.py
  • src/openai/init.py
  • src/openai/_client.py
  • src/openai/resources/audio/transcriptions.py
  • src/openai/resources/audio/translations.py
  • src/openai/resources/beta/beta.py
  • src/openai/resources/beta/threads/runs/runs.py
  • src/openai/resources/beta/threads/threads.py
  • src/openai/resources/embeddings.py
  • src/openai/resources/files.py
  • src/openai/resources/realtime/realtime.py
  • src/openai/resources/uploads/uploads.py
  • src/openai/resources/vector_stores/file_batches.py
  • src/openai/resources/vector_stores/files.py
  • src/openai/resources/videos.py
  • src/openai/resources/webhooks/init.py
  • src/openai/resources/webhooks/webhooks.py
  • src/openai/types/chat/init.py
  • src/openai/types/chat/chat_completion_message_tool_call.py
  • src/openai/types/fine_tuning/fine_tuning_job_integration.py
  • src/openai/types/responses/init.py
  • src/openai/types/responses/response_function_web_search.py
  • src/openai/types/responses/response_function_web_search_param.py
  • src/openai/types/responses/tool.py
  • src/openai/types/responses/tool_param.py
  • src/openai/types/webhooks/init.py
  • tests/api_resources/test_videos.py

A changed generated baseline means this report cannot reliably identify which handwritten lines changed.

Inspect the custom-code diff

Download the exact patch produced by this run (requires repository access):

gh run download 33572010822 --repo openai/openai-python \
  --name castiron-custom-code-33572010822-1 --dir /tmp/castiron-custom-code-33572010822-1
git apply --stat /tmp/castiron-custom-code-33572010822-1/custom-code.patch
cat /tmp/castiron-custom-code-33572010822-1/custom-code.patch

Or reproduce it from an SDK checkout containing the vendored reporter:

git fetch --no-tags origin b19c2161b1eac80fbf1f6f67a64a50af99c53356 93586687533ffc588f84235d57594f1e494c2f90
python3 scripts/castiron/custom_code_report.py report \
  --base b19c2161b1eac80fbf1f6f67a64a50af99c53356 \
  --head 93586687533ffc588f84235d57594f1e494c2f90 --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-93586687533f
cat /tmp/castiron-custom-code-93586687533f/custom-code.patch

This is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR.

Full report and patch

@apcha-oai
apcha-oai marked this pull request as ready for review September 1, 2026 21:47
@apcha-oai
apcha-oai requested a review from a team as a code owner September 1, 2026 21:47
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-01T21:49:46.391123Z 4d504a9 Draft marked ready
🔒 Security Review Completed 2026-09-01T21:50:35.123364Z 4d504a9 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openai-sdks

openai-sdks Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

OkTest Summary

237/237 SDK tests passed in 11.964s for Python SDK PR #3779.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 226ms
tests/chat-completions-create.test.ts ✅ Passed 264ms
tests/chat-completions-stream.test.ts ✅ Passed 135ms
tests/files-content-binary.test.ts ✅ Passed 250ms
tests/files-create-multipart.test.ts ✅ Passed 229ms
tests/files-list-pagination.test.ts ✅ Passed 153ms
tests/initialize-config.test.ts ✅ Passed 183ms
tests/instance-isolation.test.ts ✅ Passed 231ms
tests/models-list.test.ts ✅ Passed 215ms
tests/responses-background-lifecycle.test.ts ✅ Passed 274ms
tests/responses-body-method-errors.test.ts ✅ Passed 334ms
tests/responses-cancel-timeout.test.ts ✅ Passed 215ms
tests/responses-cancel.test.ts ✅ Passed 229ms
tests/responses-compact-retries.test.ts ✅ Passed 366ms
tests/responses-compact.test.ts ✅ Passed 379ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 175ms
tests/responses-create-advanced.test.ts ✅ Passed 252ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.157s
tests/responses-create-errors.test.ts ✅ Passed 214ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 254ms
tests/responses-create-retries.test.ts ✅ Passed 385ms
tests/responses-create-stream-failures.test.ts ✅ Passed 141ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 226ms
tests/responses-create-stream-wire.test.ts ✅ Passed 4.031s
tests/responses-create-stream.test.ts ✅ Passed 93ms
tests/responses-create-terminal-states.test.ts ✅ Passed 275ms
tests/responses-create-timeout.test.ts ✅ Passed 238ms
tests/responses-create.test.ts ✅ Passed 275ms
tests/responses-delete.test.ts ✅ Passed 321ms
tests/responses-input-items-errors.test.ts ✅ Passed 447ms
tests/responses-input-items-list.test.ts ✅ Passed 367ms
tests/responses-input-items-options.test.ts ✅ Passed 388ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 267ms
tests/responses-input-tokens-count.test.ts ✅ Passed 219ms
tests/responses-malformed-inputs.test.ts ✅ Passed 3.137s
tests/responses-not-found-errors.test.ts ✅ Passed 262ms
tests/responses-parse.test.ts ✅ Passed 427ms
tests/responses-retrieve-retries.test.ts ✅ Passed 282ms
tests/responses-retrieve.test.ts ✅ Passed 194ms
tests/responses-stored-method-errors.test.ts ✅ Passed 653ms
tests/retry-behavior.test.ts ✅ Passed 3.185s
tests/sdk-error-shape.test.ts ✅ Passed 299ms

View OkTest run #33563456989

SDK merge (5107ff0e438e) · head (93586687533f) · base (b19c2161b1ea) · OkTest (2b1bdfd25e98)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4d504a9def

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/openai/types/completion_usage.py

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking scope issue: the stated outcome is limited to removing the unlaunched compute_units usage fields, but this exact diff also promotes unrelated schema and public-surface changes—for example, a new organization-cost line_items filter, a new max_messages incomplete-reason value, and broad model/example/documentation updates. Those changes are not narrowly necessary for the field removal and make the patch carry behavior/API surface that the PR does not describe. Please regenerate from a baseline/config containing only the compute_units removal, or split and explicitly document/approve the broader promotion. I understand the compatibility/breaking-change checks triggered by the intentional field removal; that expected break is not this finding.

@apcha-oai apcha-oai changed the title fix(api): remove compute units from usage types feat(api): update usage APIs and documentation Sep 1, 2026

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for broadening the description. One public-surface change is still missing from the stated scope: this diff adds max_messages to the Responses/Beta Responses incomplete-reason enum/type in addition to the usage and documentation changes. That is a generated public API change, not merely a documentation refresh. Please explicitly include it in the description (or remove it) so the reviewed scope matches the exact diff.

@HAYDEN-OAI HAYDEN-OAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the complete diff at 93586687533f, including the intentional removal of the unlaunched compute_units field, optional organization-cost line_items filtering, stable/beta max_messages reason support, and schema/documentation updates. Checked sync/async filter propagation and query encoding, admin authentication, remaining usage contracts, and stable/beta response-model consumers.

No substantive issues found. Static source review only.

@apcha-oai
apcha-oai merged commit 6f0da16 into main Sep 2, 2026
27 of 28 checks passed
@apcha-oai
apcha-oai deleted the castiron/promotions/pr-74 branch September 2, 2026 01:14
@openai-sdks openai-sdks Bot mentioned this pull request Sep 2, 2026
pull Bot pushed a commit to mcx/openai-python that referenced this pull request Sep 2, 2026
Automated Release PR
---


##
[3.7.0](openai/openai-python@v3.6.0...v3.7.0)
(2026-09-02)


### Features

* **api:** update usage APIs and documentation
([openai#3779](openai#3779))
([6f0da16](openai@6f0da16))


### Bug Fixes

* avoid repeated numpy checks for embeddings
([openai#3757](openai#3757))
([b19c216](openai@b19c216))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: openai-sdks[bot] <284451331+openai-sdks[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants