Mithril spot API

The spot API from Mithril — 5 operation(s) for spot.

OpenAPI Specification

mithril-spot-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Mithril API Keys spot API
  description: Mithril Compute API
  version: 1.0.0
servers:
- url: https://api.mithril.ai
tags:
- name: spot
paths:
  /v2/spot/bids:
    get:
      tags:
      - spot
      summary: Get Bids
      description: Get all Spot bids for a project, or all user's projects if not specified
      operationId: get_bids_v2_spot_bids_get
      security:
      - MithrilAPIKey: []
      parameters:
      - name: next_cursor
        in: query
        required: false
        schema:
          nullable: true
      - name: sort_by
        in: query
        required: false
        schema:
          enum:
          - created_at
          - status
          type: string
          nullable: true
      - name: sort_dir
        in: query
        required: false
        schema:
          $ref: '#/components/schemas/SortDirection'
          nullable: true
      - name: project
        in: query
        required: false
        schema:
          type: string
          examples:
          - proj_abc123456
          nullable: true
      - name: instance_type
        in: query
        required: false
        schema:
          type: string
          examples:
          - it_abc123456
          nullable: true
      - name: region
        in: query
        required: false
        schema:
          type: string
          examples:
          - us-central1-a
          nullable: true
      - name: status
        in: query
        required: false
        schema:
          enum:
          - Open
          - Allocated
          - Preempting
          - Terminated
          - Paused
          type: string
          nullable: true
      - name: name
        in: query
        required: false
        schema:
          type: string
          nullable: true
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          maximum: 100
          minimum: 1
          nullable: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetBidsResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
    post:
      tags:
      - spot
      summary: Create Bid
      description: Place a new Spot bid
      operationId: create_bid_v2_spot_bids_post
      security:
      - MithrilAPIKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateBidRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BidModel'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /v2/spot/bids/{bid_fid}:
    get:
      tags:
      - spot
      summary: Get Bid
      description: Get a single Spot bid by FID
      operationId: get_bid_v2_spot_bids__bid_fid__get
      security:
      - MithrilAPIKey: []
      parameters:
      - name: bid_fid
        in: path
        required: true
        schema:
          type: string
          title: Bid Fid
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BidModel'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
    patch:
      tags:
      - spot
      summary: Update Bid
      description: Update the limit price of a Spot bid
      operationId: update_bid_v2_spot_bids__bid_fid__patch
      security:
      - MithrilAPIKey: []
      parameters:
      - name: bid_fid
        in: path
        required: true
        schema:
          type: string
          title: Bid Fid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateBidRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BidModel'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
    delete:
      tags:
      - spot
      summary: Cancel Bid
      description: Cancel a Spot bid
      operationId: cancel_bid_v2_spot_bids__bid_fid__delete
      security:
      - MithrilAPIKey: []
      parameters:
      - name: bid_fid
        in: path
        required: true
        schema:
          type: string
          title: Bid Fid
      responses:
        '204':
          description: Successful Response
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /v2/spot/bids/{bid_fid}/status:
    get:
      tags:
      - spot
      summary: Get Bid Status
      description: 'Get detailed status of a Spot bid.


        Returns a detailed status that includes instance-level status information.

        The status can be one of: Open, Allocated, Preempting, Terminated,

        Paused, Relocating.


        "Relocating" indicates that part of the order is being relocated.'
      operationId: get_bid_status_v2_spot_bids__bid_fid__status_get
      security:
      - MithrilAPIKey: []
      parameters:
      - name: bid_fid
        in: path
        required: true
        schema:
          type: string
          title: Bid Fid
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BidStatusResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /v2/spot/bids/{bid_fid}/history:
    get:
      tags:
      - spot
      summary: Get Bid History
      description: 'Get the history of events for a Spot bid.


        Returns a list of historical events including:

        - placing the bid

        - pausing the bid

        - resuming the bid

        - terminating the bid

        - changes to the limit price'
      operationId: get_bid_history_v2_spot_bids__bid_fid__history_get
      security:
      - MithrilAPIKey: []
      parameters:
      - name: bid_fid
        in: path
        required: true
        schema:
          type: string
          title: Bid Fid
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BidHistoryResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /v2/spot/availability:
    get:
      tags:
      - spot
      summary: Get Auctions
      description: Get the Spot availability across all regions.
      operationId: get_auctions_v2_spot_availability_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/AuctionModel'
                type: array
                title: Response Get Auctions V2 Spot Availability Get
      security:
      - MithrilAPIKey: []
components:
  schemas:
    BidStatusResponse:
      properties:
        bid_fid:
          type: string
          title: Bid Fid
          examples:
          - bid_xxxx
        status:
          type: string
          enum:
          - Open
          - Allocated
          - Preempting
          - Terminated
          - Paused
          - Relocating
          title: Status
          examples:
          - Open
          - Allocated
          - Preempting
          - Terminated
          - Paused
          - Relocating
      type: object
      required:
      - bid_fid
      - status
      title: BidStatusResponse
      description: Response model for the detailed bid status endpoint.
    ValidationError:
      properties:
        loc:
          items:
            oneOf:
            - type: string
            - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
      - loc
      - msg
      - type
      title: ValidationError
    CreateBidRequest:
      properties:
        project:
          type: string
          title: Project
          examples:
          - proj_abc123456
        region:
          type: string
          title: Region
          examples:
          - us-central1-a
        instance_type:
          type: string
          title: Instance Type
          examples:
          - it_abc123456
        limit_price:
          type: string
          title: Limit Price
          examples:
          - $25.60
        instance_quantity:
          type: integer
          title: Instance Quantity
          examples:
          - 4
        name:
          type: string
          title: Name
        launch_specification:
          $ref: '#/components/schemas/LaunchSpecificationModel'
        notification_email:
          type: string
          nullable: true
      type: object
      required:
      - project
      - region
      - instance_type
      - limit_price
      - instance_quantity
      - name
      - launch_specification
      title: CreateBidRequest
    BidModel:
      properties:
        fid:
          type: string
          title: Fid
          examples:
          - bid_abc123456
        name:
          type: string
          title: Name
        project:
          type: string
          title: Project
          examples:
          - proj_abc123456
        created_by:
          type: string
          title: Created By
          examples:
          - user_abc123456
        created_at:
          type: string
          format: datetime
          title: Created At
          examples:
          - '2024-01-01T00:00:00Z'
          - '2024-01-01T00:00:00+00:00'
          - '2024-01-01T00:00:00-00:00'
        deactivated_at:
          type: string
          format: datetime
          examples:
          - '2024-01-01T00:00:00Z'
          - '2024-01-01T00:00:00+00:00'
          - '2024-01-01T00:00:00-00:00'
          nullable: true
        limit_price:
          type: string
          title: Limit Price
          examples:
          - $15.60
        instance_quantity:
          type: integer
          title: Instance Quantity
          examples:
          - 4
        instance_type:
          type: string
          title: Instance Type
          examples:
          - it_abc123456
        region:
          type: string
          examples:
          - us-central1-a
          nullable: true
        instances:
          items:
            type: string
            examples:
            - inst_abc123456
          type: array
          title: Instances
        launch_specification:
          $ref: '#/components/schemas/LaunchSpecificationModel'
        status:
          type: string
          enum:
          - Open
          - Allocated
          - Preempting
          - Terminated
          - Paused
          title: Status
          examples:
          - Open
          - Allocated
          - Preempting
          - Terminated
          - Paused
      type: object
      required:
      - fid
      - name
      - project
      - created_by
      - created_at
      - limit_price
      - instance_quantity
      - instance_type
      - instances
      - launch_specification
      - status
      title: BidModel
    PersistentDiskChange:
      properties:
        attached:
          type: string
          nullable: true
        removed:
          type: string
          nullable: true
      type: object
      title: PersistentDiskChange
    UpdateBidRequest:
      properties:
        limit_price:
          type: string
          nullable: true
        paused:
          type: boolean
          nullable: true
        volumes:
          items:
            type: string
            examples:
            - vol_abc123456
          type: array
          nullable: true
        memory_gb:
          type: integer
          nullable: true
      type: object
      title: UpdateBidRequest
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    SortDirection:
      type: string
      enum:
      - asc
      - desc
    AuctionModel:
      properties:
        fid:
          type: string
          title: Fid
          examples:
          - auc_abc123456
        instance_type:
          type: string
          title: Instance Type
          examples:
          - it_abc123456
        region:
          type: string
          title: Region
          examples:
          - us-central1-a
        capacity:
          type: integer
          title: Capacity
          examples:
          - 512
        last_instance_price:
          type: string
          title: Last Instance Price
          examples:
          - $10.00
        lowest_allocated_price:
          type: string
          examples:
          - $15.00
          nullable: true
        adjustable_memory:
          type: boolean
          title: Adjustable Memory
        default_image_version:
          type: string
          examples:
          - imgver_abc123456
          nullable: true
      type: object
      required:
      - fid
      - instance_type
      - region
      - capacity
      - last_instance_price
      - adjustable_memory
      title: AuctionModel
    GetBidsResponse:
      properties:
        data:
          items:
            $ref: '#/components/schemas/BidModel'
          type: array
          title: Data
        next_cursor:
          type: string
          nullable: true
      type: object
      required:
      - data
      title: GetBidsResponse
    BidHistoryResponse:
      properties:
        bid_fid:
          type: string
          title: Bid Fid
          examples:
          - bid_abc123456
        events:
          items:
            $ref: '#/components/schemas/BidHistoryEventModel'
          type: array
          title: Events
          description: List of historical events for this bid, ordered by timestamp
      type: object
      required:
      - bid_fid
      - events
      title: BidHistoryResponse
      description: Response model for bid history.
    BidHistoryEventModel:
      properties:
        timestamp:
          type: string
          format: datetime
          title: Timestamp
          description: When the event occurred
          examples:
          - '2024-01-01T00:00:00Z'
          - '2024-01-01T00:00:00+00:00'
          - '2024-01-01T00:00:00-00:00'
        event_type:
          type: string
          enum:
          - Placed
          - Paused
          - Resumed
          - Terminated
          - Allocated
          - Preempted
          - Limit Price Changed
          - Memory Adjusted
          - Volumes Attached
          - Volumes Removed
          title: Event Type
          examples:
          - Placed
          - Paused
          - Resumed
          - Terminated
          - Allocated
          - Preempted
          - Limit Price Changed
          - Memory Adjusted
          - Volumes Attached
          - Volumes Removed
        limit_price:
          type: string
          examples:
          - $15.60
          nullable: true
        user_id:
          type: string
          nullable: true
        memory_gb:
          type: integer
          nullable: true
        persistent_disk_change:
          $ref: '#/components/schemas/PersistentDiskChange'
          nullable: true
      type: object
      required:
      - timestamp
      - event_type
      title: BidHistoryEventModel
      description: A single event in the history of a spot bid.
    LaunchSpecificationModel:
      properties:
        volumes:
          items:
            type: string
            examples:
            - vol_abc123456
          type: array
          title: Volumes
          description: List of volume FIDs
          examples:
          - - vol_1234567890
            - vol_1234567891
        ssh_keys:
          items:
            type: string
            examples:
            - sshkey_abc123456
          type: array
          title: Ssh Keys
          description: List of SSH key FIDs
          examples:
          - - sshkey_1234567890
            - sshkey_1234567891
        startup_script:
          type: string
          nullable: true
        kubernetes_cluster:
          type: string
          examples:
          - clust_abc123456
          nullable: true
        image_version:
          type: string
          examples:
          - imgver_abc123456
          nullable: true
        memory_gb:
          type: integer
          nullable: true
      type: object
      required:
      - volumes
      - ssh_keys
      title: LaunchSpecificationModel
  securitySchemes:
    MithrilAPIKey:
      type: http
      scheme: bearer
      bearerFormat: fkey_<key>