Add metadata cost breakdown to Request Analytics API spec#325
Conversation
…cs API spec Adds two new fields to the Request Analytics endpoint: - `metadata_cost_breakdown_key` (request field on RequestLogQuery): when provided, the response includes a cost/request breakdown filtered to that specific metadata key. - `metadataValueBreakdown` (response field on RequestAnalyticsResponse): array of key/value/label/requests/cost entries, ordered by cost descending, up to 50 entries. https://claude.ai/code/session_01DJAvfB8L7GLPpAyNU6r9yz
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f221dc15d2
ℹ️ 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".
| "metadata_cost_breakdown_key": { | ||
| "type": "string", | ||
| "nullable": true, | ||
| "description": "When provided, the analytics response includes a `metadataValueBreakdown` array with cost and request counts for each value of this metadata key. Omit or pass null to get an aggregate breakdown across the top metadata keys." |
There was a problem hiding this comment.
Keep analytics-only fields out of search schema
Adding this field to RequestLogQuery also adds it to SearchRequestLogsRequest, because the search request schema is an allOf over #/components/schemas/RequestLogQuery (openapi.json lines 16673-16679). That makes POST /api/public/v2/requests/search advertise an analytics-only option whose description talks about changing the analytics response, which is not the real search API contract and will surface confusing/generated docs for the search endpoint. Please put this parameter on an analytics-specific request schema instead of the shared search/analytics base.
Useful? React with 👍 / 👎.
Summary
metadata_cost_breakdown_keyto theRequestLogQueryrequest schema. When provided, the analytics response includes ametadataValueBreakdownarray scoped to that metadata key's values.metadataValueBreakdownto theRequestAnalyticsResponseschema. Each entry containskey,value,label,requests, andcost. When a specific key is requested the label equals the value; in the aggregate view the label iskey = value. Results are ordered by cost descending, up to 50 entries.Generated by Claude Code