Query parameters
-
Start time (Unix seconds) of the query time range, inclusive.
-
End time (Unix seconds) of the query time range, exclusive.
-
Width of each time bucket in response. Currently only
1d
is supported, default to1d
.Value is
1d
. Default value is1d
. -
Return only costs for these projects.
-
Group the costs by the specified fields. Support fields include
project_id
,line_item
and any combination of them.Values are
project_id
orline_item
. -
A limit on the number of buckets to be returned. Limit can range between 1 and 180, and the default is 7.
Default value is
7
. -
A cursor for use in pagination. Corresponding to the
next_page
field from the previous response.
GET
/organization/costs
curl \
--request GET 'https://api.openai.com/v1/organization/costs?start_time=42' \
--header "Authorization: Bearer $ACCESS_TOKEN"
Response examples (200)
{
"object": "page",
"data": [
{
"object": "bucket",
"start_time": 42,
"end_time": 42,
"result": [
{
"object": "organization.usage.completions.result",
"input_tokens": 42,
"input_cached_tokens": 42,
"output_tokens": 42,
"input_audio_tokens": 42,
"output_audio_tokens": 42,
"num_model_requests": 42,
"project_id": "string",
"user_id": "string",
"api_key_id": "string",
"model": "string",
"batch": true
}
]
}
],
"has_more": true,
"next_page": "string"
}