Skip to content

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

Merged
apcha-oai merged 1 commit into
mainfrom
castiron/promotions/pr-53
Sep 2, 2026
Merged

feat(api): update usage APIs and documentation#147
apcha-oai merged 1 commit into
mainfrom
castiron/promotions/pr-53

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-cli-internal#53
Castiron-Source-SHA: 2c575423ec72ad64e6fdcea9023276a62ef3e576
Castiron-Public-Base-SHA: 5933dd5
Copilot AI lite review requested due to automatic review settings September 1, 2026 21:46
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

Castiron custom code

✅ No new custom-code files detected.

5 mixed files remain; 0 existing customizations changed.

Compared 5933dd50fbea0790d3f1e25b. Generated baselines verified.

5 existing customizations unchanged
  • pkg/cmd/adminorganizationcertificate.go
  • pkg/cmd/cmd.go
  • scripts/castiron/README.md
  • scripts/castiron/custom_code_report.py
  • scripts/castiron/test_custom_code_report.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 33572005470 --repo openai/openai-cli \
  --name castiron-custom-code-33572005470-1 --dir /tmp/castiron-custom-code-33572005470-1
git apply --stat /tmp/castiron-custom-code-33572005470-1/custom-code.patch
cat /tmp/castiron-custom-code-33572005470-1/custom-code.patch

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

git fetch --no-tags origin 5933dd50fbea96b54cb11c46221bd70ed1aa6a52 0790d3f1e25bfcface3c2e2d4e1c77a9adf97d62
python3 scripts/castiron/custom_code_report.py report \
  --base 5933dd50fbea96b54cb11c46221bd70ed1aa6a52 \
  --head 0790d3f1e25bfcface3c2e2d4e1c77a9adf97d62 --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-0790d3f1e25b
cat /tmp/castiron-custom-code-0790d3f1e25b/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:59.608644Z 0790d3f Draft marked ready
🔒 Security Review Completed 2026-09-01T21:51:32.778360Z 0790d3f 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.

Copilot AI 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.

🟡 Changes recommended

The PR scope/description doesn’t match the additional spec-driven changes in the diff, and the new line_items examples include spaces that are not copy/pasteable without quoting/encoding.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the generated OpenAPI reference (and corresponding generated CLI commands/tests) to remove the unlaunched compute_units field from usage schemas, along with additional spec-driven doc/example updates.

Changes:

  • Remove compute_units from usage-related schemas in api_reference/openapi.transformed.yml.
  • Regenerate generated CLI command help/tests to reflect updated spec text and example model IDs.
  • Add a new line_items query filter surfaced as --line-item for admin organization usage costs.
File summaries
File Description
pkg/cmd/response.go Updates generated Responses command flag help text/examples.
pkg/cmd/response_test.go Updates generated Responses CLI argument expectations for new model example.
pkg/cmd/model_test.go Updates generated Models retrieve test example model ID.
pkg/cmd/inputtoken.go Updates generated input-tokens command flag help text.
pkg/cmd/chatcompletion.go Updates generated Chat Completions command help text/examples.
pkg/cmd/chatcompletion_test.go Updates generated Chat Completions CLI argument expectations for new model example.
pkg/cmd/betaresponse.go Updates generated Beta Responses command help text/examples.
pkg/cmd/betaresponse_test.go Updates generated Beta Responses CLI argument expectations for new model example.
pkg/cmd/betaassistant_test.go Updates generated Beta Assistants test example model ID.
pkg/cmd/adminorganizationusage.go Adds generated --line-item flag mapping to line_items query parameter.
pkg/cmd/adminorganizationusage_test.go Updates generated admin usage costs test to include --line-item.
api_reference/openapi.transformed.yml Removes compute_units and updates various API docs/examples (models, params, examples).
.castiron.stats.yml Updates generation metadata/hashes for the regenerated outputs.
Review details
  • Files reviewed: 12/13 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +9483 to +9490
- name: line_items
in: query
description: Return only costs for these exact line item names. Each value must match the complete `line_item` value, for example `gpt-5.6-sol, input_tokens`.
required: false
schema:
type: array
items:
type: string
Comment on lines +293 to +297
&requestflag.Flag[[]string]{
Name: "line-item",
Usage: "Return only costs for these exact line item names. Each value must match the complete `line_item` value, for example `gpt-5.6-sol, input_tokens`.",
QueryPath: "line_items",
},

@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 incomplete-reason schema in addition to the usage and documentation changes. Please explicitly include that API change in the description (or remove it), and address the two unresolved line_items help/example threads before approval.

@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 0790d3f1e25b — one concrete issue remains in the new line_items filter: supported JSON/YAML stdin arrays are sent as one literal JSON string rather than individual exact names. The inline comment describes the path and fix direction; explicit quoted/repeated flags are unaffected.

Static review of all 13 changed files with an independent pass; no runtime API request was sent. This comment does not resolve the separate description/scope discussion.

&requestflag.Flag[[]string]{
Name: "line-item",
Usage: "Return only costs for these exact line item names. Each value must match the complete `line_item` value, for example `gpt-5.6-sol, input_tokens`.",
QueryPath: "line_items",

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.

[P2] Preserve line_items array elements from stdin

In the existing JSON/YAML stdin mode, with no explicit --line-item, input such as {"start_time":1,"line_items":["gpt-5.6-sol, input_tokens"]} sends the JSON text of the whole array as one line_items[] value. The stdin adapter JSON-marshals the array before calling Flag[[]string].Set, whose slice setter parses and appends one string. The resulting value includes the brackets and quotes instead of the exact line-item name, so the new filter requests a different name than the caller supplied. Please preserve individual array elements when populating this query flag from stdin. Explicit quoted or repeated --line-item arguments are unaffected.

@apcha-oai apcha-oai Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

valid but existing bug; affects all arrays similarly

@apcha-oai
apcha-oai merged commit f0c1afd into main Sep 2, 2026
19 checks passed
@apcha-oai
apcha-oai deleted the castiron/promotions/pr-53 branch September 2, 2026 01:15
@openai-sdks openai-sdks Bot mentioned this pull request Sep 1, 2026
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.

4 participants