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

# Prepare a model upload

> Validates a model push payload and issues upload credentials.



## OpenAPI

````yaml post /v1/prepare_model_upload
openapi: 3.1.0
info:
  description: REST API for management of Baseten resources
  title: Baseten management API
  version: 1.0.0
servers:
  - url: https://api.baseten.co
security:
  - BearerAuth: []
paths:
  /v1/prepare_model_upload:
    post:
      summary: Validates a model push payload and issues upload credentials
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PrepareModelUploadRequestV1'
        required: true
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PrepareModelUploadResponseV1'
      x-codeSamples:
        - lang: bash
          source: |-
            curl --request POST \
            --url https://api.baseten.co/v1/prepare_model_upload \
            --header "Authorization: Bearer $BASETEN_API_KEY" \
            --data '{
              "deployment": {
                "config": null,
                "raw_config": null,
                "user_env": null,
                "environment_name": null,
                "region": null,
                "deploy_timeout_minutes": null,
                "deployment_name": null,
                "labels": null,
                "autoscaling_settings": {
                  "max_replica": 4,
                  "min_replica": 2
                },
                "request_backpressure_settings": {
                  "policy": "REJECT_ON_FULL"
                },
                "autoscaling_schedule_settings": null,
                "promotion_settings_override": {
                  "rolling_deploy_config": {
                    "max_surge_percent": 50
                  }
                },
                "instance_type_id": null
              },
              "name": null,
              "team_id": null,
              "model_id": null
            }'
        - lang: python
          source: |-
            import requests
            import os
            API_KEY = os.environ.get("BASETEN_API_KEY", "<YOUR_API_KEY>")
            url = "https://api.baseten.co/v1/prepare_model_upload"

            headers = {"Authorization": f"Bearer {API_KEY}"}

            response = requests.request(
                "POST",
                url,
                headers=headers,
                json={'deployment': {'config': None, 'raw_config': None, 'user_env': None, 'environment_name': None, 'region': None, 'deploy_timeout_minutes': None, 'deployment_name': None, 'labels': None, 'autoscaling_settings': {'max_replica': 4, 'min_replica': 2}, 'request_backpressure_settings': {'policy': 'REJECT_ON_FULL'}, 'autoscaling_schedule_settings': None, 'promotion_settings_override': {'rolling_deploy_config': {'max_surge_percent': 50}}, 'instance_type_id': None}, 'name': None, 'team_id': None, 'model_id': None}
            )

            print(response.text)
components:
  schemas:
    PrepareModelUploadRequestV1:
      description: |-
        Body for `POST /v1/prepare_model_upload`.

        Validates the same payload the commit endpoint will validate, and on
        `dry_run=false` issues STS upload credentials. Exactly one of `name` or
        `model_id` is required: `name` validates the new-model path (`POST
        /v1/models`); `model_id` validates the add-deployment path (`POST
        /v1/models/{model_id}/deployments`).
      properties:
        deployment:
          $ref: '#/components/schemas/DeploymentArchivePayloadV1'
          description: Deployment-level payload, identical to the payload sent at commit.
        name:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            Set to validate a new-model push. Exactly one of `name` or
            `model_id` is required.
          title: Name
        team_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            Team the new model will belong to. Only valid when `name` is set;
            defaults to the organization's default team when omitted. Must not
            be set when `model_id` is set (the existing model already has a
            team).
          title: Team Id
        model_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            Set to validate an add-deployment push to an existing model. Exactly
            one of `name` or `model_id` is required.
          title: Model Id
        dry_run:
          default: false
          description: >-
            If true, validate the payload only and do not issue upload
            credentials. The response sets `creds`, `s3_bucket`, and `s3_key` to
            `null`.
          title: Dry Run
          type: boolean
      required:
        - deployment
      title: PrepareModelUploadRequestV1
      type: object
    PrepareModelUploadResponseV1:
      description: >-
        Response from `POST /v1/prepare_model_upload`.


        Returns STS upload credentials when the push requires an archive upload.
        All

        four fields (`creds`, `s3_bucket`, `s3_key`, `s3_region`) are `null`
        when no

        upload is needed: either `dry_run=true` (validation only) or a model
        format

        that is not built from an uploaded archive (for example, BIS-LLM, which
        is

        built from its config alone).
      properties:
        creds:
          anyOf:
            - $ref: '#/components/schemas/AWSCredentialsV1'
            - type: 'null'
          default: null
          description: >-
            STS credentials to upload the model archive. Null when no archive
            upload is required.
        s3_bucket:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            S3 bucket the credentials are scoped to. Null when no archive upload
            is required.
          title: S3 Bucket
        s3_key:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            S3 key the credentials are scoped to. Pass this to `POST /v1/models`
            (in the `model_archive` source) once the upload completes. Null when
            no archive upload is required.
          title: S3 Key
        s3_region:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            AWS region the S3 bucket resides in. Null when no archive upload is
            required.
          title: S3 Region
      title: PrepareModelUploadResponseV1
      type: object
    DeploymentArchivePayloadV1:
      description: >-
        Deployment-level fields for a model-archive push.


        Shared by every endpoint that creates a deployment from an uploaded
        archive:

        `POST /v1/prepare_model_upload`, the `model_archive` source on `POST

        /v1/models`, and `POST /v1/models/{model_id}/deployments`.
      properties:
        config:
          additionalProperties: true
          description: Parsed model config as a JSON object.
          title: Config
          type: object
        raw_config:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            Original config.yaml text, persisted as-is on the deployment.
            Best-effort: invalid raw configs are logged and dropped without
            failing the request.
          title: Raw Config
        user_env:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          default: null
          description: >-
            Client environment metadata (e.g. client version, Python version).
            Validated server-side.
          title: User Env
        environment_name:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            Stable environment to push to (e.g. `production`). If unset, the
            deployment is created without environment selection. Caller must
            have push permission for the named environment.
          title: Environment Name
        create_environment_if_missing:
          default: true
          description: >-
            Create the environment named by `environment_name` if it does not
            exist yet. If false, a push to an environment that does not exist is
            rejected. Only meaningful when `environment_name` is set to
            something other than `production`, which always exists. This field
            currently defaults to true, but that default will change to false in
            a future release. Set it explicitly to avoid a behavior change.
          title: Create Environment If Missing
          type: boolean
        region:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: Region in which to deploy the model
          title: Region
        preserve_env_instance_type:
          default: true
          description: >-
            Retain the target environment's current instance type rather than
            the one in `config`. Only meaningful when `environment_name` is set
            and that environment already exists.
          title: Preserve Env Instance Type
          type: boolean
        deploy_timeout_minutes:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          description: >-
            Deploy timeout in minutes; allowed range 10 to 1440. Server default
            applies if unset.
          title: Deploy Timeout Minutes
        deployment_name:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: Optional human-readable name for the deployment.
          title: Deployment Name
        labels:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          default: null
          description: User-provided key-value labels for the deployment.
          title: Labels
        is_development:
          default: false
          description: >-
            If true, push as a development deployment: the model's single
            mutable dev slot, created if absent and overwritten in place
            otherwise. The following fields must be left at their defaults:
            `environment_name`, `preserve_env_instance_type`, `deployment_name`.
          title: Is Development
          type: boolean
        autoscaling_settings:
          anyOf:
            - $ref: '#/components/schemas/UpdateAutoscalingSettingsV1'
            - type: 'null'
          default: null
          description: >-
            Autoscaling settings for the new deployment. The new deployment
            starts from the settings of the environment named by
            `environment_name` with these changes applied, and the environment
            keeps the result when the promotion completes. Requires
            `environment_name`.
          examples:
            - max_replica: 4
              min_replica: 2
        request_backpressure_settings:
          anyOf:
            - $ref: '#/components/schemas/UpdateRequestBackpressureSettingsV1'
            - type: 'null'
          default: null
          description: >-
            Request backpressure settings for the new deployment, applied the
            same way as `autoscaling_settings`.
          examples:
            - policy: REJECT_ON_FULL
        autoscaling_schedule_settings:
          anyOf:
            - $ref: '#/components/schemas/UpdateAutoscalingScheduleSettingsV1'
            - type: 'null'
          default: null
          description: >-
            Autoscaling schedule changes for the environment named by
            `environment_name`, applied when the promotion completes. Requires
            `environment_name`.
        promotion_settings_override:
          anyOf:
            - $ref: '#/components/schemas/UpdatePromotionSettingsV1'
            - type: 'null'
          default: null
          description: >-
            Promotion settings for promoting the new deployment into the
            environment named by `environment_name`, for this promotion only.
            Omitted fields keep the environment's values, and the environment's
            promotion settings are unchanged. Requires `environment_name`.
          examples:
            - rolling_deploy_config:
                max_surge_percent: 50
        instance_type_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            Instance type for the new deployment, from `GET /v1/instance_types`,
            in place of the one in `config`. The environment named by
            `environment_name` takes it when the promotion completes. Requires
            `environment_name`. Cannot be set with `preserve_env_instance_type:
            true`.
          title: Instance Type Id
      required:
        - config
      title: DeploymentArchivePayloadV1
      type: object
    AWSCredentialsV1:
      description: AWS credentials
      properties:
        aws_access_key_id:
          description: The AWS access key ID
          title: Aws Access Key Id
          type: string
        aws_secret_access_key:
          description: The AWS secret access key
          title: Aws Secret Access Key
          type: string
        aws_session_token:
          description: The AWS session token
          title: Aws Session Token
          type: string
      required:
        - aws_access_key_id
        - aws_secret_access_key
        - aws_session_token
      title: AWSCredentialsV1
      type: object
    UpdateAutoscalingSettingsV1:
      additionalProperties: false
      description: >-
        A request to update autoscaling settings for a deployment. All fields
        are optional, and we only update ones passed in.
      properties:
        min_replica:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          description: Minimum number of replicas
          examples:
            - 0
          title: Min Replica
        max_replica:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          description: Maximum number of replicas
          examples:
            - 7
          title: Max Replica
        autoscaling_window:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          description: Timeframe of traffic considered for autoscaling decisions
          examples:
            - 600
          title: Autoscaling Window
        scale_down_delay:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          description: Waiting period before scaling down any active replica
          examples:
            - 120
          title: Scale Down Delay
        concurrency_target:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          description: Number of requests per replica before scaling up
          examples:
            - 2
          title: Concurrency Target
        target_utilization_percentage:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          description: Target utilization percentage for scaling up/down.
          examples:
            - 70
          title: Target Utilization Percentage
        target_in_flight_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          description: >-
            Target number of in-flight tokens for autoscaling decisions. Early
            access only.
          examples:
            - 40000
          title: Target In Flight Tokens
        max_scale_down_rate:
          anyOf:
            - maximum: 50
              minimum: 1
              type: integer
            - type: 'null'
          default: null
          description: >-
            Maximum percentage of replicas that can be removed per autoscaling
            window (1–50). E.g. 20 means at most 20% of replicas are removed per
            window.
          examples:
            - 20
          title: Max Scale Down Rate
      title: UpdateAutoscalingSettingsV1
      type: object
    UpdateRequestBackpressureSettingsV1:
      additionalProperties: false
      description: A request to update request backpressure settings.
      properties:
        policy:
          anyOf:
            - $ref: '#/components/schemas/RequestBackpressurePolicyV1'
            - type: 'null'
          default: null
          description: >-
            Backpressure policy to apply. Null indicates no policy (on update,
            clears an existing one).
          examples:
            - REJECT_ON_FULL
          x-null-distinct: true
      title: UpdateRequestBackpressureSettingsV1
      type: object
    UpdateAutoscalingScheduleSettingsV1:
      additionalProperties: false
      description: Partial mutation of an environment's autoscaling schedule collection.
      properties:
        timezone:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            IANA timezone shared by the resulting collection. Omission preserves
            the current timezone; null is allowed only when deleting every
            schedule.
          title: Timezone
          x-null-distinct: true
        schedules:
          description: >-
            Complete schedules to create or replace. Existing schedules omitted
            from this list are unchanged.
          items:
            discriminator:
              mapping:
                DAILY: '#/components/schemas/AutoscalingScheduleUpsertV1'
                HOURLY: '#/components/schemas/AutoscalingScheduleUpsertV1'
                ONE_TIME: '#/components/schemas/OneTimeAutoscalingScheduleUpsertV1'
              propertyName: cadence
            oneOf:
              - $ref: '#/components/schemas/AutoscalingScheduleUpsertV1'
              - $ref: '#/components/schemas/OneTimeAutoscalingScheduleUpsertV1'
          title: Schedules
          type: array
        delete_schedules:
          description: >-
            Stable identifiers of schedules to delete. To clear all schedules,
            include every existing schedule identifier.
          items:
            type: string
          title: Delete Schedules
          type: array
      title: UpdateAutoscalingScheduleSettingsV1
      type: object
    UpdatePromotionSettingsV1:
      description: Promotion settings for model promotion
      properties:
        redeploy_on_promotion:
          anyOf:
            - type: boolean
            - type: 'null'
          default: null
          description: >-
            Whether to deploy on all promotions. Enabling this flag allows model
            code to safely handle environment-specific logic. When a deployment
            is promoted, a new deployment will be created with a copy of the
            image.
          examples:
            - true
          title: Redeploy On Promotion
        rolling_deploy:
          anyOf:
            - type: boolean
            - type: 'null'
          default: null
          description: Whether the environment should rely on rolling deploy orchestration.
          examples:
            - true
          title: Rolling Deploy
        promotion_cleanup_strategy:
          anyOf:
            - $ref: '#/components/schemas/PromotionCleanupStrategyV1'
            - type: 'null'
          default: null
          description: The cleanup strategy to use after a promotion completes.
          examples:
            - SCALE_TO_ZERO
        rolling_deploy_config:
          anyOf:
            - $ref: '#/components/schemas/UpdateRollingDeployConfigV1'
            - type: 'null'
          default: null
          description: Rolling deploy configuration for promotions
        ramp_up_while_promoting:
          anyOf:
            - type: boolean
            - type: 'null'
          default: null
          description: Whether to ramp up traffic while promoting
          examples:
            - true
          title: Ramp Up While Promoting
        ramp_up_duration_seconds:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          description: Duration of the ramp up in seconds
          examples:
            - 600
          title: Ramp Up Duration Seconds
      title: UpdatePromotionSettingsV1
      type: object
    RequestBackpressurePolicyV1:
      enum:
        - QUEUE_ON_FULL
        - REJECT_ON_FULL
      title: RequestBackpressurePolicyV1
      type: string
    AutoscalingScheduleUpsertV1:
      additionalProperties: false
      description: A complete recurring schedule submitted for create or replacement.
      properties:
        id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: Stable schedule identifier. Omit this field to create a schedule.
          title: Id
        name:
          description: Name of the schedule
          title: Name
          type: string
        enabled:
          description: Whether the schedule is enabled
          title: Enabled
          type: boolean
        autoscaling_settings:
          $ref: '#/components/schemas/AutoscalingScheduleSettingsRequestV1'
          description: >-
            Complete raw autoscaling overrides for the schedule. Every field is
            required; nullable fields store no schedule override and follow the
            current environment value.
        cadence:
          description: Recurring schedule cadence
          enum:
            - DAILY
            - HOURLY
          title: Cadence
          type: string
        weekdays:
          description: Weekdays on which the schedule runs
          items:
            $ref: '#/components/schemas/AutoscalingScheduleWeekdayV1'
          title: Weekdays
          type: array
        start_hour:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          description: >-
            Start hour in the environment schedule timezone. Omit for
            unrestricted HOURLY schedules.
          title: Start Hour
        start_minute:
          description: Start minute of the schedule window
          title: Start Minute
          type: integer
        end_hour:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          description: >-
            End hour in the environment schedule timezone. Omit for unrestricted
            HOURLY schedules.
          title: End Hour
        end_minute:
          description: End minute of the schedule window
          title: End Minute
          type: integer
      required:
        - name
        - enabled
        - autoscaling_settings
        - cadence
        - weekdays
        - start_minute
        - end_minute
      title: AutoscalingScheduleUpsertV1
      type: object
    OneTimeAutoscalingScheduleUpsertV1:
      additionalProperties: false
      description: A complete one-time schedule submitted for create or replacement.
      properties:
        id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: Stable schedule identifier. Omit this field to create a schedule.
          title: Id
        name:
          description: Name of the schedule
          title: Name
          type: string
        enabled:
          description: Whether the schedule is enabled
          title: Enabled
          type: boolean
        autoscaling_settings:
          $ref: '#/components/schemas/AutoscalingScheduleSettingsRequestV1'
          description: >-
            Complete raw autoscaling overrides for the schedule. Every field is
            required; nullable fields store no schedule override and follow the
            current environment value.
        cadence:
          const: ONE_TIME
          description: One-time schedule cadence
          title: Cadence
          type: string
        start_at:
          description: >-
            Inclusive start of the schedule window in ISO 8601 format. New
            schedules must start in the future.
          format: date-time
          title: Start At
          type: string
        end_at:
          description: Exclusive end of the schedule window in ISO 8601 format
          format: date-time
          title: End At
          type: string
      required:
        - name
        - enabled
        - autoscaling_settings
        - cadence
        - start_at
        - end_at
      title: OneTimeAutoscalingScheduleUpsertV1
      type: object
    PromotionCleanupStrategyV1:
      description: The promotion cleanup strategy.
      enum:
        - KEEP
        - SCALE_TO_ZERO
        - DEACTIVATE
      title: PromotionCleanupStrategyV1
      type: string
    UpdateRollingDeployConfigV1:
      description: Rolling deploy config for promoting chains and oracles
      properties:
        rolling_deploy_strategy:
          anyOf:
            - $ref: '#/components/schemas/RollingDeployStrategyV1'
            - type: 'null'
          default: null
          description: The rolling deploy strategy to use for promotions.
          examples:
            - REPLICA
        max_surge_percent:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          description: The maximum surge percentage for rolling deploys.
          examples:
            - 25
          title: Max Surge Percent
        max_unavailable_percent:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          description: The maximum unavailable percentage for rolling deploys.
          examples:
            - 10
          title: Max Unavailable Percent
        stabilization_time_seconds:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          description: The stabilization time in seconds for rolling deploys.
          examples:
            - 300
          title: Stabilization Time Seconds
        replica_overhead_percent:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          description: The replica overhead percentage for rolling deploys.
          examples:
            - 0
          title: Replica Overhead Percent
      title: UpdateRollingDeployConfigV1
      type: object
    AutoscalingScheduleSettingsRequestV1:
      additionalProperties: false
      description: A complete set of raw autoscaling overrides for a schedule.
      properties:
        min_replica:
          description: Minimum number of replicas
          title: Min Replica
          type: integer
        max_replica:
          description: Maximum number of replicas
          title: Max Replica
          type: integer
        autoscaling_window:
          anyOf:
            - type: integer
            - type: 'null'
          description: >-
            Timeframe of traffic considered for autoscaling decisions. Null
            stores no schedule override and follows the current environment
            value.
          title: Autoscaling Window
        scale_down_delay:
          anyOf:
            - type: integer
            - type: 'null'
          description: >-
            Waiting period before scaling down any active replica. Null stores
            no schedule override and follows the current environment value.
          title: Scale Down Delay
        concurrency_target:
          anyOf:
            - type: integer
            - type: 'null'
          description: >-
            Number of requests per replica before scaling up. Null stores no
            schedule override and follows the current environment value.
          title: Concurrency Target
        target_utilization_percentage:
          anyOf:
            - type: integer
            - type: 'null'
          description: >-
            Target utilization percentage for scaling up/down. Null stores no
            schedule override and follows the current environment value.
          title: Target Utilization Percentage
        target_in_flight_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          description: >-
            Target number of in-flight tokens for autoscaling decisions. Null
            stores no schedule override and follows the current environment
            value. Early access only.
          title: Target In Flight Tokens
        max_scale_down_rate:
          anyOf:
            - maximum: 50
              minimum: 1
              type: integer
            - type: 'null'
          description: >-
            Maximum percentage of replicas that can be removed per autoscaling
            window. Null stores no schedule override and follows the current
            environment value.
          title: Max Scale Down Rate
      required:
        - min_replica
        - max_replica
        - autoscaling_window
        - scale_down_delay
        - concurrency_target
        - target_utilization_percentage
        - target_in_flight_tokens
        - max_scale_down_rate
      title: AutoscalingScheduleSettingsRequestV1
      type: object
    AutoscalingScheduleWeekdayV1:
      enum:
        - SUNDAY
        - MONDAY
        - TUESDAY
        - WEDNESDAY
        - THURSDAY
        - FRIDAY
        - SATURDAY
      title: AutoscalingScheduleWeekdayV1
      type: string
    RollingDeployStrategyV1:
      description: The rolling deploy strategy.
      enum:
        - REPLICA
      title: RollingDeployStrategyV1
      type: string
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Send `Authorization: Bearer <api_key>`. The legacy `Authorization:
        Api-Key <api_key>` scheme is also accepted.

````