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

# Query costs and resources allocated to Kubernetes workloads

> OpenCost-compatible allocation query. Returns one allocation set per step in the window, each keyed by the aggregated resource name. CPU and RAM are billed on the greater of request and usage, per the OpenCost specification. Unallocated node cost is returned as __idle__ unless shareIdle distributes it. Storage and network cost are not included.



## OpenAPI

````yaml /api-reference/costgraph/openapi.json get /api/v1/tenant/opencost/allocation
openapi: 3.0.0
info:
  description: Read and manage your CostGraph organization, spend, alerts, and settings.
  title: CostGraph API
  contact: {}
  version: '1.0'
servers:
  - url: https://api.costgraph.ai
security: []
tags:
  - name: ai
    x-group: AI
  - name: ai-serving
    x-group: AI serving
  - name: anomalies
    x-group: Anomalies
  - name: auth
    x-group: Auth
  - name: billing
    x-group: Billing
  - name: billing-export
    x-group: Billing export
  - name: budgets
    x-group: Budgets
  - name: ci
    x-group: CI
  - name: compute-recommendations
    x-group: Compute recommendations
  - name: config
    x-group: Config
  - name: cost
    x-group: Cost
  - name: gpus
    x-group: GPUs
  - name: graphai
    x-group: Graph AI
  - name: infracost
    x-group: Infracost
  - name: integrations
    x-group: Integrations
  - name: invitations
    x-group: Invitations
  - name: kubernetes-clusters
    x-group: Kubernetes clusters
  - name: marketplace
    x-group: Marketplace
  - name: network-requests
    x-group: Network requests
  - name: notifications
    x-group: Notifications
  - name: oauth
    x-group: OAuth
  - name: oauth-clients
    x-group: OAuth clients
  - name: opencost
    x-group: OpenCost
  - name: organization
    x-group: Audit log
  - name: organizations
    x-group: Organizations
  - name: placement-alternatives
    x-group: Placement alternatives
  - name: reports
    x-group: Reports
  - name: service-map
    x-group: Service map
  - name: settings
    x-group: Settings
  - name: sso
    x-group: Single sign-on
  - name: tenants
    x-group: Tenants
  - name: user
    x-group: Users
  - name: virtual-machines
    x-group: Virtual machines
  - name: virtual-tags
    x-group: Virtual tags
  - name: workflows
    x-group: Workflows
paths:
  /api/v1/tenant/opencost/allocation:
    get:
      tags:
        - opencost
      summary: Query costs and resources allocated to Kubernetes workloads
      description: >-
        OpenCost-compatible allocation query. Returns one allocation set per
        step in the window, each keyed by the aggregated resource name. CPU and
        RAM are billed on the greater of request and usage, per the OpenCost
        specification. Unallocated node cost is returned as __idle__ unless
        shareIdle distributes it. Storage and network cost are not included.
      parameters:
        - description: >-
            Duration (7d, 24h), 'today', 'yesterday', or a comma-separated
            RFC3339 pair
          name: window
          in: query
          required: true
          schema:
            type: string
        - description: >-
            Comma-separated list of cluster, node, namespace, controller,
            controllerKind, deployment, statefulset, daemonset, job, cronjob,
            pod, container, label:<key>
          name: aggregate
          in: query
          schema:
            type: string
        - description: Duration of each returned set; defaults to the whole window
          name: step
          in: query
          schema:
            type: string
        - description: Collapse the range into a single set
          name: accumulate
          in: query
          schema:
            type: boolean
        - description: Emit unallocated node cost as its own __idle__ allocation
          name: includeIdle
          in: query
          schema:
            type: boolean
        - description: >-
            Distribute idle across the other allocations instead, weighted by
            consumption
          name: shareIdle
          in: query
          schema:
            type: boolean
        - description: Not supported; idle is reported for the cluster
          name: idleByNode
          in: query
          schema:
            type: boolean
        - description: Restrict the result, for example cluster:\
          name: filter
          in: query
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/controllers.allocationEnvelope'
        '400':
          description: Bad Request
          content:
            application/json:
              schema: {}
        '401':
          description: Unauthorized
          content:
            application/json:
              schema: {}
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema: {}
      security:
        - BearerAuth: []
components:
  schemas:
    controllers.allocationEnvelope:
      type: object
      properties:
        code:
          type: integer
        data:
          $ref: '#/components/schemas/opencost.AllocationSetRange'
    opencost.AllocationSetRange:
      type: object
      properties:
        allocations:
          type: array
          items:
            $ref: '#/components/schemas/opencost.AllocationSet'
        fromStore:
          description: stores the name of the store used to retrieve the data
          type: string
    opencost.AllocationSet:
      type: object
      properties:
        allocations:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/opencost.Allocation'
        errors:
          type: array
          items:
            type: string
        externalKeys:
          type: object
          additionalProperties:
            type: boolean
        fromSource:
          description: stores the name of the source used to compute the data
          type: string
        idleKeys:
          type: object
          additionalProperties:
            type: boolean
        warnings:
          type: array
          items:
            type: string
        window:
          $ref: '#/components/schemas/opencost.Window'
    opencost.Allocation:
      type: object
      properties:
        GPUAllocation:
          description: '@bingen:field[version=23]'
          allOf:
            - $ref: '#/components/schemas/opencost.GPUAllocation'
        LoadBalancers:
          description: '@bingen:field[version=18]'
          allOf:
            - $ref: '#/components/schemas/opencost.LbAllocations'
        cpuCoreHours:
          type: number
        cpuCoreLimitAverage:
          description: '@bingen:field[version=24]'
          type: number
        cpuCoreRequestAverage:
          type: number
        cpuCoreUsageAverage:
          type: number
        cpuCost:
          type: number
        cpuCostAdjustment:
          type: number
        cpuCostIdle:
          description: '@bingen:field[ignore]'
          type: number
        end:
          type: string
        externalCost:
          type: number
        gpuCost:
          type: number
        gpuCostAdjustment:
          type: number
        gpuCostIdle:
          description: '@bingen:field[ignore]'
          type: number
        gpuHours:
          type: number
        loadBalancerCost:
          type: number
        loadBalancerCostAdjustment:
          type: number
        name:
          type: string
        networkCost:
          type: number
        networkCostAdjustment:
          type: number
        networkCrossRegionCost:
          description: '@bingen:field[version=16]'
          type: number
        networkCrossZoneCost:
          description: '@bingen:field[version=16]'
          type: number
        networkInternetCost:
          description: '@bingen:field[version=16]'
          type: number
        networkNatGatewayEgressCost:
          description: NAT Gateway Costs
          type: number
        networkNatGatewayIngressCost:
          description: '@bingen:field[version=25]'
          type: number
        networkReceiveBytes:
          type: number
        networkTransferBytes:
          type: number
        properties:
          $ref: '#/components/schemas/opencost.AllocationProperties'
        proportionalAssetResourceCosts:
          description: >-
            ProportionalAssetResourceCost represents the per-resource costs of
            the

            allocation as a percentage of the per-resource total cost of the

            asset on which the allocation was run. It is optionally computed

            and appended to an Allocation, and so by default is is nil.
          allOf:
            - $ref: '#/components/schemas/opencost.ProportionalAssetResourceCosts'
        pvCostAdjustment:
          type: number
        pvs:
          $ref: '#/components/schemas/opencost.PVAllocations'
        ramByteHours:
          type: number
        ramByteLimitAverage:
          description: '@bingen:field[version=24]'
          type: number
        ramByteRequestAverage:
          type: number
        ramByteUsageAverage:
          type: number
        ramCost:
          type: number
        ramCostAdjustment:
          type: number
        ramCostIdle:
          description: '@bingen:field[ignore]'
          type: number
        rawAllocationOnly:
          description: |-
            RawAllocationOnly is a pointer so if it is not present it will be
            marshalled as null rather than as an object with Go default values.
          allOf:
            - $ref: '#/components/schemas/opencost.RawAllocationOnlyData'
        sharedCost:
          type: number
        sharedCostBreakdown:
          description: '@bingen:field[ignore]'
          allOf:
            - $ref: '#/components/schemas/opencost.SharedCostBreakdowns'
        start:
          type: string
        window:
          $ref: '#/components/schemas/opencost.Window'
    opencost.Window:
      type: object
    opencost.GPUAllocation:
      type: object
      properties:
        gpuDevice:
          type: string
        gpuModel:
          type: string
        gpuRequestAverage:
          type: number
        gpuUUID:
          type: string
        gpuUsageAverage:
          type: number
        isGPUShared:
          type: boolean
    opencost.LbAllocations:
      type: object
      additionalProperties:
        $ref: '#/components/schemas/opencost.LbAllocation'
    opencost.AllocationProperties:
      type: object
      properties:
        annotations:
          $ref: '#/components/schemas/opencost.AllocationAnnotations'
        cluster:
          type: string
        container:
          type: string
        controller:
          type: string
        controllerKind:
          type: string
        labels:
          $ref: '#/components/schemas/opencost.AllocationLabels'
        namespace:
          type: string
        namespaceAnnotations:
          description: '@bingen:field[version=17]'
          allOf:
            - $ref: '#/components/schemas/opencost.AllocationAnnotations'
        namespaceLabels:
          description: '@bingen:field[version=17]'
          allOf:
            - $ref: '#/components/schemas/opencost.AllocationLabels'
        node:
          type: string
        pod:
          type: string
        providerID:
          type: string
        services:
          type: array
          items:
            type: string
    opencost.ProportionalAssetResourceCosts:
      type: object
      additionalProperties:
        $ref: '#/components/schemas/opencost.ProportionalAssetResourceCost'
    opencost.PVAllocations:
      type: object
      additionalProperties:
        $ref: '#/components/schemas/opencost.PVAllocation'
    opencost.RawAllocationOnlyData:
      type: object
      properties:
        cpuCoreUsageMax:
          type: number
        gpuUsageMax:
          description: '@bingen:field[version=23]'
          type: number
        ramByteUsageMax:
          type: number
    opencost.SharedCostBreakdowns:
      type: object
      additionalProperties:
        $ref: '#/components/schemas/opencost.SharedCostBreakdown'
    opencost.LbAllocation:
      type: object
      properties:
        adjustment:
          description: '@bingen:field[ignore]'
          type: number
        cost:
          type: number
        hours:
          description: '@bingen:field[version=21]'
          type: number
        ip:
          description: '@bingen:field[version=19]'
          type: string
        private:
          type: boolean
        service:
          type: string
    opencost.AllocationAnnotations:
      type: object
      additionalProperties:
        type: string
    opencost.AllocationLabels:
      type: object
      additionalProperties:
        type: string
    opencost.ProportionalAssetResourceCost:
      type: object
      properties:
        cluster:
          type: string
        cpuPercentage:
          type: number
        gpuPercentage:
          type: number
        loadBalancerPercentage:
          type: number
        name:
          type: string
        nodeResourceCostPercentage:
          type: number
        providerID:
          type: string
        pvPercentage:
          type: number
        ramPercentage:
          type: number
        type:
          type: string
    opencost.PVAllocation:
      type: object
      properties:
        adjustment:
          description: '@bingen:field[ignore]'
          type: number
        byteHours:
          type: number
        cost:
          type: number
        providerID:
          description: '@bingen:field[version=20]'
          type: string
    opencost.SharedCostBreakdown:
      type: object
      properties:
        cpuCost:
          type: number
        externalCost:
          type: number
        gpuCost:
          type: number
        loadBalancerCost:
          type: number
        name:
          type: string
        networkCost:
          type: number
        pvCost:
          type: number
        ramCost:
          type: number
        totalCost:
          type: number
  securitySchemes:
    BearerAuth:
      description: Enter "Bearer {token}"
      type: apiKey
      name: Authorization
      in: header

````

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