OpenAI Usage API

The Usage API from OpenAI — 9 operation(s) for usage.

Operations 9

GET /organization/costs Get costs details for the organization. #
GET /organization/usage/audio_speeches Get audio speeches usage details for the organization. #
GET /organization/usage/audio_transcriptions Get audio transcriptions usage details for the organization. #
GET /organization/usage/code_interpreter_sessions Get code interpreter sessions usage details for the organization. #
GET /organization/usage/completions Get completions usage details for the organization. #
GET /organization/usage/embeddings Get embeddings usage details for the organization. #
GET /organization/usage/images Get images usage details for the organization. #
GET /organization/usage/moderations Get moderations usage details for the organization. #
GET /organization/usage/vector_stores Get vector stores usage details for the organization. #

Documentation

📖
Documentation
https://platform.openai.com/docs/assistants/overview
📖
Documentation
https://platform.openai.com/docs/api-reference/assistants
📖
Documentation
https://platform.openai.com/docs/guides/text-to-speech
📖
Documentation
https://platform.openai.com/docs/api-reference/audio
📖
Documentation
https://platform.openai.com/docs/guides/speech-to-text
📖
Documentation
https://developers.openai.com/api/docs/guides/audio/
📖
Documentation
https://developers.openai.com/api/docs/guides/voice-agents/
📖
Documentation
https://platform.openai.com/docs/api-reference/chat
📖
Documentation
https://platform.openai.com/docs/guides/embeddings
📖
Documentation
https://platform.openai.com/docs/api-reference/embeddings
📖
Documentation
https://platform.openai.com/docs/api-reference/files
📖
Documentation
https://platform.openai.com/docs/guides/fine-tuning
📖
Documentation
https://platform.openai.com/docs/api-reference/fine-tuning
📖
Documentation
https://platform.openai.com/docs/guides/images
📖
Documentation
https://platform.openai.com/docs/api-reference/images
📖
Documentation
https://platform.openai.com/docs/guides/image-generation
📖
Documentation
https://platform.openai.com/docs/guides/images-vision
📖
Documentation
https://platform.openai.com/docs/models
📖
Documentation
https://platform.openai.com/docs/api-reference/models
📖
Documentation
https://platform.openai.com/docs/assistants/how-it-works/managing-threads-and-messages
📖
Documentation
https://platform.openai.com/docs/api-reference/threads
📖
Documentation
https://platform.openai.com/docs/api-reference/completions

Specifications

Schemas & Data

Other Resources

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/openai-usage-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

openai-usage-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: OpenAI Usage API
  description: The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.
  version: 2.3.0
  termsOfService: https://openai.com/policies/terms-of-use
  contact:
    name: OpenAI Support
    url: https://help.openai.com/
  license:
    name: MIT
    url: https://github.com/openai/openai-openapi/blob/master/LICENSE
servers:
- url: https://api.openai.com/v1
security:
- ApiKeyAuth: []
tags:
- name: Usage
paths:
  /organization/costs:
    get:
      security:
      - AdminApiKeyAuth: []
      summary: Get costs details for the organization.
      operationId: usage-costs
      tags:
      - Usage
      parameters:
      - name: start_time
        in: query
        description: Start time (Unix seconds) of the query time range, inclusive.
        required: true
        schema:
          type: integer
      - name: end_time
        in: query
        description: End time (Unix seconds) of the query time range, exclusive.
        required: false
        schema:
          type: integer
      - name: bucket_width
        in: query
        description: Width of each time bucket in response. Currently only `1d` is supported, default to `1d`.
        required: false
        schema:
          type: string
          enum:
          - 1d
          default: 1d
      - name: project_ids
        in: query
        description: Return only costs for these projects.
        required: false
        schema:
          type: array
          items:
            type: string
      - name: api_key_ids
        in: query
        description: Return only costs for these API keys.
        required: false
        schema:
          type: array
          items:
            type: string
      - name: group_by
        in: query
        description: Group the costs by the specified fields. Support fields include `project_id`, `line_item`, `api_key_id` and any combination of them.
        required: false
        schema:
          type: array
          items:
            type: string
            enum:
            - project_id
            - line_item
            - api_key_id
      - name: limit
        in: query
        description: 'A limit on the number of buckets to be returned. Limit can range between 1 and 180, and the default is 7.

          '
        required: false
        schema:
          type: integer
          default: 7
      - name: page
        in: query
        description: A cursor for use in pagination. Corresponding to the `next_page` field from the previous response.
        schema:
          type: string
      responses:
        '200':
          description: Costs data retrieved successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageResponse'
      x-oaiMeta:
        name: Costs
        group: usage-costs
        examples:
          request:
            curl: 'curl "https://api.openai.com/v1/organization/costs?start_time=1730419200&limit=1" \

              -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \

              -H "Content-Type: application/json"

              '
            node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n  adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.admin.organization.usage.costs({ start_time: 0 });\n\nconsole.log(response.data);"
            python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n    admin_api_key=os.environ.get(\"OPENAI_ADMIN_KEY\"),  # This is the default and can be omitted\n)\nresponse = client.admin.organization.usage.costs(\n    start_time=0,\n)\nprint(response.data)"
            go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tresponse, err := client.Admin.Organization.Usage.Costs(context.TODO(), openai.AdminOrganizationUsageCostsParams{\n\t\tStartTime: 0,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n"
            java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.admin.organization.usage.UsageCostsParams;\nimport com.openai.models.admin.organization.usage.UsageCostsResponse;\n\npublic final class Main {\n    private Main() {}\n\n    public static void main(String[] args) {\n        OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n        UsageCostsParams params = UsageCostsParams.builder()\n            .startTime(0L)\n            .build();\n        UsageCostsResponse response = client.admin().organization().usage().costs(params);\n    }\n}"
            ruby: 'require "openai"


              openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")


              response = openai.admin.organization.usage.costs(start_time: 0)


              puts(response)'
          response: "{\n    \"object\": \"page\",\n    \"data\": [\n        {\n            \"object\": \"bucket\",\n            \"start_time\": 1730419200,\n            \"end_time\": 1730505600,\n            \"results\": [\n                {\n                    \"object\": \"organization.costs.result\",\n                    \"amount\": {\n                        \"value\": 0.06,\n                        \"currency\": \"usd\"\n                    },\n                    \"line_item\": null,\n                    \"project_id\": null,\n                    \"api_key_id\": null,\n                    \"quantity\": null\n                }\n            ]\n        }\n    ],\n    \"has_more\": false,\n    \"next_page\": null\n}\n"
  /organization/usage/audio_speeches:
    get:
      security:
      - AdminApiKeyAuth: []
      summary: Get audio speeches usage details for the organization.
      operationId: usage-audio-speeches
      tags:
      - Usage
      parameters:
      - name: start_time
        in: query
        description: Start time (Unix seconds) of the query time range, inclusive.
        required: true
        schema:
          type: integer
      - name: end_time
        in: query
        description: End time (Unix seconds) of the query time range, exclusive.
        required: false
        schema:
          type: integer
      - name: bucket_width
        in: query
        description: Width of each time bucket in response. Currently `1m`, `1h` and `1d` are supported, default to `1d`.
        required: false
        schema:
          type: string
          enum:
          - 1m
          - 1h
          - 1d
          default: 1d
      - name: project_ids
        in: query
        description: Return only usage for these projects.
        required: false
        schema:
          type: array
          items:
            type: string
      - name: user_ids
        in: query
        description: Return only usage for these users.
        required: false
        schema:
          type: array
          items:
            type: string
      - name: api_key_ids
        in: query
        description: Return only usage for these API keys.
        required: false
        schema:
          type: array
          items:
            type: string
      - name: models
        in: query
        description: Return only usage for these models.
        required: false
        schema:
          type: array
          items:
            type: string
      - name: group_by
        in: query
        description: Group the usage data by the specified fields. Support fields include `project_id`, `user_id`, `api_key_id`, `model` or any combination of them.
        required: false
        schema:
          type: array
          items:
            type: string
            enum:
            - project_id
            - user_id
            - api_key_id
            - model
      - name: limit
        in: query
        description: '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

          '
        required: false
        schema:
          type: integer
      - name: page
        in: query
        description: A cursor for use in pagination. Corresponding to the `next_page` field from the previous response.
        schema:
          type: string
      responses:
        '200':
          description: Usage data retrieved successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageResponse'
      x-oaiMeta:
        name: Audio speeches
        group: usage-audio-speeches
        examples:
          request:
            curl: 'curl "https://api.openai.com/v1/organization/usage/audio_speeches?start_time=1730419200&limit=1" \

              -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \

              -H "Content-Type: application/json"

              '
            node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n  adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.admin.organization.usage.audioSpeeches({ start_time: 0 });\n\nconsole.log(response.data);"
            python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n    admin_api_key=os.environ.get(\"OPENAI_ADMIN_KEY\"),  # This is the default and can be omitted\n)\nresponse = client.admin.organization.usage.audio_speeches(\n    start_time=0,\n)\nprint(response.data)"
            go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tresponse, err := client.Admin.Organization.Usage.AudioSpeeches(context.TODO(), openai.AdminOrganizationUsageAudioSpeechesParams{\n\t\tStartTime: 0,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n"
            java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.admin.organization.usage.UsageAudioSpeechesParams;\nimport com.openai.models.admin.organization.usage.UsageAudioSpeechesResponse;\n\npublic final class Main {\n    private Main() {}\n\n    public static void main(String[] args) {\n        OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n        UsageAudioSpeechesParams params = UsageAudioSpeechesParams.builder()\n            .startTime(0L)\n            .build();\n        UsageAudioSpeechesResponse response = client.admin().organization().usage().audioSpeeches(params);\n    }\n}"
            ruby: 'require "openai"


              openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")


              response = openai.admin.organization.usage.audio_speeches(start_time: 0)


              puts(response)'
          response: "{\n    \"object\": \"page\",\n    \"data\": [\n        {\n            \"object\": \"bucket\",\n            \"start_time\": 1730419200,\n            \"end_time\": 1730505600,\n            \"results\": [\n                {\n                    \"object\": \"organization.usage.audio_speeches.result\",\n                    \"characters\": 45,\n                    \"num_model_requests\": 1,\n                    \"project_id\": null,\n                    \"user_id\": null,\n                    \"api_key_id\": null,\n                    \"model\": null\n                }\n            ]\n        }\n    ],\n    \"has_more\": false,\n    \"next_page\": null\n}\n"
  /organization/usage/audio_transcriptions:
    get:
      security:
      - AdminApiKeyAuth: []
      summary: Get audio transcriptions usage details for the organization.
      operationId: usage-audio-transcriptions
      tags:
      - Usage
      parameters:
      - name: start_time
        in: query
        description: Start time (Unix seconds) of the query time range, inclusive.
        required: true
        schema:
          type: integer
      - name: end_time
        in: query
        description: End time (Unix seconds) of the query time range, exclusive.
        required: false
        schema:
          type: integer
      - name: bucket_width
        in: query
        description: Width of each time bucket in response. Currently `1m`, `1h` and `1d` are supported, default to `1d`.
        required: false
        schema:
          type: string
          enum:
          - 1m
          - 1h
          - 1d
          default: 1d
      - name: project_ids
        in: query
        description: Return only usage for these projects.
        required: false
        schema:
          type: array
          items:
            type: string
      - name: user_ids
        in: query
        description: Return only usage for these users.
        required: false
        schema:
          type: array
          items:
            type: string
      - name: api_key_ids
        in: query
        description: Return only usage for these API keys.
        required: false
        schema:
          type: array
          items:
            type: string
      - name: models
        in: query
        description: Return only usage for these models.
        required: false
        schema:
          type: array
          items:
            type: string
      - name: group_by
        in: query
        description: Group the usage data by the specified fields. Support fields include `project_id`, `user_id`, `api_key_id`, `model` or any combination of them.
        required: false
        schema:
          type: array
          items:
            type: string
            enum:
            - project_id
            - user_id
            - api_key_id
            - model
      - name: limit
        in: query
        description: '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

          '
        required: false
        schema:
          type: integer
      - name: page
        in: query
        description: A cursor for use in pagination. Corresponding to the `next_page` field from the previous response.
        schema:
          type: string
      responses:
        '200':
          description: Usage data retrieved successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageResponse'
      x-oaiMeta:
        name: Audio transcriptions
        group: usage-audio-transcriptions
        examples:
          request:
            curl: 'curl "https://api.openai.com/v1/organization/usage/audio_transcriptions?start_time=1730419200&limit=1" \

              -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \

              -H "Content-Type: application/json"

              '
            node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n  adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.admin.organization.usage.audioTranscriptions({ start_time: 0 });\n\nconsole.log(response.data);"
            python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n    admin_api_key=os.environ.get(\"OPENAI_ADMIN_KEY\"),  # This is the default and can be omitted\n)\nresponse = client.admin.organization.usage.audio_transcriptions(\n    start_time=0,\n)\nprint(response.data)"
            go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tresponse, err := client.Admin.Organization.Usage.AudioTranscriptions(context.TODO(), openai.AdminOrganizationUsageAudioTranscriptionsParams{\n\t\tStartTime: 0,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n"
            java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.admin.organization.usage.UsageAudioTranscriptionsParams;\nimport com.openai.models.admin.organization.usage.UsageAudioTranscriptionsResponse;\n\npublic final class Main {\n    private Main() {}\n\n    public static void main(String[] args) {\n        OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n        UsageAudioTranscriptionsParams params = UsageAudioTranscriptionsParams.builder()\n            .startTime(0L)\n            .build();\n        UsageAudioTranscriptionsResponse response = client.admin().organization().usage().audioTranscriptions(params);\n    }\n}"
            ruby: 'require "openai"


              openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")


              response = openai.admin.organization.usage.audio_transcriptions(start_time: 0)


              puts(response)'
          response: "{\n    \"object\": \"page\",\n    \"data\": [\n        {\n            \"object\": \"bucket\",\n            \"start_time\": 1730419200,\n            \"end_time\": 1730505600,\n            \"results\": [\n                {\n                    \"object\": \"organization.usage.audio_transcriptions.result\",\n                    \"seconds\": 20,\n                    \"num_model_requests\": 1,\n                    \"project_id\": null,\n                    \"user_id\": null,\n                    \"api_key_id\": null,\n                    \"model\": null\n                }\n            ]\n        }\n    ],\n    \"has_more\": false,\n    \"next_page\": null\n}\n"
  /organization/usage/code_interpreter_sessions:
    get:
      security:
      - AdminApiKeyAuth: []
      summary: Get code interpreter sessions usage details for the organization.
      operationId: usage-code-interpreter-sessions
      tags:
      - Usage
      parameters:
      - name: start_time
        in: query
        description: Start time (Unix seconds) of the query time range, inclusive.
        required: true
        schema:
          type: integer
      - name: end_time
        in: query
        description: End time (Unix seconds) of the query time range, exclusive.
        required: false
        schema:
          type: integer
      - name: bucket_width
        in: query
        description: Width of each time bucket in response. Currently `1m`, `1h` and `1d` are supported, default to `1d`.
        required: false
        schema:
          type: string
          enum:
          - 1m
          - 1h
          - 1d
          default: 1d
      - name: project_ids
        in: query
        description: Return only usage for these projects.
        required: false
        schema:
          type: array
          items:
            type: string
      - name: group_by
        in: query
        description: Group the usage data by the specified fields. Support fields include `project_id`.
        required: false
        schema:
          type: array
          items:
            type: string
            enum:
            - project_id
      - name: limit
        in: query
        description: '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

          '
        required: false
        schema:
          type: integer
      - name: page
        in: query
        description: A cursor for use in pagination. Corresponding to the `next_page` field from the previous response.
        schema:
          type: string
      responses:
        '200':
          description: Usage data retrieved successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageResponse'
      x-oaiMeta:
        name: Code interpreter sessions
        group: usage-code-interpreter-sessions
        examples:
          request:
            curl: 'curl "https://api.openai.com/v1/organization/usage/code_interpreter_sessions?start_time=1730419200&limit=1" \

              -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \

              -H "Content-Type: application/json"

              '
            node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n  adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.admin.organization.usage.codeInterpreterSessions({ start_time: 0 });\n\nconsole.log(response.data);"
            python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n    admin_api_key=os.environ.get(\"OPENAI_ADMIN_KEY\"),  # This is the default and can be omitted\n)\nresponse = client.admin.organization.usage.code_interpreter_sessions(\n    start_time=0,\n)\nprint(response.data)"
            go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tresponse, err := client.Admin.Organization.Usage.CodeInterpreterSessions(context.TODO(), openai.AdminOrganizationUsageCodeInterpreterSessionsParams{\n\t\tStartTime: 0,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n"
            java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.admin.organization.usage.UsageCodeInterpreterSessionsParams;\nimport com.openai.models.admin.organization.usage.UsageCodeInterpreterSessionsResponse;\n\npublic final class Main {\n    private Main() {}\n\n    public static void main(String[] args) {\n        OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n        UsageCodeInterpreterSessionsParams params = UsageCodeInterpreterSessionsParams.builder()\n            .startTime(0L)\n            .build();\n        UsageCodeInterpreterSessionsResponse response = client.admin().organization().usage().codeInterpreterSessions(params);\n    }\n}"
            ruby: 'require "openai"


              openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")


              response = openai.admin.organization.usage.code_interpreter_sessions(start_time: 0)


              puts(response)'
          response: "{\n    \"object\": \"page\",\n    \"data\": [\n        {\n            \"object\": \"bucket\",\n            \"start_time\": 1730419200,\n            \"end_time\": 1730505600,\n            \"results\": [\n                {\n                    \"object\": \"organization.usage.code_interpreter_sessions.result\",\n                    \"num_sessions\": 1,\n                    \"project_id\": null\n                }\n            ]\n        }\n    ],\n    \"has_more\": false,\n    \"next_page\": null\n}\n"
  /organization/usage/completions:
    get:
      security:
      - AdminApiKeyAuth: []
      summary: Get completions usage details for the organization.
      operationId: usage-completions
      tags:
      - Usage
      parameters:
      - name: start_time
        in: query
        description: Start time (Unix seconds) of the query time range, inclusive.
        required: true
        schema:
          type: integer
      - name: end_time
        in: query
        description: End time (Unix seconds) of the query time range, exclusive.
        required: false
        schema:
          type: integer
      - name: bucket_width
        in: query
        description: Width of each time bucket in response. Currently `1m`, `1h` and `1d` are supported, default to `1d`.
        required: false
        schema:
          type: string
          enum:
          - 1m
          - 1h
          - 1d
          default: 1d
      - name: project_ids
        in: query
        description: Return only usage for these projects.
        required: false
        schema:
          type: array
          items:
            type: string
      - name: user_ids
        in: query
        description: Return only usage for these users.
        required: false
        schema:
          type: array
          items:
            type: string
      - name: api_key_ids
        in: query
        description: Return only usage for these API keys.
        required: false
        schema:
          type: array
          items:
            type: string
      - name: models
        in: query
        description: Return only usage for these models.
        required: false
        schema:
          type: array
          items:
            type: string
      - name: batch
        in: query
        description: 'If `true`, return batch jobs only. If `false`, return non-batch jobs only. By default, return both.

          '
        required: false
        schema:
          type: boolean
      - name: group_by
        in: query
        description: Group the usage data by the specified fields. Support fields include `project_id`, `user_id`, `api_key_id`, `model`, `batch`, `service_tier` or any combination of them.
        required: false
        schema:
          type: array
          items:
            type: string
            enum:
            - project_id
            - user_id
            - api_key_id
            - model
            - batch
            - service_tier
      - name: limit
        in: query
        description: '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

          '
        required: false
        schema:
          type: integer
      - name: page
        in: query
        description: A cursor for use in pagination. Corresponding to the `next_page` field from the previous response.
        schema:
          type: string
      responses:
        '200':
          description: Usage data retrieved successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageResponse'
      x-oaiMeta:
        name: Completions
        group: usage-completions
        examples:
          request:
            curl: 'curl "https://api.openai.com/v1/organization/usage/completions?start_time=1730419200&limit=1" \

              -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \

              -H "Content-Type: application/json"

              '
            node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n  adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.admin.organization.usage.completions({ start_time: 0 });\n\nconsole.log(response.data);"
            python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n    admin_api_key=os.environ.get(\"OPENAI_ADMIN_KEY\"),  # This is the default and can be omitted\n)\nresponse = client.admin.organization.usage.completions(\n    start_time=0,\n)\nprint(response.data)"
            go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAdminAPIKey(\"My Admin API Key\"),\n\t)\n\tresponse, err := client.Admin.Organization.Usage.Completions(context.TODO(), openai.AdminOrganizationUsageCompletionsParams{\n\t\tStartTime: 0,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n"
            java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.admin.organization.usage.UsageCompletionsParams;\nimport com.openai.models.admin.organization.usage.UsageCompletionsResponse;\n\npublic final class Main {\n    private Main() {}\n\n    public static void main(String[] args) {\n        OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n        UsageCompletionsParams params = UsageCompletionsParams.builder()\n            .startTime(0L)\n            .build();\n        UsageCompletionsResponse response = client.admin().organization().usage().completions(params);\n    }\n}"
            ruby: 'require "openai"


              openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")


              response = openai.admin.organization.usage.completions(start_time: 0)


              puts(response)'
          response: "{\n    \"object\": \"page\",\n    \"data\": [\n        {\n            \"object\": \"bucket\",\n            \"start_time\": 1730419200,\n            \"end_time\": 1730505600,\n            \"results\": [\n                {\n                    \"object\": \"organization.usage.completions.result\",\n                    \"input_tokens\": 1000,\n                    \"output_tokens\": 500,\n                    \"input_cached_tokens\": 800,\n                    \"input_audio_tokens\": 0,\n                    \"output_audio_tokens\": 0,\n                    \"num_model_requests\": 5,\n                    \"project_id\": null,\n                    \"user_id\": null,\n                    \"api_key_id\": null,\n                    \"model\": null,\n                    \"batch\": null,\n                    \"service_tier\": null\n                }\n            ]\n        }\n    ],\n    \"has_more\": true,\n    \"next_page\": \"page_AAAAAGdGxdEiJdKOAAAAAGcqsYA=\"\n}\n"
  /organization/usage/embeddings:
    get:
      security:
      - AdminApiKeyAuth: []
      summary: Get embeddings usage details for the organization.
      operationId: usage-embeddings
      tags:
      - Usage
      parameters:
      - name: start_time
        in: query
        description: Start time (Unix seconds) of the query time range, inclusive.
        required: true
        schema:
          type: integer
      - name: end_time
        in: query
        description: End time (Unix seconds) of the query time range, exclusive.
        required: false
        schema:
          type: integer
      - name: bucket_width
        in: query
        description: Width of each time bucket in response. Currently `1m`, `1h` and `1d` are supported, default to `1d`.
        required: false
        schema:
          type: string
          enum:
          - 1m
          - 1h
          - 1d
          default: 1d
      - name: project_ids
        in: query
        description: Return only usage for these projects.
        required: false
        schema:
          type: array
          items:
            type: string
      - name: user_ids
        in: query
        description: Return only usage for these users.
        required: false
        schema:
          type: array
          items:
            type: string
      - name: api_key_ids
        in: query
        description: Return only usage for these API keys.
        required: false
        schema:
          type: array
          items:
            type: string
      - name: models
        in: query
        description: Return only usage for these models.
        required: false
        schema:
          type: array
          items:
            type: string
      - name: group_by
        in: query
        description: Group the usage data by the specified fields. Support fields include `project_id`, `user_id`, `api_key_id`, `model` or any combination of them.
        required: false
        schema:
          type: array
          items:
            type: string
            enum:
            - project_id
            - user_id
            - api_key_id
            - model
      - name: limit
        in: query
        description: '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

          '
        required: false
        schema:
          type: integer
      - name: page
        in: query
        description: A cursor for use in pagination. Corresponding to the `next_page` field from the previous response.
        schema:
          type: string
      responses:
        '200':
          description: Usage data retrieved successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Usag

# --- truncated at 32 KB (90 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/openai/refs/heads/main/openapi/openai-usage-api-openapi.yml