{
 "openapi": "3.0.3",
 "info": {
  "title": "Face and head swap (default): Qwen-Image-2.1 + BFS head-swap LoRA",
  "version": "2026-11-21",
  "description": "Curated ZeroGPU tool from the ZeroGPU lineup catalog. Calls go straight to the upstream Space hugging-apps/bfs-best-face-swap; send your own HF token as a bearer token so the call uses your ZeroGPU quota."
 },
 "servers": [
  {
   "url": "https://hugging-apps-bfs-best-face-swap.hf.space"
  }
 ],
 "x-zerogpu": {
  "category": "Image editing",
  "slot": "Face and head swap",
  "need": "Character consistency, stand-ins and retouching. High abuse risk.",
  "role": "default",
  "space": "hugging-apps/bfs-best-face-swap",
  "space_url": "https://huggingface.co/spaces/hugging-apps/bfs-best-face-swap",
  "model": "Qwen-Image-2.1 + BFS head-swap LoRA",
  "license": "Qwen Research (non-commercial)",
  "license_class": "nc",
  "gpu_seconds_booked": "9\u201323",
  "notes": "The newest and best head swap. Measured 9 s at 1024 px and 23 s at 1536 px.",
  "caveats": "The Space only shows a consent note. The super Space must add a consent assertion and a real-person/NCII filter, and refuse minors.",
  "lineup_call": "/face_swap(reference_face, target_image, base_model=\"Turbo \u00b7 Viggle 6-step\", resolution=\"1536\", num_inference_steps=6, lora_scale=1) \u2192 image slider, seed",
  "api_style": "v2",
  "mcp_url": "https://hugging-apps-bfs-best-face-swap.hf.space/gradio_api/mcp/"
 },
 "components": {
  "securitySchemes": {
   "hfToken": {
    "type": "http",
    "scheme": "bearer",
    "description": "Your own Hugging Face token (read scope is enough). It is sent only to the upstream Space and bills that call to your account's ZeroGPU quota. Without it the call runs on the small anonymous quota."
   }
  },
  "schemas": {}
 },
 "paths": {
  "/gradio_api/call/v2/face_swap": {
   "post": {
    "summary": "Face and head swap (default): Qwen-Image-2.1 + BFS head-swap LoRA",
    "description": "Character consistency, stand-ins and retouching. High abuse risk. Step 1 of 2: returns {\"event_id\"}; then GET /gradio_api/call/face_swap/{event_id} reads an SSE stream whose `event: complete` data is the JSON output array (`event: error` on failure). Upstream: https://huggingface.co/spaces/hugging-apps/bfs-best-face-swap. License: Qwen Research (non-commercial). Caveats: The Space only shows a consent note. The super Space must add a consent assertion and a real-person/NCII filter, and refuse minors. \n\nUpstream description: Swap the head of the person in `target_image` with the head from `reference_face`. Uses the BFS head-swap LoRA (bfs_head_v1_qwen_2.1) on Qwen-Image-2.1.Output must be fetched from GET /gradio_api/call/face_swap/{event_id}. Returns an array of 2 elements of the following format: [\"output ({'anyOf': [{'maxItems': 2, 'minItems': 2, 'prefixItems': [{'anyOf': [{'type': 'object', 'description': 'JSON object with url key to fetch the output'}, {'type': 'null'}]}, {'anyOf': [{'type': 'object', 'description': 'JSON object with url key to fetch the output'}, {'type': 'null'}]}], 'type': 'array'}, {'type': 'null'}], 'title': 'SliderData', 'additional_description': None})\", \"output_1 ({'type': 'number'})\"]",
    "operationId": "image_edit_face_and_head_swap",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "reference_face": {
          "type": "string",
          "description": "Must include {\"path\": \"url\", \"meta\": {\"_type\": \"gradio.FileData\"}}. The meta key signals that the file will be uploaded to the remote server.",
          "format": "filepath"
         },
         "target_image": {
          "type": "string",
          "description": "Must include {\"path\": \"url\", \"meta\": {\"_type\": \"gradio.FileData\"}}. The meta key signals that the file will be uploaded to the remote server.",
          "format": "filepath"
         },
         "base_model": {
          "enum": [
           "Turbo \u00b7 Viggle 6-step",
           "Base \u00b7 Qwen-Image-2.1"
          ],
          "title": "Radio",
          "type": "string"
         },
         "resolution": {
          "type": "integer",
          "enum": [
           1024,
           1536,
           2048
          ]
         },
         "num_inference_steps": {
          "type": "number",
          "description": "numeric value between 4 and 50"
         },
         "lora_scale": {
          "type": "number",
          "description": "numeric value between 0.0 and 1.5"
         },
         "seed": {
          "type": "number",
          "description": "numeric value between 0 and 2147483647"
         },
         "randomize_seed": {
          "type": "boolean"
         },
         "prompt": {
          "type": "string",
          "description": "If omitted, the Space substitutes its demo text (\"head_swap: start with <image1> as the base image, keeping it\\u2026\"); send \"\" for none."
         }
        },
        "required": [
         "prompt"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Job accepted.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "required": [
          "event_id"
         ],
         "properties": {
          "event_id": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    },
    "tags": [
     "Image editing"
    ],
    "security": [
     {
      "hfToken": []
     },
     {}
    ]
   }
  },
  "/gradio_api/call/face_swap/{event_id}": {
   "get": {
    "summary": "Fetch results for /face_swap",
    "description": "Returns a stream of server-sent events (SSE). The final event has `event: complete` with `data` containing a JSON array of outputs.",
    "operationId": "image_edit_face_and_head_swap_result",
    "parameters": [
     {
      "name": "event_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "The event_id returned by the POST request"
     }
    ],
    "responses": {
     "200": {
      "description": "SSE stream with event: complete containing a JSON array of outputs",
      "content": {
       "text/event-stream": {
        "schema": {
         "type": "string"
        }
       }
      }
     }
    },
    "tags": [
     "Image editing"
    ],
    "security": [
     {
      "hfToken": []
     },
     {}
    ]
   }
  },
  "/gradio_api/upload": {
   "post": {
    "summary": "Upload File",
    "operationId": "image_edit_face_and_head_swap_upload",
    "parameters": [
     {
      "name": "upload_id",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "nullable": true,
       "default": null
      },
      "description": "Optional ID to track upload progress"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "multipart/form-data": {
       "schema": {
        "type": "object",
        "properties": {
         "files": {
          "type": "array",
          "items": {
           "type": "string",
           "format": "binary"
          },
          "description": "One or more files to upload"
         }
        },
        "required": [
         "files"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "List of file paths where the uploaded files were saved",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "type": "string"
         }
        }
       }
      }
     },
     "400": {
      "description": "Invalid content type or invalid file name",
      "content": {
       "text/plain": {
        "schema": {
         "type": "string"
        }
       }
      }
     },
     "413": {
      "description": "File exceeds maximum allowed size",
      "content": {
       "text/plain": {
        "schema": {
         "type": "string"
        }
       }
      }
     }
    },
    "security": [
     {
      "hfToken": []
     },
     {}
    ]
   }
  }
 }
}