Costs
admin.organization.usage.costs(UsageCostsParams**kwargs) -> UsageCostsResponse
GET/organization/costs
Get costs details for the organization.
Parameters
bucket_width: Optional[Literal["1d"]]
Width of each time bucket in response. Currently only 1d is supported, default to 1d.
limit: Optional[int]
A limit on the number of buckets to be returned. Limit can range between 1 and 180, and the default is 7.
Costs
import os
from openai import OpenAI
client = OpenAI(
admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted
)
response = client.admin.organization.usage.costs(
start_time=0,
)
print(response.data){
"object": "page",
"data": [
{
"object": "bucket",
"start_time": 1730419200,
"end_time": 1730505600,
"results": [
{
"object": "organization.costs.result",
"amount": {
"value": 0.06,
"currency": "usd"
},
"line_item": null,
"project_id": null,
"api_key_id": null
}
]
}
],
"has_more": false,
"next_page": null
}
Returns Examples
{
"object": "page",
"data": [
{
"object": "bucket",
"start_time": 1730419200,
"end_time": 1730505600,
"results": [
{
"object": "organization.costs.result",
"amount": {
"value": 0.06,
"currency": "usd"
},
"line_item": null,
"project_id": null,
"api_key_id": null
}
]
}
],
"has_more": false,
"next_page": null
}