openai_get_costs
Query daily OpenAI API spend breakdown by project, API key, or line item. Specify a start time to get cost buckets, with optional grouping and filtering.
Instructions
Query the organization's daily spend breakdown.
Args:
start_time: Start of the query range, inclusive (Unix seconds).
end_time: End of the query range, exclusive (Unix seconds).
bucket_width: Time bucket size — only `1d` is currently supported.
group_by: Fields to group by — project_id, line_item, api_key_id.
project_ids: Only include costs for these projects.
api_key_ids: Only include costs for these API keys.
limit: Number of buckets to return (1-180, default 7).
page: Pagination cursor from a previous response's `next_page`.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | ||
| limit | No | ||
| end_time | No | ||
| group_by | No | ||
| start_time | Yes | ||
| api_key_ids | No | ||
| project_ids | No | ||
| bucket_width | No | 1d |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |