apicheats.dev openai/llms.txt Raw .md
GET

GET /organization/costs — OpenAI API

OpenAI admin key (required); https://api.openai.com/v1

OpenAI API

Costs

Base URL
https://api.openai.com/v1
Auth
Authorization: Bearer <OPENAI_API_KEY>
Last verified
2026-10-20 · upstream hash matched
Actions Try in browser→
Agents: curl -H "Accept: text/markdown" this URL
→ 358 tokens · Vary: Accept

Critical gotchas

The Responses API is the primary interface for new text and tool workflows; Chat Completions remains a separate compatibility API.

Audio transcription uploads use multipart form data rather than a JSON request body.

cURL

curl -X GET 'https://api.openai.com/v1/organization/costs?start_time=10&end_time=10&bucket_width=1d&project_ids=example&api_key_ids=example&line_items=example&group_by=example&limit=7&page=example-page' \  -H "Authorization: Bearer $OPENAI_ADMIN_KEY"

Parameters

Name In Type Required Description
start_time query integer Yes Start time (Unix seconds) of the query time range, inclusive.
end_time query integer No End time (Unix seconds) of the query time range, exclusive.
bucket_width query string No Width of each time bucket in response. Currently only `1d` is supported, default to `1d`.
project_ids query string[] No Return only costs for these projects.
api_key_ids query string[] No Return only costs for these API keys.
line_items query string[] No Return only costs for these exact line item names. Each value must match the complete `line_item` value, for example `gpt-6-astra, input_tokens`.
group_by query string[] No Group the costs by the specified fields. Supported fields include `project_id`, `user_id`, `line_item`, `api_key_id`, and `api_source`. Support for combining `user_id` with `project_id` grouping or the `project_ids` filter depends on the organization and requested time range. Unsupported combinations return HTTP 400. When grouped by `api_source`, results use `agents_api` for attributed Agents API activity and `unlabeled` for all other activity. Without source grouping, `api_source` is null.
limit query integer No A limit on the number of buckets to be returned. Limit can range between 1 and 180, and the default is 7.
page query string No A cursor for use in pagination. Corresponding to the `next_page` field from the previous response.

Response 200 OK

{
  "object": "page",
  "data": [
    {
      "object": "bucket",
      "start_time": 0,
      "end_time": 0,
      "results": [
        {
          "api_source": "agents_api",
          "object": "organization.usage.completions.result",
          "input_tokens": 0,
          "input_cached_tokens": 0,
          "input_cache_write_tokens": 0,
          "input_cache_write_30m_tokens": 0,
          "input_cache_write_12h_tokens": 0,
          "input_uncached_tokens": 0,
          "output_tokens": 0,
          "input_text_tokens": 0,
          "output_text_tokens": 0,
          "input_cached_text_tokens": 0,
          "input_audio_tokens": 0,
          "input_cached_audio_tokens": 0,
          "output_audio_tokens": 0,
          "input_image_tokens": 0,
          "input_cached_image_tokens": 0,
          "output_image_tokens": 0,
          "num_model_requests": 0,
          "project_id": "string",
          "user_id": "string",
          "api_key_id": "string",
          "model": "string",
          "batch": true,
          "service_tier": "string"
        }
      ]
    }
  ],
  "has_more": true,
  "next_page": "string"
}
Get a free OpenAI API key → sponsored

Affiliate link - we may earn a commission, at no extra cost to you.