FASHN AI Predictions API

The Predictions API from FASHN AI — 2 operation(s) for predictions.

OpenAPI Specification

fashn-predictions-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: FASHN AI Predictions API
  description: 'FASHN AI is a generative-image platform tailored for fashion. The public API exposes an asynchronous prediction workflow: clients submit a job against a named model with model-specific inputs, then poll a status endpoint until the prediction completes. Models include Try-On Max, Product to Model, Face to Model, Model Create, Model Swap, Edit, Reframe, Image to Video, and Background Remove.'
  version: '1.0'
  contact:
    name: FASHN AI
    url: https://fashn.ai/products/api
servers:
- url: https://api.fashn.ai/v1
  description: FASHN AI production API
security:
- BearerAuth: []
tags:
- name: Predictions
paths:
  /run:
    post:
      operationId: runPrediction
      summary: Submit a new prediction job
      description: 'Queues a new prediction for the requested model. The response contains a prediction id which must be polled via the status endpoint until the job reaches a terminal state. Rate limit: 50 requests per 60 seconds. Concurrency limit: 6 simultaneous predictions per account.'
      tags:
      - Predictions
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunRequest'
      responses:
        '200':
          description: Prediction accepted.
          headers:
            x-fashn-credits-used:
              schema:
                type: integer
              description: Credits consumed by the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunResponse'
        '400':
          description: Bad Request - invalid input.
        '401':
          description: Unauthorized - missing or invalid bearer token.
        '402':
          description: Payment Required - insufficient credits.
        '429':
          description: Too Many Requests - rate limit exceeded.
  /status/{id}:
    get:
      operationId: getPredictionStatus
      summary: Retrieve prediction status and output
      description: 'Returns the current state of a prediction. CDN output URLs are valid for 72 hours; base64 outputs are valid for 60 minutes. Rate limit: 50 requests per 10 seconds.'
      tags:
      - Predictions
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
        description: Prediction identifier returned from /run.
      responses:
        '200':
          description: Current prediction state.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatusResponse'
        '401':
          description: Unauthorized.
        '404':
          description: Prediction not found.
components:
  schemas:
    RunResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Identifier used to poll prediction status.
        error:
          type: string
          nullable: true
          description: Error message if the request was rejected, otherwise null.
    StatusResponse:
      type: object
      properties:
        id:
          type: string
        status:
          type: string
          enum:
          - starting
          - in_queue
          - processing
          - completed
          - failed
          description: Current lifecycle state of the prediction.
        output:
          type: array
          nullable: true
          items:
            type: string
            format: uri
          description: Output asset URLs (CDN). Available when status is completed. URLs are valid for 72 hours.
        error:
          type: string
          nullable: true
          description: Error message when status is failed, otherwise null.
    RunRequest:
      type: object
      required:
      - model_name
      - inputs
      properties:
        model_name:
          type: string
          description: The FASHN model to invoke (e.g. tryon-max, product-to-model, face-to-model, model-create, model-swap, edit, reframe, image-to-video, background-remove).
          examples:
          - tryon-max
          - product-to-model
        inputs:
          type: object
          additionalProperties: true
          description: Model-specific input parameters.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key