Get costs details for the organization.

GET /organization/costs

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

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

    Value is 1d. Default value is 1d.

  • project_ids array[string]

    Return only costs for these projects.

  • group_by array[string]

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

    Values are project_id or line_item.

  • limit integer

    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.

  • page string

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

Responses

  • 200 application/json

    Costs data retrieved successfully.

    Hide response attributes Show response attributes object
    • object string Required

      Value is page.

    • data array[object] Required
      Hide data attributes Show data attributes object
      • object string Required

        Value is bucket.

      • start_time integer Required
      • end_time integer Required
      • result array[object] Required
        One of:

        The aggregated completions usage details of the specific time bucket.

        Hide attributes Show attributes
        • object string Required

          Value is organization.usage.completions.result.

        • input_tokens integer Required

          The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

        • input_cached_tokens integer

          The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

        • output_tokens integer Required

          The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

        • input_audio_tokens integer

          The aggregated number of audio input tokens used, including cached tokens.

        • output_audio_tokens integer

          The aggregated number of audio output tokens used.

        • num_model_requests integer Required

          The count of requests made to the model.

        • project_id string | null

          When group_by=project_id, this field provides the project ID of the grouped usage result.

        • user_id string | null

          When group_by=user_id, this field provides the user ID of the grouped usage result.

        • api_key_id string | null

          When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

        • model string | null

          When group_by=model, this field provides the model name of the grouped usage result.

        • batch boolean | null

          When group_by=batch, this field tells whether the grouped usage result is batch or not.

    • has_more boolean Required
    • next_page string Required
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"
}