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

# Get the company AI credit usage

> Return the AI credits the company has consumed: the period total, a breakdown per feature (credits, metered generations and share of the total, highest spender first) and a per-day series. Defaults to the current UTC calendar month; pass `from` and `to` for another window. The AI usage page in the cockpit anchors its period on the subscription start date instead, so figures can differ for a company whose billing cycle does not start on the 1st.

<span className="badge-read">Key: Read</span><span className="badge-company">Scope: Company</span>


## OpenAPI

````yaml https://api.getprimo.com/openapi.json get /ai-usage
openapi: 3.1.1
info:
  title: Public API - BETA
  description: Read docs on https://docs.getprimo.com/
  version: '1.0'
  contact: {}
servers:
  - url: https://api.getprimo.com
security:
  - apikey: []
tags: []
paths:
  /ai-usage:
    get:
      tags:
        - AiUsage
      summary: Get the company AI credit usage
      description: >-
        Return the AI credits the company has consumed: the period total, a
        breakdown per feature (credits, metered generations and share of the
        total, highest spender first) and a per-day series. Defaults to the
        current UTC calendar month; pass `from` and `to` for another window. The
        AI usage page in the cockpit anchors its period on the subscription
        start date instead, so figures can differ for a company whose billing
        cycle does not start on the 1st.
      operationId: getAiUsage
      parameters:
        - name: from
          required: false
          in: query
          description: Start of the period, ISO 8601
          schema:
            type: string
            format: date-time
            pattern: >-
              ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
        - name: to
          required: false
          in: query
          description: End of the period, ISO 8601
          schema:
            type: string
            format: date-time
            pattern: >-
              ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
      responses:
        default:
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetAiUsage_Output'
components:
  schemas:
    GetAiUsage_Output:
      type: object
      properties:
        from:
          type: string
          description: Start of the period the figures cover, inclusive
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
        to:
          type: string
          description: End of the period the figures cover, exclusive
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
        totalCredits:
          type: number
          description: Credits spent across every feature over the period
        totalRunCount:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        byFeature:
          type: array
          description: Highest spending feature first
          items:
            type: object
            properties:
              feature:
                description: The product surface the credits were spent on
                type: string
                enum:
                  - chat
                  - custom_agent
                  - trigger
                  - tickets
                  - it_support
                  - onboarding
                  - offboarding
                  - equipment_policy
                  - purchasing_policy
                  - custom_fields_auto_fill
                  - compliance
              runCount:
                description: Number of metered generations recorded for this feature
                type: integer
                minimum: -9007199254740991
                maximum: 9007199254740991
              credits:
                description: Credits spent by this feature over the period
                type: number
              sharePercent:
                description: Share of the period total credits, in percent, rounded
                type: number
              inputTokens:
                type: integer
                minimum: -9007199254740991
                maximum: 9007199254740991
              outputTokens:
                type: integer
                minimum: -9007199254740991
                maximum: 9007199254740991
              totalTokens:
                type: integer
                minimum: -9007199254740991
                maximum: 9007199254740991
            required:
              - feature
              - runCount
              - credits
              - sharePercent
              - inputTokens
              - outputTokens
              - totalTokens
            additionalProperties: false
        byDay:
          type: array
          description: One entry per day that recorded usage, chronological
          items:
            type: object
            properties:
              day:
                type: string
                format: date
                pattern: >-
                  ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))$
              credits:
                type: number
              runCount:
                type: integer
                minimum: -9007199254740991
                maximum: 9007199254740991
            required:
              - day
              - credits
              - runCount
            additionalProperties: false
      required:
        - from
        - to
        - totalCredits
        - totalRunCount
        - byFeature
        - byDay
      additionalProperties: false
  securitySchemes:
    apikey:
      scheme: bearer
      bearerFormat: API key
      type: http
      description: >-
        Use your Primo API key in the Authorization header as `Bearer
        <API_KEY>`.

````