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

# Upload a custom PyBaMM model JSON file

> Upload a custom PyBaMM model from a serialized JSON file.

The model JSON is stored compressed (zstd) directly in the custom_model_data
column. Custom models are identified by having non-null custom_model_data.

Non-JSON-compliant values (Infinity, -Infinity, NaN) are sanitized to strings
before storing to ensure the JSON can be parsed by JavaScript.

Parameters
----------
name : str
    Name for the custom model
description : str, optional
    Optional description for the model
file : UploadFile
    The PyBaMM serialized model JSON file

Returns
-------
Model
    The created model record



## OpenAPI

````yaml https://api.ionworks.com/openapi.json post /models/upload-custom
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://api.ionworks.com
    description: Production
security: []
paths:
  /models/upload-custom:
    post:
      summary: Upload a custom PyBaMM model JSON file
      description: >-
        Upload a custom PyBaMM model from a serialized JSON file.


        The model JSON is stored compressed (zstd) directly in the
        custom_model_data

        column. Custom models are identified by having non-null
        custom_model_data.


        Non-JSON-compliant values (Infinity, -Infinity, NaN) are sanitized to
        strings

        before storing to ensure the JSON can be parsed by JavaScript.


        Parameters

        ----------

        name : str
            Name for the custom model
        description : str, optional
            Optional description for the model
        file : UploadFile
            The PyBaMM serialized model JSON file

        Returns

        -------

        Model
            The created model record
      operationId: upload_custom_model_models_upload_custom_post
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: >-
                #/components/schemas/Body_upload_custom_model_models_upload_custom_post
        required: true
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Model'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    Body_upload_custom_model_models_upload_custom_post:
      properties:
        name:
          type: string
          title: Name
          description: Name for the custom model
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: Optional description
        chemistry:
          type: string
          title: Chemistry
          description: >-
            Model chemistry kind (lithium_ion, lithium_sulfur, ecm, generic).
            Defaults to lithium_ion.
          default: lithium_ion
        file:
          type: string
          contentMediaType: application/octet-stream
          title: File
          description: PyBaMM serialized model JSON file
      type: object
      required:
        - name
        - file
      title: Body_upload_custom_model_models_upload_custom_post
    Model:
      properties:
        name:
          type: string
          title: Name
          description: The name of the model.
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: An optional description for the model.
        pybamm_version:
          anyOf:
            - type: string
            - type: 'null'
          title: Pybamm Version
          description: >-
            PyBaMM version used for this model. If not provided, will be read
            from pybamm.__version__.
        chemistry:
          type: string
          enum:
            - lithium_ion
            - lithium_sulfur
            - ecm
            - generic
          title: Chemistry
          description: >-
            Model chemistry kind: 'lithium_ion' (default — assumes pybamm
            lithium-ion conventions), 'lithium_sulfur', 'ecm', or 'generic' (no
            chemistry-specific enrichment).
          default: lithium_ion
        id:
          type: string
          title: Id
          description: The unique identifier for the model.
        user_id:
          type: string
          title: User Id
          description: The ID of the user who created the model.
        organization_id:
          type: string
          title: Organization Id
          description: The ID of the organization this model belongs to.
        created_by_email:
          anyOf:
            - type: string
            - type: 'null'
          title: Created By Email
          description: Email of the user who created the model.
        created_at:
          type: string
          format: date-time
          title: Created At
          description: Timestamp of when the model was created.
        updated_at:
          type: string
          format: date-time
          title: Updated At
          description: Timestamp of when the model was last updated.
        is_custom_model:
          type: boolean
          title: Is Custom Model
          description: Check if this is a custom model (has compressed model data).
          readOnly: true
      type: object
      required:
        - name
        - id
        - user_id
        - organization_id
        - created_at
        - updated_at
        - is_custom_model
      title: Model
      description: Model representing a model as returned by the API (without config).
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````