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

# Get Usage Query

> Return aggregated usage data grouped by a chosen dimension.



## OpenAPI

````yaml /api-reference/openapi.json get /v1/billing/usage
openapi: 3.1.0
info:
  title: faces
  version: 0.101.0
servers: []
security: []
paths:
  /v1/billing/usage:
    get:
      tags:
        - Billing
      summary: Get Usage Query
      description: Return aggregated usage data grouped by a chosen dimension.
      operationId: get_usage_query_v1_billing_usage_get
      parameters:
        - name: group_by
          in: query
          required: false
          schema:
            type: string
            description: >-
              Grouping dimension: api_key_id | model_iam_id | llm_model |
              model_username | date
            default: model_iam_id
            title: Group By
          description: >-
            Grouping dimension: api_key_id | model_iam_id | llm_model |
            model_username | date
        - name: api_key_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Filter by API key UUID
            title: Api Key Id
          description: Filter by API key UUID
        - name: model_username
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Filter by model IAM username
            title: Model Username
          description: Filter by model IAM username
        - name: model_iam_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Filter by model IAM UUID
            title: Model Iam Id
          description: Filter by model IAM UUID
        - name: llm_model
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Filter by model id, as `group_by=llm_model` reports it
            title: Llm Model
          description: Filter by model id, as `group_by=llm_model` reports it
        - name: from_date
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Start date (ISO format, inclusive)
            title: From Date
          description: Start date (ISO format, inclusive)
        - name: to_date
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: End date (ISO format, inclusive)
            title: To Date
          description: End date (ISO format, inclusive)
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Authorization
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageQueryResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    UsageQueryResponse:
      properties:
        rows:
          items:
            $ref: '#/components/schemas/UsageRow'
          type: array
          title: Rows
        totals:
          $ref: '#/components/schemas/UsageRow'
      type: object
      required:
        - rows
        - totals
      title: UsageQueryResponse
      description: Response for GET /v1/billing/usage grouped query.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    UsageRow:
      properties:
        group_key:
          type: string
          title: Group Key
        group_label:
          type: string
          title: Group Label
        input_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Input Tokens
        output_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Output Tokens
        provider_cost_usd:
          type: number
          title: Provider Cost Usd
        markup_usd:
          type: number
          title: Markup Usd
        total_cost_usd:
          type: number
          title: Total Cost Usd
        request_count:
          type: integer
          title: Request Count
      type: object
      required:
        - group_key
        - group_label
        - input_tokens
        - output_tokens
        - provider_cost_usd
        - markup_usd
        - total_cost_usd
        - request_count
      title: UsageRow
      description: One row in a usage GROUP BY result.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.