Costs

get https://api.openai.com/v1/organization/costs

Get costs details for the organization.source

Query parameters

Start time (Unix seconds) of the query time range, inclusive.source

End time (Unix seconds) of the query time range, exclusive.source

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

Return only costs for these projects.source

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

A limit on the number of buckets to be returned. Limit can range between 1 and 180, and the default is 7.source

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

Returns

A list of paginated, time bucketed Costs objects.source

Example request
1
2
3
curl "https://api.openai.com/v1/organization/costs?start_time=1730419200&limit=1" \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
-H "Content-Type: application/json"
Response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
    "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
                }
            ]
        }
    ],
    "has_more": false,
    "next_page": null
}