openapi: 3.0.3
info:
  title: Spot Seller API
  description: A focused API for registering capacity, listing offers, and monitoring seller delivery. Prices are decimal strings per one million tokens.
  license:
    name: MIT
  version: 1.0.0
servers:
- url: https://aispotmarket.com/sell/api
  description: Production Seller API
paths:
  /v1/agent-keys:
    get:
      tags:
      - crate
      operationId: list_agent_keys
      responses:
        '200':
          description: Agent credentials, newest first
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentKeyList'
        '401':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
      security:
      - x_seller_api_key: []
    post:
      tags:
      - crate
      operationId: create_agent_key
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAgentKey'
        required: true
      responses:
        '200':
          description: Minted credential; the secret is shown once
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MintedAgentKey'
        '400':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '401':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
      security:
      - x_seller_api_key: []
  /v1/agent-keys/{id}:
    delete:
      tags:
      - crate
      operationId: revoke_agent_key
      parameters:
      - name: id
        in: path
        description: Agent key id
        required: true
        schema:
          type: string
      responses:
        '204':
          description: Revoked
        '401':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '404':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
      security:
      - x_seller_api_key: []
  /v1/decisions:
    post:
      tags:
      - crate
      operationId: report_seller_decisions
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReportDecisionsRequest'
        required: true
      responses:
        '200':
          description: Decisions recorded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReportDecisionsResponse'
        '400':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '401':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
      security:
      - x_seller_api_key: []
  /v1/deliveries:
    get:
      tags:
      - crate
      operationId: seller_persona_deliveries
      responses:
        '200':
          description: Reserved delivery lots
      security:
      - x_seller_api_key: []
  /v1/offers:
    get:
      tags:
      - crate
      operationId: list_seller_offers
      responses:
        '200':
          description: Active offers
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SellerOfferList'
        '401':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
      security:
      - x_seller_api_key: []
    post:
      tags:
      - crate
      operationId: create_seller_offer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSellerOffer'
        required: true
      responses:
        '200':
          description: Accepted offer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SellerOffer'
        '400':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '401':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
      security:
      - x_seller_api_key: []
  /v1/offers/{id}:
    delete:
      tags:
      - crate
      operationId: cancel_seller_offer
      parameters:
      - name: id
        in: path
        description: Offer id
        required: true
        schema:
          type: string
      responses:
        '204':
          description: Offer cancelled
        '401':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '404':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
      security:
      - x_seller_api_key: []
  /v1/profile:
    get:
      tags:
      - crate
      operationId: seller_profile
      responses:
        '200':
          description: Authenticated seller profile
        '401':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
      security:
      - x_seller_api_key: []
  /v1/register:
    post:
      tags:
      - crate
      operationId: register_seller_persona
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SellerRegistration'
        required: true
      responses:
        '200':
          description: Registered seller profile
  /v1/reputation:
    get:
      tags:
      - crate
      operationId: seller_persona_reputation
      responses:
        '200':
          description: Authenticated seller reputation
      security:
      - x_seller_api_key: []
  /v1/trades:
    get:
      tags:
      - crate
      operationId: seller_persona_trades
      responses:
        '200':
          description: Seller executions
      security:
      - x_seller_api_key: []
components:
  schemas:
    AgentKey:
      type: object
      required:
      - key_id
      - label
      - last4
      - created_at
      properties:
        created_at:
          type: string
        key_id:
          type: string
        label:
          type: string
        last4:
          type: string
        revoked_at:
          type: string
          nullable: true
    AgentKeyList:
      type: object
      required:
      - agent_keys
      properties:
        agent_keys:
          type: array
          items:
            $ref: '#/components/schemas/AgentKey'
    CreateAgentKey:
      type: object
      required:
      - label
      properties:
        label:
          type: string
          description: Operator-facing name, so several daemons can be told apart.
    CreateSellerOffer:
      type: object
      required:
      - model
      - region
      - price_per_million_tokens
      - quantity_tokens
      - valid_for_seconds
      properties:
        model:
          type: string
        price_per_million_tokens:
          type: string
          description: Decimal price per one million tokens.
        quantity_tokens:
          type: integer
          format: int64
          minimum: 0
        region:
          type: string
        tenor:
          type: string
          nullable: true
        valid_for_seconds:
          type: integer
          format: int64
          minimum: 0
    ErrorBody:
      type: object
      required:
      - code
      - error
      properties:
        code:
          type: string
          description: Wire error code.
        error:
          type: string
          description: Human-readable detail.
    MintedAgentKey:
      type: object
      required:
      - key_id
      - label
      - agent_key
      - last4
      - created_at
      properties:
        agent_key:
          type: string
          description: The secret. Returned once; Spot stores only its hash.
        created_at:
          type: string
        key_id:
          type: string
        label:
          type: string
        last4:
          type: string
    ReportDecisionsRequest:
      type: object
      description: Body of `POST /v1/sellers/{id}/decisions`.
      required:
      - decisions
      properties:
        decisions:
          type: array
          items:
            $ref: '#/components/schemas/SellerDecision'
          description: Decisions from one Autopilot tick. Must not be empty.
    ReportDecisionsResponse:
      type: object
      description: Response for `POST /v1/sellers/{id}/decisions`.
      required:
      - seller_id
      - recorded
      properties:
        recorded:
          type: integer
          description: How many decisions this request recorded.
          minimum: 0
        seller_id:
          type: string
          description: Seller the decisions were recorded against.
    SellerDecision:
      type: object
      description: |-
        One Autopilot decision, as reported to the Market.

        Autopilot keeps the durable copy in its own local log; this is the
        operator-facing projection the dashboard reads back.
      required:
      - at
      - sold
      - reason
      properties:
        at:
          type: string
          description: When the decision was taken.
        model_id:
          type: string
          description: |-
            Model the decision applies to. `null` for a cluster-wide decision, such
            as a guardrail that stopped every model at once.
          nullable: true
        price_per_million:
          type: string
          description: Price per one million tokens the decision used, when it had one.
          nullable: true
        reason:
          type: string
          description: Operator-facing explanation, at most 500 characters.
        sold:
          type: boolean
          description: Whether capacity was listed for sale as a result.
        tokens:
          type: integer
          format: int64
          description: Tokens the decision covered, when it listed or would have listed.
          nullable: true
          minimum: 0
    SellerOffer:
      type: object
      required:
      - offer_id
      - status
      - model
      - region
      - price_per_million_tokens
      - quantity_tokens
      - remaining_tokens
      - created_at
      - expires_at
      properties:
        created_at:
          type: string
        expires_at:
          type: string
        model:
          type: string
        offer_id:
          type: string
        price_per_million_tokens:
          type: string
          description: Decimal price per one million tokens.
        quantity_tokens:
          type: integer
          format: int64
          minimum: 0
        region:
          type: string
        remaining_tokens:
          type: integer
          format: int64
          minimum: 0
        status:
          type: string
    SellerOfferList:
      type: object
      required:
      - offers
      properties:
        offers:
          type: array
          items:
            $ref: '#/components/schemas/SellerOffer'
    SellerRegistration:
      type: object
      required:
      - name
      - endpoint_url
      - supported_models
      - api_key
      properties:
        api_key:
          type: string
        endpoint_url:
          type: string
        name:
          type: string
        regions:
          type: array
          items:
            type: string
          description: |-
            Delivery regions. Omit to keep the current regions on re-registration,
            or to default a new seller to `["global"]`.
          nullable: true
        supported_models:
          type: array
          items:
            type: string
  securitySchemes:
    bearer_buyer:
      type: http
      scheme: bearer
    x_seller_api_key:
      type: apiKey
      in: header
      name: X-Seller-API-Key
