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

# List spend summaries

> Reconciliation checksum fast path: spend rollups with token classes and integer nano-USD cost. Settled (unpriced) requests are counted separately as settled_count and never included in cost sums. Diff individual items via /spend-events only when a checksum diverges. `group_by` takes one or two of virtual_key, end_user, project, model, provider, principal and request_type, comma-separated, and `bucket` adds an hour or day column in the `timezone` you name. `key` stays the first dimension's value for consumers written against the single-dimension surface; read `group` to tell two dimensions apart. Paged by group key ascending: follow next_cursor until it comes back null, because a page that is full does not mean the window held nothing more. Grouping by model or provider, or into time buckets, is refused with `gateway_spend_group_by_unstable` while the window is recent enough that outcomes can still arrive, because those groups can move under a page walk and the totals would double-count some requests and miss others; ask for an older range, or send `allow_unstable` when an approximate shape is enough. Every filter here is accepted by /spend-events too, and the reverse holds apart from `status=admitted`: a rollup sums the cost of requests past admission, so an admitted request has none to contribute and that narrowing is refused rather than answered with a zero. Ask /spend-events for those.



## OpenAPI

````yaml GET /api/gateway/v1/spend-summaries
openapi: 3.1.0
info:
  title: LangWatch API
  version: 1.0.0
  description: LangWatch openapi spec
servers:
  - url: https://app.langwatch.ai
security:
  - project_api_key: []
paths:
  /api/gateway/v1/spend-summaries:
    get:
      tags:
        - Gateway Spend
      summary: List spend summaries
      description: >-
        Reconciliation checksum fast path: spend rollups with token classes and
        integer nano-USD cost. Settled (unpriced) requests are counted
        separately as settled_count and never included in cost sums. Diff
        individual items via /spend-events only when a checksum diverges.
        `group_by` takes one or two of virtual_key, end_user, project, model,
        provider, principal and request_type, comma-separated, and `bucket` adds
        an hour or day column in the `timezone` you name. `key` stays the first
        dimension's value for consumers written against the single-dimension
        surface; read `group` to tell two dimensions apart. Paged by group key
        ascending: follow next_cursor until it comes back null, because a page
        that is full does not mean the window held nothing more. Grouping by
        model or provider, or into time buckets, is refused with
        `gateway_spend_group_by_unstable` while the window is recent enough that
        outcomes can still arrive, because those groups can move under a page
        walk and the totals would double-count some requests and miss others;
        ask for an older range, or send `allow_unstable` when an approximate
        shape is enough. Every filter here is accepted by /spend-events too, and
        the reverse holds apart from `status=admitted`: a rollup sums the cost
        of requests past admission, so an admitted request has none to
        contribute and that narrowing is refused rather than answered with a
        zero. Ask /spend-events for those.
      operationId: getApiGatewayV1Spend-summaries
      parameters:
        - in: query
          name: group_by
          schema:
            type: string
            description: >-
              One or two dimensions, comma separated: virtual_key, end_user,
              project, model, provider, principal, request_type. A dimension may
              not repeat. Each row's `key` is the first dimension's value and
              `group` names them all, so two rows may share a key.
            example: model,end_user
          required: true
        - in: query
          name: bucket
          schema:
            type: string
            enum:
              - none
              - hour
              - day
            default: none
          required: false
        - in: query
          name: timezone
          schema:
            type: string
            minLength: 1
            maxLength: 64
            default: UTC
          required: false
        - in: query
          name: allow_unstable
          schema:
            type: string
            default: 'false'
            description: >-
              true, 1, yes for yes; false, 0, no or omitted for no. Case does
              not matter, so a Python True is accepted as sent.
            example: 'true'
          required: false
        - in: query
          name: from
          schema:
            type: integer
            exclusiveMinimum: 0
            maximum: 9007199254740991
            description: >-
              Milliseconds since the Unix epoch, not seconds. An epoch in
              seconds is a valid integer here and answers for 1970, so a
              mismatched unit reads as an empty window rather than as an error.
            example: 1782864000000
          required: true
        - in: query
          name: to
          schema:
            type: integer
            exclusiveMinimum: 0
            maximum: 9007199254740991
            description: >-
              Milliseconds since the Unix epoch, not seconds. An epoch in
              seconds is a valid integer here and answers for 1970, so a
              mismatched unit reads as an empty window rather than as an error.
            example: 1782864000000
          required: true
        - in: query
          name: cursor
          schema:
            type: string
            maxLength: 500
          required: false
        - in: query
          name: limit
          schema:
            type: integer
            exclusiveMinimum: 0
            maximum: 1000
            default: 500
          required: false
        - in: query
          name: project_id
          schema:
            anyOf:
              - type: string
                minLength: 1
                maxLength: 100
              - type: array
                items:
                  type: string
                  minLength: 1
                  maxLength: 100
                maxItems: 100
          required: false
        - in: query
          name: team_id
          schema:
            anyOf:
              - type: string
                minLength: 1
                maxLength: 100
              - type: array
                items:
                  type: string
                  minLength: 1
                  maxLength: 100
                maxItems: 100
          required: false
        - in: query
          name: external_id
          schema:
            anyOf:
              - type: string
                minLength: 1
                maxLength: 200
              - type: array
                items:
                  type: string
                  minLength: 1
                  maxLength: 200
                maxItems: 100
          required: false
        - in: query
          name: virtual_key_id
          schema:
            anyOf:
              - type: string
                minLength: 1
                maxLength: 100
              - type: array
                items:
                  type: string
                  minLength: 1
                  maxLength: 100
                maxItems: 100
          required: false
        - in: query
          name: end_user_id
          schema:
            anyOf:
              - type: string
                minLength: 1
                maxLength: 256
              - type: array
                items:
                  type: string
                  minLength: 1
                  maxLength: 256
                maxItems: 100
          required: false
        - in: query
          name: principal_user_id
          schema:
            anyOf:
              - type: string
                minLength: 1
                maxLength: 100
              - type: array
                items:
                  type: string
                  minLength: 1
                  maxLength: 100
                maxItems: 100
          required: false
        - in: query
          name: model
          schema:
            anyOf:
              - type: string
                minLength: 1
                maxLength: 200
              - type: array
                items:
                  type: string
                  minLength: 1
                  maxLength: 200
                maxItems: 100
          required: false
        - in: query
          name: provider_key
          schema:
            anyOf:
              - type: string
                minLength: 1
                maxLength: 100
              - type: array
                items:
                  type: string
                  minLength: 1
                  maxLength: 100
                maxItems: 100
          required: false
        - in: query
          name: request_type
          schema:
            anyOf:
              - type: string
                minLength: 1
                maxLength: 50
              - type: array
                items:
                  type: string
                  minLength: 1
                  maxLength: 50
                maxItems: 100
          required: false
        - in: query
          name: label
          schema:
            anyOf:
              - type: string
                minLength: 1
                maxLength: 200
              - type: array
                items:
                  type: string
                  minLength: 1
                  maxLength: 200
                maxItems: 100
          required: false
        - in: query
          name: metadata
          schema:
            anyOf:
              - type: string
                minLength: 3
                maxLength: 640
              - type: array
                items:
                  type: string
                  minLength: 3
                  maxLength: 640
                maxItems: 100
          required: false
        - in: query
          name: status
          schema:
            type: string
            enum:
              - success
              - error
              - confirmed
              - failed
              - settled
            description: >-
              Narrow to one lifecycle status. `admitted` is not accepted here: a
              rollup sums the cost of requests past admission, and an admitted
              request is still in flight with no cost of its own yet. Ask
              /spend-events for those.
          required: false
      responses:
        '200':
          description: Per-key spend rollups
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        key:
                          type: string
                        group:
                          type: object
                          additionalProperties:
                            type: string
                        bucket_start:
                          type:
                            - string
                            - 'null'
                        event_count:
                          type: integer
                        settled_count:
                          type: integer
                        usage:
                          type: object
                          properties:
                            input_tokens:
                              type: integer
                            output_tokens:
                              type: integer
                            cache_read_input_tokens:
                              type: integer
                            cache_creation_input_tokens:
                              type: integer
                            reasoning_tokens:
                              type: integer
                          required:
                            - input_tokens
                            - output_tokens
                            - cache_read_input_tokens
                            - cache_creation_input_tokens
                            - reasoning_tokens
                        cost:
                          type: object
                          properties:
                            total_usd:
                              type: string
                              description: >-
                                Display value. Decimal string, up to 9
                                fractional digits, trailing zeros trimmed, never
                                exponent notation. Use nano_usd for arithmetic.
                            nano_usd:
                              type: integer
                              description: >-
                                Canonical integer cost, nano-USD. Rated as an
                                integer and summed as one, so this is the figure
                                to reconcile against.
                          required:
                            - total_usd
                            - nano_usd
                      required:
                        - key
                        - group
                        - bucket_start
                        - event_count
                        - settled_count
                        - usage
                        - cost
                  next_cursor:
                    type:
                      - string
                      - 'null'
                required:
                  - data
                  - next_cursor
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                      message:
                        type: string
                      meta:
                        type: object
                        additionalProperties: {}
                      trace_id:
                        type: string
                      span_id:
                        type: string
                    required:
                      - type
                      - code
                      - message
                required:
                  - error
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                      message:
                        type: string
                      meta:
                        type: object
                        additionalProperties: {}
                      trace_id:
                        type: string
                      span_id:
                        type: string
                    required:
                      - type
                      - code
                      - message
                required:
                  - error
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                      message:
                        type: string
                      meta:
                        type: object
                        additionalProperties: {}
                      trace_id:
                        type: string
                      span_id:
                        type: string
                    required:
                      - type
                      - code
                      - message
                required:
                  - error
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                      message:
                        type: string
                      meta:
                        type: object
                        additionalProperties: {}
                      trace_id:
                        type: string
                      span_id:
                        type: string
                    required:
                      - type
                      - code
                      - message
                required:
                  - error
      security:
        - admin_api_key: []
components:
  securitySchemes:
    project_api_key:
      type: apiKey
      in: header
      name: X-Auth-Token
      description: >-
        Project API key for sending traces and accessing project-scoped
        resources. Format: sk-lw-... (no underscore). Obtain one by creating a
        project via the Admin API or the LangWatch UI.
    admin_api_key:
      type: http
      scheme: bearer
      description: >-
        Admin API key for organization-level operations (managing projects, API
        keys). Create one in Settings > API Keys or via POST /api/api-keys.
        Format: sk-lw-{id}_{secret}.

````