feat(api): update usage APIs and documentation - #147
Conversation
Castiron-Internal-PR: openai/openai-cli-internal#53 Castiron-Source-SHA: 2c575423ec72ad64e6fdcea9023276a62ef3e576 Castiron-Public-Base-SHA: 5933dd5
Castiron custom code✅ No new custom-code files detected. 5 mixed files remain; 0 existing customizations changed. Compared 5 existing customizations unchanged
A changed generated baseline means this report cannot reliably identify which handwritten lines changed. Inspect the custom-code diffDownload 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.patchOr 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.patchThis is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🟡 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_unitsfrom usage-related schemas inapi_reference/openapi.transformed.yml. - Regenerate generated CLI command help/tests to reflect updated spec text and example model IDs.
- Add a new
line_itemsquery filter surfaced as--line-itemfor 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.
| - 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 |
| &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
left a comment
There was a problem hiding this comment.
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.
jbeckwith-oai
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
[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.
There was a problem hiding this comment.
valid but existing bug; affects all arrays similarly
Summary
Updates organization usage filtering, Responses and Chat Completions usage types, and API documentation.
Changes
line_itemsfiltering to organization cost usage requests, allowing results to be limited to exact cost line-item namescompute_unitsfield from Responses and Chat Completions usage types