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

# Backfill a model price's unpriced history

> Price the chat records this price prices that were recorded at no cost (traffic from before the model had a price), at the current price, optionally only within a date range (inclusive dates, UTC). Records that have a cost are left alone; to reprice those, use PATCH /model-prices/{id}/recalculate.



## OpenAPI

````yaml /swagger/5.16/ai-studio-swagger.yml post /model-prices/{id}/backfill
openapi: 3.0.1
info:
  title: Midsommar API
  description: This is the API for the Midsommar user and group management system.
  termsOfService: http://swagger.io/terms/
  contact:
    name: API Support
    url: http://www.swagger.io/support
    email: support@swagger.io
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  version: '1.0'
servers:
  - url: //localhost:8080/api/v1
security: []
paths:
  /model-prices/{id}/backfill:
    post:
      tags:
        - model-prices
      summary: Backfill a model price's unpriced history
      description: >-
        Price the chat records this price prices that were recorded at no cost
        (traffic from before the model had a price), at the current price,
        optionally only within a date range (inclusive dates, UTC). Records that
        have a cost are left alone; to reprice those, use PATCH
        /model-prices/{id}/recalculate.
      parameters:
        - name: id
          in: path
          description: Model Price ID
          required: true
          schema:
            type: integer
      requestBody:
        description: Optional date range
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/api.BackfillModelPriceInput'
        required: false
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api.BackfillModelPriceResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api.ErrorResponse'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api.ErrorResponse'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api.ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    api.BackfillModelPriceInput:
      type: object
      properties:
        from:
          type: string
        to:
          type: string
    api.BackfillModelPriceResponse:
      type: object
      properties:
        data:
          type: object
          properties:
            model_price:
              $ref: '#/components/schemas/api.ModelPriceResponse'
            rows_priced:
              type: integer
              description: RowsPriced is the number of chat records that were priced.
    api.ErrorResponse:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              detail:
                type: string
              title:
                type: string
      description: Error response model
    api.ModelPriceResponse:
      type: object
      properties:
        attributes:
          type: object
          properties:
            cache_read_pt:
              type: number
              description: >-
                Price per token read from the provider's prompt cache, per
                single token.
            cache_write_pt:
              type: number
              description: >-
                Price per token written to the provider's prompt cache, per
                single token.
            cpit:
              type: number
              description: >-
                Price per INPUT (prompt) token, in currency units per single
                token (not per million).
            cpt:
              type: number
              description: >-
                Price per OUTPUT (completion) token, in currency units per
                single token (not per million).
            currency:
              type: string
            model_name:
              type: string
            vendor:
              type: string
        id:
          type: string
        meta:
          type: object
          description: Meta is set on the list response only.
          allOf:
            - $ref: '#/components/schemas/api.ModelPriceMeta'
        type:
          type: string
      description: Model Price response model
    api.ModelPriceMeta:
      type: object
      properties:
        unpriced_rows:
          type: integer
          description: >-
            UnpricedRows is the number of chat records this price prices that
            were

            recorded at no cost (before the model had a price): what

            POST /model-prices/{id}/backfill would price.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````