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

# Query spend

> Requires spend:read. Filters are intersected. UTC dates use an exclusive end, at most 366 days apart. key groups and sdkKeyId refer to Brello ingestion keys. Retained daily totals are included with date and environment filters and have a null dimension when grouped by anything other than day. Filters by provider, model, key, end user, or feature use retained request details only. This is SDK estimated usage.

Requires `spend:read`. Use `groupBy` to break down spend. The `total` covers all matching requests, and pagination applies to `groups`.

See [Query usage and reports](https://docs.brello.app/sdk/guides/read-api.md) for filters, units, and unknown costs.


## OpenAPI

````yaml sdk/openapi.json GET /spend
openapi: 3.1.0
info:
  title: Brello Public API
  version: 1.0.0-beta.3
  description: >-
    Public SDK ingestion, scoped read endpoints, and outgoing signed webhooks.
    Read spend is SDK estimated cost; it is not a complete provider invoice. SDK
    content is not collected.
servers:
  - url: https://api.brello.app/v1
security: []
paths:
  /spend:
    get:
      tags:
        - Spend
      summary: Query SDK estimated spend
      description: >-
        Requires spend:read. Filters are intersected. UTC dates use an exclusive
        end, at most 366 days apart. key groups and sdkKeyId refer to Brello
        ingestion keys. Retained daily totals are included with date and
        environment filters and have a null dimension when grouped by anything
        other than day. Filters by provider, model, key, end user, or feature
        use retained request details only. This is SDK estimated usage.
      operationId: getSpend
      parameters:
        - schema:
            type: string
            format: date
          required: false
          name: from
          in: query
        - schema:
            type: string
            format: date
          required: false
          name: to
          in: query
        - schema:
            type: string
            enum:
              - all
              - live
              - test
            default: all
          required: false
          name: environment
          in: query
        - schema:
            type: string
            enum:
              - openai
              - anthropic
          required: false
          name: provider
          in: query
        - schema:
            type: string
            minLength: 1
            maxLength: 256
          required: false
          name: model
          in: query
        - schema:
            type: string
            format: uuid
          required: false
          name: sdkKeyId
          in: query
        - schema:
            type: string
            format: uuid
          required: false
          name: endUserId
          in: query
        - schema:
            type: string
            pattern: ^[a-f0-9]{64}$
          required: false
          name: providerKeyFingerprint
          in: query
        - schema:
            type: string
            minLength: 1
            maxLength: 64
          required: false
          name: feature
          in: query
        - schema:
            type: string
            enum:
              - day
              - model
              - key
              - providerKey
              - endUser
              - feature
              - provider
            default: day
          required: false
          name: groupBy
          in: query
        - schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 50
          required: false
          name: limit
          in: query
        - schema:
            type:
              - integer
              - 'null'
            minimum: 0
            maximum: 10000
            default: 0
          required: false
          name: offset
          in: query
      responses:
        '200':
          description: >-
            Estimated spend. A null total means some requests could not be
            priced.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      projectId:
                        type: string
                        format: uuid
                      period:
                        type: object
                        properties:
                          from:
                            type: string
                            format: date
                          to:
                            type: string
                            format: date
                          timeZone:
                            type: string
                            enum:
                              - UTC
                          endExclusive:
                            type: boolean
                            enum:
                              - true
                        required:
                          - from
                          - to
                          - timeZone
                          - endExclusive
                      environment:
                        type: string
                        enum:
                          - all
                          - live
                          - test
                      groupBy:
                        type: string
                        enum:
                          - day
                          - model
                          - key
                          - providerKey
                          - endUser
                          - feature
                          - provider
                        default: day
                      total:
                        $ref: '#/components/schemas/PublicCostSummary'
                      groups:
                        type: array
                        items:
                          allOf:
                            - $ref: '#/components/schemas/PublicCostSummary'
                            - type: object
                              properties:
                                dimension:
                                  type:
                                    - string
                                    - 'null'
                              required:
                                - dimension
                      pagination:
                        type: object
                        properties:
                          limit:
                            type: number
                          offset:
                            type: number
                          hasMore:
                            type: boolean
                        required:
                          - limit
                          - offset
                          - hasMore
                    required:
                      - projectId
                      - period
                      - environment
                      - total
                      - groups
                      - pagination
                required:
                  - data
        '400':
          description: Invalid parameters or JSON. Fix the request before retrying.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
        '401':
          description: Invalid, expired, revoked, or suspended-issuer API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
        '403':
          description: The API key does not contain the required scope.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
        '404':
          description: Resource not found in the authenticated project.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
        '413':
          description: Request body exceeds 16,384 bytes.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
        '429':
          description: Rate limit exceeded. Retry after the indicated number of seconds.
          headers:
            Retry-After:
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
        '503':
          description: Temporarily unavailable. Retry with bounded backoff.
          headers:
            Retry-After:
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
      security:
        - publicApiKey: []
components:
  schemas:
    PublicCostSummary:
      type: object
      properties:
        currency:
          type: string
          enum:
            - USD
        costSource:
          type: string
          enum:
            - sdk_estimate
        requestCount:
          type: string
          pattern: ^\d+$
        knownEstimatedCostMicros:
          type: string
          pattern: ^\d+$
        estimatedCostMicros:
          type:
            - string
            - 'null'
          pattern: ^\d+$
        unpricedRequestCount:
          type: string
          pattern: ^\d+$
      required:
        - currency
        - costSource
        - requestCount
        - knownEstimatedCostMicros
        - estimatedCostMicros
        - unpricedRequestCount
    PublicApiError:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
            requestId:
              type: string
          required:
            - code
            - message
            - requestId
      required:
        - error
  securitySchemes:
    publicApiKey:
      type: http
      scheme: bearer
      bearerFormat: brl_read_<43 Base64URL characters>

````

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