> ## 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.

# Update a model price and recalculate historical costs

> Get a model price by its name, creating it with default values if it doesn't exist
Update an existing model price's information and recalculate all historical chat record costs



## OpenAPI

````yaml /swagger/5.12/ai-studio-swagger.yml get /model-prices/by-name
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/by-name:
    get:
      tags:
        - model-prices
        - model-prices
      summary: Update a model price and recalculate historical costs
      description: >-
        Get a model price by its name, creating it with default values if it
        doesn't exist

        Update an existing model price's information and recalculate all
        historical chat record costs
      parameters:
        - name: model_name
          in: query
          description: Model name
          required: true
          schema:
            type: string
      requestBody:
        description: Updated model price information
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/api.ModelPriceInput'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api.ModelPriceResponse'
        '400':
          description: Bad Request
          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: []
        - BearerAuth: []
components:
  schemas:
    api.ModelPriceInput:
      type: object
      properties:
        data:
          type: object
          properties:
            attributes:
              type: object
              properties:
                cache_read_pt:
                  type: number
                cache_write_pt:
                  type: number
                cpit:
                  type: number
                cpt:
                  type: number
                currency:
                  type: string
                model_name:
                  type: string
                vendor:
                  type: string
            type:
              type: string
      description: Model Price input model
    api.ModelPriceResponse:
      type: object
      properties:
        attributes:
          type: object
          properties:
            cache_read_pt:
              type: number
            cache_write_pt:
              type: number
            cpit:
              type: number
            cpt:
              type: number
            currency:
              type: string
            model_name:
              type: string
            vendor:
              type: string
        id:
          type: string
        type:
          type: string
      description: Model Price response model
    api.ErrorResponse:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              detail:
                type: string
              title:
                type: string
      description: Error response model
  securitySchemes:
    BearerAuth:
      type: apiKey
      name: Authorization
      in: header

````