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

# Agents' prompt cache

> Tokens, the provider's cache hit rate and the estimated savings, per agent, vendor or model.



## OpenAPI

````yaml openapi/en/cell.json GET /v1/usage/prompt-cache
openapi: 3.1.0
info:
  title: Niadra data API
  version: '1'
  description: >-
    Writing, context, history, objects, identity, privacy and governance of one
    space. Every space has a stable address, with the space and the region in
    its name.
servers:
  - url: https://{space}.{region}.api.niadra.com
    variables:
      space:
        default: acme-prod
        description: The space, which comes in the source key.
      region:
        default: us-east-2
        description: The region of the space, which also comes in the key.
security: []
paths:
  /v1/usage/prompt-cache:
    get:
      tags:
        - usage
      summary: Agents' prompt cache
      description: >-
        The agents' prompt cache: tokens, cache hits and the estimated saving,
        from the usage the SDK read

        from each model call.


        **Authentication.** Console person token with the `analysis`, `vendor`
        role (or admin), or a source key with the `admin` scope.
      operationId: prompt_cache_v1_usage_prompt_cache_get
      parameters:
        - in: query
          name: since
          required: false
          schema:
            anyOf:
              - format: date
                type: string
              - type: 'null'
            title: Since
        - in: query
          name: until
          required: false
          schema:
            anyOf:
              - format: date
                type: string
              - type: 'null'
            title: Until
        - in: query
          name: group_by
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            title: Group By
        - in: query
          name: source_id
          required: false
          schema:
            anyOf:
              - format: uuid
                type: string
              - type: 'null'
            title: Source Id
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PromptCacheReport'
          description: Successful Response
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
          description: The request does not match the contract.
      security:
        - sourceKey: []
        - personToken: []
components:
  schemas:
    PromptCacheReport:
      additionalProperties: false
      description: >-
        `GET /v1/usage/prompt-cache`: the agents' prompt cache, from what the
        providers reported.
      properties:
        buckets:
          items:
            $ref: '#/components/schemas/PromptCacheBucket'
          title: Buckets
          type: array
        estimate:
          default: true
          description: >-
            Always true: the savings are an estimate, never what a provider
            billed.
          title: Estimate
          type: boolean
        group_by:
          items:
            type: string
          title: Group By
          type: array
        prices:
          description: The price of every model the estimate used.
          items:
            $ref: '#/components/schemas/ModelPriceOut'
          title: Prices
          type: array
        prices_as_of:
          description: When the product's table was taken from the public price lists.
          title: Prices As Of
          type: string
        since:
          format: date
          title: Since
          type: string
        until:
          format: date
          title: Until
          type: string
      required:
        - since
        - until
        - group_by
        - buckets
        - prices
        - prices_as_of
      title: PromptCacheReport
      type: object
    Problem:
      additionalProperties: false
      description: RFC 9457 problem details; `code` comes from the versioned error catalog.
      properties:
        code:
          title: Code
          type: string
        detail:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Detail
        request_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Request Id
        status:
          title: Status
          type: integer
        title:
          title: Title
          type: string
        type:
          default: about:blank
          title: Type
          type: string
      required:
        - title
        - status
        - code
      title: Problem
      type: object
    PromptCacheBucket:
      additionalProperties: false
      properties:
        cache_write_tokens:
          description: Input tokens written to the cache.
          title: Cache Write Tokens
          type: integer
        cached_tokens:
          description: Input tokens the provider read from its prompt cache.
          title: Cached Tokens
          type: integer
        calls:
          description: Agent turns whose model call reported its usage.
          title: Calls
          type: integer
        day:
          anyOf:
            - format: date
              type: string
            - type: 'null'
          title: Day
        estimated_savings_micros:
          anyOf:
            - type: integer
            - type: 'null'
          description: >-
            An estimate, in millionths of a US dollar: cached tokens at the
            input price minus the cached price, less the write premium, by the
            price of each call's model. Null when no call of the bucket has a
            price.
          title: Estimated Savings Micros
        hit_rate:
          anyOf:
            - type: number
            - type: 'null'
          description: '`cached_tokens` over `prompt_tokens`; null without tokens.'
          title: Hit Rate
        model:
          anyOf:
            - type: string
            - type: 'null'
          title: Model
        prompt_tokens:
          description: Every input token of those calls, cached ones included.
          title: Prompt Tokens
          type: integer
        provider:
          anyOf:
            - type: string
            - type: 'null'
          title: Provider
        source_id:
          anyOf:
            - format: uuid
              type: string
            - type: 'null'
          title: Source Id
        unpriced_calls:
          default: 0
          description: >-
            Calls of models without a price in either table: left out of the
            estimate.
          title: Unpriced Calls
          type: integer
        vendor:
          anyOf:
            - type: string
            - type: 'null'
          description: From the source configuration; "" when none.
          title: Vendor
      required:
        - calls
        - prompt_tokens
        - cached_tokens
        - cache_write_tokens
      title: PromptCacheBucket
      type: object
    ModelPriceOut:
      additionalProperties: false
      properties:
        cache_write:
          title: Cache Write
          type: number
        cached_input:
          title: Cached Input
          type: number
        input:
          description: USD per million input tokens.
          title: Input
          type: number
        model:
          title: Model
          type: string
        provider:
          title: Provider
          type: string
        table:
          description: >-
            `product`: the product's table of public prices; `space`: the
            space's settings.
          enum:
            - product
            - space
          title: Table
          type: string
      required:
        - provider
        - model
        - input
        - cached_input
        - cache_write
        - table
      title: ModelPriceOut
      type: object
  securitySchemes:
    sourceKey:
      type: http
      scheme: bearer
      description: nia_sk_...
    personToken:
      type: http
      scheme: bearer
      bearerFormat: JWT

````