Skip to content

feat(api): group Completions usage and costs by completion window - #4376

Open
markstuart-oai wants to merge 1 commit into
mainfrom
castiron/promotions/pr-476
Open

markstuart-oai wants to merge 1 commit into
mainfrom
castiron/promotions/pr-476

Conversation

@markstuart-oai

Copy link
Copy Markdown
Contributor

Summary

Use group_by=["completion_window"] with usage.completions() or usage.costs() to group results by background completion window. Read row.completion_window to get "2h", "8h", "unlabeled", or None.

Compatibility

  • Type checkers may reject a list annotated with the old grouping literals. Pass [*columns] or widen the annotation. Add "completion_window" to exhaustive checks.
  • Pydantic now treats completion_window as a named field. Code that indexes row.model_extra["completion_window"] can raise KeyError. Use row.completion_window instead. To distinguish an omitted field from an explicit null, check "completion_window" in row.model_fields_set. row.model_dump(exclude_unset=True) includes the field when present.

Castiron-Internal-PR: openai/openai-python-internal#476
Castiron-Source-SHA: be7c319cb97f92940566230a7a09b2062cfe3d4c
Castiron-Public-Base-SHA: ba6e577
@markstuart-oai
markstuart-oai requested a review from a team as a code owner December 5, 2026 02:24
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-05T02:25:19.920781Z 5107442 PR opened
🔒 Security Review ✅ Completed 2026-12-05T02:25:20.648276Z 5107442 PR opened
ℹ️ 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.

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

Approved after comprehensive static review and an independent second review. The complete public-head file tree matches the reviewed internal counterpart, including file modes. Checked completion-window grouping, response models, null/omission semantics, compatibility, and pagination/wire regression coverage; no actionable findings.

SDK CI and the OkTest test job passed, but OkTest reporting failed with "missing or ambiguous prepared check; rerun all jobs". The overall OkTest check is therefore still failed.

No candidate code or tests were executed locally.

This branch has not been deployed

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