> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lightdash.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get AI credit usage

> The organization's AI usage for the current period, in tokens and credits,
with its allowance when one is agreed. Organization admins only.



## OpenAPI

````yaml https://raw.githubusercontent.com/lightdash/lightdash/refs/heads/main/packages/backend/src/generated/swagger.json get /api/v1/org/ai-credits/usage
openapi: 3.0.0
info:
  title: Lightdash API
  version: 2.397.0
  description: >
    Open API documentation for all public Lightdash API endpoints. #
    Authentication Before you get started, you might need to create a Personal
    Access Token to authenticate via the API. You can create a token by
    following this guide: https://docs.lightdash.com/references/personal_tokens
  license:
    name: MIT
  contact:
    name: Lightdash Support
    email: support@lightdash.com
    url: https://docs.lightdash.com/help-and-contact/contact/contact_info/
servers:
  - url: /
security: []
tags:
  - name: My Account
    description: These routes allow users to manage their own user account.
  - name: Organizations
    description: >-
      Each user is a member of a single organization. These routes allow users
      to manage their organization. Most actions are only available to admin
      users.
  - name: Projects
    description: >-
      Projects belong to a single organization. These routes allow users to
      manage their projects, browse content, and execute queries. Users inside
      an organization might have access to a project from an organization-level
      role or they might be granted access to a project directly.
  - name: Spaces
    description: >-
      Spaces allow you to organize charts and dashboards within a project. They
      also allow granular access to content by allowing you to create private
      spaces, which are only accessible to the creator and admins.
  - name: Roles & Permissions
    description: >-
      These routes allow users to manage roles and permissions for their
      organization.
    externalDocs:
      url: https://docs.lightdash.com/references/roles
  - name: Query
    description: >-
      These routes allow users to execute and manage queries against their data
      warehouse. This includes metric queries, SQL queries, and retrieving query
      results.
paths:
  /api/v1/org/ai-credits/usage:
    get:
      summary: Get AI credit usage
      description: >-
        The organization's AI usage for the current period, in tokens and
        credits,

        with its allowance when one is agreed. Organization admins only.
      operationId: getOrganizationAiCreditUsage
      parameters: []
      responses:
        '200':
          description: Retrieved AI credit usage
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiAiCreditUsageResponse'
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorPayload'
      security: []
components:
  schemas:
    ApiAiCreditUsageResponse:
      $ref: '#/components/schemas/ApiSuccess_AiCreditUsageSummary_'
    ApiErrorPayload:
      properties:
        error:
          properties:
            data:
              $ref: '#/components/schemas/AnyType'
              description: Optional data containing details of the error
            message:
              type: string
              description: A friendly message summarising the error
            name:
              type: string
              description: Unique name for the type of error
            statusCode:
              type: number
              format: integer
              description: HTTP status code
          required:
            - name
            - statusCode
          type: object
        status:
          type: string
          enum:
            - error
          nullable: false
      required:
        - error
        - status
      type: object
      description: |-
        The Error object is returned from the api any time there is an error.
        The message contains
    ApiSuccess_AiCreditUsageSummary_:
      properties:
        results:
          $ref: '#/components/schemas/AiCreditUsageSummary'
        status:
          type: string
          enum:
            - ok
          nullable: false
      required:
        - results
        - status
      type: object
    AnyType:
      description: |-
        This AnyType is an alias for any
        The goal is to make it easier to identify any type in the codebase
        without having to eslint-disable all the time
        These are only used on legacy `any` types, don't use it for new types.
        This is added on a separate file to avoid circular dependencies.
    AiCreditUsageSummary:
      properties:
        activeHolds:
          items:
            $ref: '#/components/schemas/AiCreditHold'
          type: array
        byKeyOrigin:
          items:
            $ref: '#/components/schemas/AiCreditUsageBreakdownRow'
          type: array
        byChannel:
          items:
            $ref: '#/components/schemas/AiCreditUsageBreakdownRow'
          type: array
        byTier:
          items:
            $ref: '#/components/schemas/AiCreditUsageBreakdownRow'
          type: array
        byFeature:
          items:
            $ref: '#/components/schemas/AiCreditUsageBreakdownRow'
          type: array
        unpricedTokens:
          type: number
          format: double
        excluded:
          $ref: '#/components/schemas/AiCreditUsageTotals'
        selfManaged:
          $ref: '#/components/schemas/AiCreditUsageTotals'
        billable:
          $ref: '#/components/schemas/AiCreditUsageTotals'
        canShowCredits:
          type: boolean
        contract:
          allOf:
            - $ref: '#/components/schemas/Omit_AiCreditContract.organizationUuid_'
          nullable: true
        period:
          $ref: '#/components/schemas/AiCreditPeriod'
      required:
        - activeHolds
        - byKeyOrigin
        - byChannel
        - byTier
        - byFeature
        - unpricedTokens
        - excluded
        - selfManaged
        - billable
        - canShowCredits
        - contract
        - period
      type: object
    AiCreditHold:
      properties:
        releasedAt:
          type: string
          format: date-time
          nullable: true
        expiresAt:
          type: string
          format: date-time
          nullable: true
        placedAt:
          type: string
          format: date-time
        placedBy:
          type: string
        notes:
          type: string
          nullable: true
        reason:
          $ref: '#/components/schemas/AiCreditHoldReason'
        contractUuid:
          type: string
          nullable: true
        userUuid:
          type: string
          nullable: true
        organizationUuid:
          type: string
        uuid:
          type: string
      required:
        - releasedAt
        - expiresAt
        - placedAt
        - placedBy
        - notes
        - reason
        - contractUuid
        - userUuid
        - organizationUuid
        - uuid
      type: object
    AiCreditUsageBreakdownRow:
      allOf:
        - $ref: '#/components/schemas/AiCreditUsageTotals'
        - properties:
            key:
              type: string
          required:
            - key
          type: object
    AiCreditUsageTotals:
      properties:
        calls:
          type: number
          format: double
        tokens:
          type: number
          format: double
        credits:
          type: number
          format: double
      required:
        - calls
        - tokens
        - credits
      type: object
    Omit_AiCreditContract.organizationUuid_:
      $ref: >-
        #/components/schemas/Pick_AiCreditContract.Exclude_keyofAiCreditContract.organizationUuid__
      description: Construct a type with the properties of T except for those in type K.
    AiCreditPeriod:
      properties:
        periodEnd:
          type: string
          format: date-time
        periodStart:
          type: string
          format: date-time
      required:
        - periodEnd
        - periodStart
      type: object
    AiCreditHoldReason:
      type: string
      enum:
        - allowance_exhausted
        - admin_cap_reached
        - manual_pause
        - trial_ended
    Pick_AiCreditContract.Exclude_keyofAiCreditContract.organizationUuid__:
      properties:
        uuid:
          type: string
        startsAt:
          type: string
          format: date-time
        endsAt:
          type: string
          format: date-time
          nullable: true
        resetIntervalMonths:
          type: number
          format: double
        allowanceCredits:
          type: number
          format: double
          nullable: true
      required:
        - uuid
        - startsAt
        - endsAt
        - resetIntervalMonths
        - allowanceCredits
      type: object
      description: From T, pick a set of properties whose keys are in the union K

````