Costs

GEThttps:/api.openai.com/v1/organization/costs

Get costs details for the organization.

Query parameters

  • start_time
    integer
    Required
    Start time (Unix seconds) of the query time range, inclusive.
  • end_time
    integer
    End time (Unix seconds) of the query time range, exclusive.
  • bucket_width
    string
    Defaults: 1d

    Width of each time bucket in response. Currently only 1d is supported, default to 1d.

  • project_ids
    array
    Return only costs for these projects.
  • group_by
    array

    Group the costs by the specified fields. Support fields include project_id, line_item and any combination of them.

  • limit
    integer
    Defaults: 7
    A limit on the number of buckets to be returned. Limit can range between 1 and 180, and the default is 7.
  • page
    string

    A cursor for use in pagination. Corresponding to the next_page field from the previous response.

Response

A list of paginated, time bucketed Costs objects.

Example request
1
curl "https://api.openai.com/v1/organization/costs?start_time=1730419200&limit=1" \
2
-H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
3
-H "Content-Type: application/json"
Example response
1
{
2
"object": "page",
3
"data": [
4
{
5
"object": "bucket",
6
"start_time": 1730419200,
7
"end_time": 1730505600,
8
"results": [
9
{
10
"object": "organization.costs.result",
11
"amount": {
12
"value": 0.06,
13
"currency": "usd"
14
},
15
"line_item": null,
16
"project_id": null
17
}
18
]
19
}
20
],
21
"has_more": false,
22
"next_page": null
23
}
Built with