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

# Get the estimated cost, LLM spans and tokens of a period split by model, version or end user

> The sessions `GET /analytics/cost-overview` counts, split into one row per model, version or end user, with every row returned. The rows add up to the `totalCost` of `GET /analytics/cost-overview` for the same filters. The end user is only set on turns built from OpenTelemetry spans. Needs `evaluation.readInference` on every product of the sum, else 403.



## OpenAPI

````yaml /openapi.json get /analytics/cost-breakdown
openapi: 3.0.0
info:
  version: 1.0.0
  title: Product Management Service API
  description: API documentation for Product Management Service
  contact:
    name: Galtea AI
servers:
  - url: https://api.galtea.ai
security:
  - bearerAuth: []
tags: []
externalDocs:
  description: Galtea Platform Documentation
  url: https://docs.galtea.ai
paths:
  /analytics/cost-breakdown:
    get:
      tags:
        - analytics
      summary: >-
        Get the estimated cost, LLM spans and tokens of a period split by model,
        version or end user
      description: >-
        The sessions `GET /analytics/cost-overview` counts, split into one row
        per model, version or end user, with every row returned. The rows add up
        to the `totalCost` of `GET /analytics/cost-overview` for the same
        filters. The end user is only set on turns built from OpenTelemetry
        spans. Needs `evaluation.readInference` on every product of the sum,
        else 403.
      operationId: getCostBreakdown
      parameters:
        - schema:
            type: string
            format: date-time
            description: Start of the period, inclusive (ISO 8601)
          required: true
          description: Start of the period, inclusive (ISO 8601)
          name: from
          in: query
        - schema:
            type: string
            format: date-time
            description: >-
              End of the period, exclusive (ISO 8601). A period that does not
              end after `from`, or is longer than 1830 days (5 years), is
              rejected with 400.
          required: true
          description: >-
            End of the period, exclusive (ISO 8601). A period that does not end
            after `from`, or is longer than 1830 days (5 years), is rejected
            with 400.
          name: to
          in: query
        - schema:
            type: boolean
            description: >-
              Count production sessions when true, development sessions when
              false.
          required: true
          description: >-
            Count production sessions when true, development sessions when
            false.
          name: isProduction
          in: query
        - schema:
            type: string
            description: >-
              The organization whose products to read. Defaults to the caller's
              own organization. Another organization reads products only for a
              caller that may read across organizations.
          required: false
          description: >-
            The organization whose products to read. Defaults to the caller's
            own organization. Another organization reads products only for a
            caller that may read across organizations.
          name: organizationId
          in: query
        - schema:
            type: string
            description: Keep the products whose name contains this (case-insensitive)
          required: false
          description: Keep the products whose name contains this (case-insensitive)
          name: name
          in: query
        - schema:
            type: array
            items:
              type: string
            description: Keep the products that carry any of these tags
          required: false
          description: Keep the products that carry any of these tags
          style: form
          explode: true
          name: tags
          in: query
        - schema:
            type: array
            items:
              type: string
            description: >-
              Keep only these products. A product outside the caller's grant is
              refused with 403; a product of another organization, or a deleted
              one, matches nothing. At most 25.
            maxItems: 25
          required: false
          description: >-
            Keep only these products. A product outside the caller's grant is
            refused with 403; a product of another organization, or a deleted
            one, matches nothing. At most 25.
          style: form
          explode: true
          name: productIds
          in: query
        - schema:
            type: string
            enum:
              - model
              - version
              - endUser
            description: >-
              The value each row stands for: the model that answered each LLM
              span, the version, or the end user of each turn
            example: model
          required: true
          description: >-
            The value each row stands for: the model that answered each LLM
            span, the version, or the end user of each turn
          name: groupBy
          in: query
      responses:
        '200':
          description: The cost of the products per value
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CostBreakdown'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    CostBreakdown:
      type: object
      properties:
        rows:
          type: array
          items:
            $ref: '#/components/schemas/CostBreakdownRow'
          description: >-
            Every value, the highest cost first. Each turn's estimated cost is
            split over the LLM spans it counts, each LLM call once and under the
            model it reports; the part of a turn's cost that its spans do not
            carry goes to the version model. So the rows add up to `total`,
            which is the `totalCost` of `GET /analytics/cost-overview` for the
            same filters.
        total:
          type: object
          properties:
            llmSpanCount:
              type: integer
              description: >-
                Spans the turns count for their usage, one each, plus one for
                each turn that counts none but reports a cost or tokens itself.
                A call whose input and output sit on two spans counts as two.
            inputTokens:
              type: integer
              description: Input tokens of those LLM spans
            outputTokens:
              type: integer
              description: Output tokens of those LLM spans
            cost:
              type: number
              nullable: true
              description: Estimated cost. Null when nothing counted carries a cost.
          required:
            - llmSpanCount
            - inputTokens
            - outputTokens
            - cost
          description: The sum of every row
      required:
        - rows
        - total
    Error:
      type: object
      properties:
        error:
          type: string
          example: Error type
        message:
          type: string
          example: Error message description
    CostBreakdownRow:
      type: object
      properties:
        key:
          type: string
          nullable: true
          description: >-
            The grouped value: the model name in lowercase, the version id, or
            the end user. Null when neither the span nor its version names a
            model, or when the turn has no end user.
        label:
          type: string
          nullable: true
          description: >-
            The model name, the version label (v<number>, or v<number>: <name>
            when the version has a custom name), or the end user
        llmSpanCount:
          type: integer
          description: >-
            Spans the turns count for their usage, one each, plus one for each
            turn that counts none but reports a cost or tokens itself. A call
            whose input and output sit on two spans counts as two.
        inputTokens:
          type: integer
          description: Input tokens of those LLM spans
        outputTokens:
          type: integer
          description: Output tokens of those LLM spans
        cost:
          type: number
          nullable: true
          description: Estimated cost. Null when nothing counted carries a cost.
      required:
        - key
        - label
        - llmSpanCount
        - inputTokens
        - outputTokens
        - cost
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authorization. Pass your API key in the Authorization header as
        a Bearer token. Both new (`gsk_*`) and legacy (`gsk-`) API keys are
        accepted, e.g. `Authorization: Bearer gsk_...` or `Authorization: Bearer
        gsk-...`.

````

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