NAME

OpenAPI::Client::OpenAI::Path::organization-costs - Documentation for the /organization/costs path.

OPERATIONS

GET /organization/costs

usage-costs

$client->usage_costs({
    body => { ... },
});

Get costs details for the organization.

Path/query parameters

  • start_time (in query, required, integer) - Start time (Unix seconds) of the query time range, inclusive.

  • end_time (in query, optional, integer) - End time (Unix seconds) of the query time range, exclusive.

  • bucket_width (in query, optional, string) - Width of each time bucket in response. Currently only 1d is supported, default to 1d .

    Allowed values: 1d

    Default: 1d

  • project_ids (in query, optional, array) - Return only costs for these projects.

  • api_key_ids (in query, optional, array) - Return only costs for these API keys.

  • group_by (in query, optional, array) - Group the costs by the specified fields. Support fields include project_id , line_item , api_key_id and any combination of them.

  • limit (in query, optional, integer) - A limit on the number of buckets to be returned. Limit can range between 1 and 180, and the default is 7.

    Default: 7

  • page (in query, optional, string) - A cursor for use in pagination. Corresponding to the next_page field from the previous response.

Responses

200 - Costs data retrieved successfully.

Content-Type: application/json

Example:

{
   "data" : [
      {
         "end_time" : 0,
         "object" : "bucket",
         "results" : [
            "{\n    \"object\": \"organization.usage.completions.result\",\n    \"input_tokens\": 5000,\n    \"output_tokens\": 1000,\n    \"input_cached_tokens\": 4000,\n    \"input_audio_tokens\": 300,\n    \"output_audio_tokens\": 200,\n    \"num_model_requests\": 5,\n    \"project_id\": \"proj_abc\",\n    \"user_id\": \"user-abc\",\n    \"api_key_id\": \"key_abc\",\n    \"model\": \"gpt-4o-mini-2024-07-18\",\n    \"batch\": false,\n    \"service_tier\": \"default\"\n}\n"
         ],
         "start_time" : 0
      }
   ],
   "has_more" : false,
   "next_page" : "string",
   "object" : "page"
}

SCHEMAS

UsageResponse

Properties:

  • data (array of UsageTimeBucket, required)

  • has_more (boolean, required)

  • next_page (anyOf, required)

  • object (string, required)

    Allowed values: page

UsageTimeBucket

Properties:

  • end_time (integer, required)

  • object (string, required)

    Allowed values: bucket

  • results (array of object, required)

  • start_time (integer, required)

SEE ALSO

OpenAPI::Client::OpenAI::Path

COPYRIGHT AND LICENSE

Copyright (C) 2023-2026 by Nelson Ferraz

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.0 or, at your option, any later version of Perl 5 you may have available.