openapi: 3.0.0
servers:
  - url: https://prod.api.market/api/v1/magicapi/ai-photo-restoration-colorization
info:
  title: AI Photo Restoration & Colorizer API (Flux Kontext)
  description: Restore, repair, and colorize old or damaged photos instantly with
    high-quality AI from Flux Kontext.
  version: 85ae46551612b8f778348846b6ce1ce1b340e384fe2062399c0c412be29e107d
components:
  schemas:
    Input:
      type: object
      title: Input
      required:
        - input_image
      properties:
        seed:
          type: integer
          title: Seed
          x-order: 1
          description: Random seed. Set for reproducible generation
          example: 1
        input_image:
          type: string
          title: Input Image
          format: uri
          x-order: 0
          description: Image to restore. Must be jpeg, png, gif, or webp.
          example: https://replicate.delivery/mgxm/b033ff07-1d2e-4768-a137-6c16b5ed4bed/d_1.png
        output_format:
          allOf:
            - $ref: "#/components/schemas/output_format"
          default: png
          x-order: 2
          description: Output format for the generated image
        safety_tolerance:
          type: integer
          title: Safety Tolerance
          default: 2
          maximum: 2
          minimum: 0
          x-order: 3
          description: Safety tolerance, 0 is most strict and 2 is most permissive. 2 is
            currently the maximum allowed.
          example: 1
    Output:
      type: string
      title: Output
      format: uri
    Status:
      enum:
        - starting
        - processing
        - succeeded
        - canceled
        - failed
      type: string
      title: Status
      description: An enumeration.
    WebhookEvent:
      enum:
        - start
        - output
        - logs
        - completed
      type: string
      title: WebhookEvent
      description: An enumeration.
    output_format:
      enum:
        - jpg
        - png
      type: string
      title: output_format
      description: An enumeration.
    ValidationError:
      type: object
      title: ValidationError
      required:
        - loc
        - msg
        - type
      properties:
        loc:
          type: array
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
    PredictionRequest:
      type: object
      title: PredictionRequest
      properties:
        id:
          type: string
          title: Id
        input:
          $ref: "#/components/schemas/Input"
        context:
          type: object
          title: Context
          additionalProperties:
            type: string
        webhook:
          type: string
          title: Webhook
          format: uri
          maxLength: 65536
          minLength: 1
        created_at:
          type: string
          title: Created At
          format: date-time
        output_file_prefix:
          type: string
          title: Output File Prefix
        webhook_events_filter:
          type: array
          items:
            $ref: "#/components/schemas/WebhookEvent"
          default:
            - start
            - output
            - logs
            - completed
    PredictionResponse:
      type: object
      title: PredictionResponse
      properties:
        id:
          type: string
          title: Id
        logs:
          type: string
          title: Logs
          default: ""
        error:
          type: string
          title: Error
        input:
          $ref: "#/components/schemas/Input"
        output:
          $ref: "#/components/schemas/Output"
        status:
          $ref: "#/components/schemas/Status"
        metrics:
          type: object
          title: Metrics
        version:
          type: string
          title: Version
        created_at:
          type: string
          title: Created At
          format: date-time
        started_at:
          type: string
          title: Started At
          format: date-time
        completed_at:
          type: string
          title: Completed At
          format: date-time
    HTTPValidationError:
      type: object
      title: HTTPValidationError
      properties:
        detail:
          type: array
          items:
            $ref: "#/components/schemas/ValidationError"
          title: Detail
  securitySchemes: {}
security: {}
paths:
  /predictions:
    post:
      summary: Create a prediction with flux-kontext-apps/restore-image
      description: Run inference with the flux-kontext-apps/restore-image model on
        API.market
      operationId: createRestore_imagePrediction
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - version
                - input
              properties:
                version:
                  type: string
                  description: Model version ID
                  default: 85ae46551612b8f778348846b6ce1ce1b340e384fe2062399c0c412be29e107d
                input:
                  $ref: "#/components/schemas/Input"
            examples:
              default:
                summary: Default example
                value:
                  version: 85ae46551612b8f778348846b6ce1ce1b340e384fe2062399c0c412be29e107d
                  input:
                    input_image: https://replicate.delivery/mgxm/b033ff07-1d2e-4768-a137-6c16b5ed4bed/d_1.png
      responses:
        "201":
          description: Prediction created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: Unique identifier for the prediction
                  version:
                    type: string
                    description: Model version used for the prediction
                  status:
                    type: string
                    enum:
                      - starting
                      - processing
                      - succeeded
                      - failed
                      - canceled
                    description: Current status of the prediction
                  created_at:
                    type: string
                    format: date-time
                    description: When the prediction was created
              examples:
                success:
                  summary: Successful prediction creation
                  value:
                    id: ufawqhfynnddngldkgtslldrkq
                    version: 85ae46551612b8f778348846b6ce1ce1b340e384fe2062399c0c412be29e107d
                    status: starting
                    created_at: 2025-06-05T20:18:37.358Z
        "400":
          description: Bad request, validation error
        "401":
          description: Unauthorized, invalid API token
    parameters:
      - &a1
        description: API.market API Key
        in: header
        name: x-api-market-key
        value: Please Login/Signup to get an API Key
        required: true
        schema:
          type: string
  /predictions/{id}:
    get:
      summary: Get prediction status and results
      description: Get the status and results of a flux-kontext-apps/restore-image
        prediction from API.market
      operationId: getRestore_imagePrediction
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: The prediction ID
      responses:
        "200":
          description: Prediction details
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: Unique identifier for the prediction
                  status:
                    type: string
                    enum:
                      - starting
                      - processing
                      - succeeded
                      - failed
                      - canceled
                    description: Current status of the prediction
                  output:
                    $ref: "#/components/schemas/Output"
                  error:
                    type: string
                    description: Error message if the prediction failed
                  created_at:
                    type: string
                    format: date-time
                    description: When the prediction was created
                  started_at:
                    type: string
                    format: date-time
                    description: When the prediction started processing
                  completed_at:
                    type: string
                    format: date-time
                    description: When the prediction completed
              examples:
                succeeded:
                  summary: Successful prediction result
                  value:
                    id: ufawqhfynnddngldkgtslldrkq
                    status: succeeded
                    output: https://replicate.delivery/xezq/VjZzUS8uxOobNpyJzFebvWiuUa3Bzs60RQOexLVQIOuewckpA/tmpio8e0bce.png
                    created_at: 2023-01-01T12:00:00.000Z
                    started_at: 2023-01-01T12:00:05.000Z
                    completed_at: 2023-01-01T12:01:00.000Z
        "401":
          description: Unauthorized, invalid API token
        "404":
          description: Prediction not found
    parameters:
      - *a1
tags:
  - name: image
    description: Operations related to image
  - name: artificial-intelligence
    description: Operations related to artificial-intelligence
  - name: tools
    description: Operations related to tools
  - name: image-to-image
    description: Operations related to image-to-image
