Completions

GEThttps:/api.openai.com/v1/organization/usage/completions

Get completions usage 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 1m, 1h and 1d are supported, default to 1d.

  • project_ids
    array
    Return only usage for these projects.
  • user_ids
    array
    Return only usage for these users.
  • api_key_ids
    array
    Return only usage for these API keys.
  • models
    array
    Return only usage for these models.
  • batch
    boolean

    If true, return batch jobs only. If false, return non-batch jobs only. By default, return both.

  • group_by
    array

    Group the usage data by the specified fields. Support fields include project_id, user_id, api_key_id, model, batch or any combination of them.

  • limit
    integer

    Specifies the number of buckets to return.

    • bucket_width=1d: default: 7, max: 31
    • bucket_width=1h: default: 24, max: 168
    • bucket_width=1m: default: 60, max: 1440
  • 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 Completions usage objects.

Example request
1
curl "https://api.openai.com/v1/organization/usage/completions?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.usage.completions.result",
11
"input_tokens": 1000,
12
"output_tokens": 500,
13
"input_cached_tokens": 800,
14
"input_audio_tokens": 0,
15
"output_audio_tokens": 0,
16
"num_model_requests": 5,
17
"project_id": null,
18
"user_id": null,
19
"api_key_id": null,
20
"model": null,
21
"batch": null
22
}
23
]
24
}
25
],
26
"has_more": true,
27
"next_page": "page_AAAAAGdGxdEiJdKOAAAAAGcqsYA="
28
}
Built with