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

# AI cost breakdown for a period

> Splits the period's AI spend by what drove it — global prompt base, node instructions,
tool descriptions, knowledge base, tool results, conversation history, response format,
thinking, emitted tool calls and the reply itself.
            
Injected variable values are costed against the section they were injected into rather
than broken out separately, so the same substitution cannot appear under both the agent
node and the global prompt area.
            
The response separates flat-rate ("standard") traffic from cost-based ("metered") traffic.
Only the metered block carries shares and segments; multiply the shares by the metered
portion of the invoice to get dollars. Standard traffic is billed at a fixed per-message
rate, so it is reported as a call count alone — its real cost composition is captured
internally but deliberately never emitted, because it would describe money the customer
did not pay.



## OpenAPI

````yaml https://megastream25-api.closebot.com/swagger/v1/swagger.json get /agency/billing/ai-cost-breakdown
openapi: 3.0.4
info:
  title: CloseBot API
  version: v1
servers:
  - url: https://api.closebot.com
    description: CloseBot API Endpoint
security:
  - Key: []
tags:
  - name: Account
  - name: AccountNotification
  - name: Agency
  - name: Analytics
  - name: Billing
  - name: Bot
  - name: BotMetric
  - name: BotSourceVariable
  - name: BotTemplate
  - name: BotTesting
  - name: Dashboard
  - name: Hierarchy
  - name: Lead
  - name: Leaderboard
  - name: Library
  - name: LiveDemo
  - name: Notification
  - name: Persona
  - name: Report
  - name: SmartFAQ
  - name: Source
  - name: SourceChannel
  - name: Webhook
paths:
  /agency/billing/ai-cost-breakdown:
    get:
      tags:
        - Billing
      summary: AI cost breakdown for a period
      description: >-
        Splits the period's AI spend by what drove it — global prompt base, node
        instructions,

        tool descriptions, knowledge base, tool results, conversation history,
        response format,

        thinking, emitted tool calls and the reply itself.
                    
        Injected variable values are costed against the section they were
        injected into rather

        than broken out separately, so the same substitution cannot appear under
        both the agent

        node and the global prompt area.
                    
        The response separates flat-rate ("standard") traffic from cost-based
        ("metered") traffic.

        Only the metered block carries shares and segments; multiply the shares
        by the metered

        portion of the invoice to get dollars. Standard traffic is billed at a
        fixed per-message

        rate, so it is reported as a call count alone — its real cost
        composition is captured

        internally but deliberately never emitted, because it would describe
        money the customer

        did not pay.
      parameters:
        - name: startTime
          in: query
          schema:
            type: string
            format: date-time
        - name: endTime
          in: query
          schema:
            type: string
            format: date-time
        - name: sourceId
          in: query
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/AiCostBreakdownDto'
            application/json:
              schema:
                $ref: '#/components/schemas/AiCostBreakdownDto'
            text/json:
              schema:
                $ref: '#/components/schemas/AiCostBreakdownDto'
components:
  schemas:
    AiCostBreakdownDto:
      type: object
      properties:
        startTime:
          type: string
          format: date-time
        endTime:
          type: string
          format: date-time
        standard:
          $ref: '#/components/schemas/AiCostStandardDto'
        metered:
          $ref: '#/components/schemas/AiCostMeteredDto'
      additionalProperties: false
    AiCostStandardDto:
      type: object
      properties:
        calls:
          type: integer
          format: int32
      additionalProperties: false
    AiCostMeteredDto:
      type: object
      properties:
        calls:
          type: integer
          format: int32
        segments:
          type: number
          format: double
        shares:
          $ref: '#/components/schemas/AiCostSharesDto'
        tools:
          type: array
          items:
            $ref: '#/components/schemas/AiCostToolDto'
          nullable: true
      additionalProperties: false
    AiCostSharesDto:
      type: object
      properties:
        globalPromptBase:
          type: number
          format: double
        nodePrompting:
          type: number
          format: double
        toolDescriptions:
          type: number
          format: double
        knowledgeBase:
          type: number
          format: double
        toolCallResults:
          type: number
          format: double
        conversationHistory:
          type: number
          format: double
        responseFormat:
          type: number
          format: double
        thinking:
          type: number
          format: double
        toolCallsEmitted:
          type: number
          format: double
        message:
          type: number
          format: double
      additionalProperties: false
    AiCostToolDto:
      type: object
      properties:
        apiName:
          type: string
          nullable: true
        displayName:
          type: string
          nullable: true
        isCustom:
          type: boolean
        share:
          type: number
          format: double
      additionalProperties: false
  securitySchemes:
    Key:
      type: apiKey
      description: CloseBot API Key Authorization
      name: X-CB-KEY
      in: header

````