> For the complete documentation index, see [llms.txt](https://docs.api.market/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.api.market/api-product-docs/magicapi/migrating-from-capix-faceswap-api-to-magicapi-faceswap-capix-api.md).

# Migrating from Capix FaceSwap API to magicapi/faceswap-capix API

> ### **You can try the new API here ->** [**https://api.market/store/magicapi/faceswap-capix**](https://api.market/store/magicapi/faceswap-capix)

**Why Migrate?**

The Capix FaceSwap API is scheduled for a platform-wide shutdown on **Wednesday, May 21st, 2025**. Our new `magicapi/faceswap-capix` API is an enhanced, in-house replacement designed for better performance and clarity.

### Summary of Key Differences

The primary changes you need to be aware of are:

1. **No `/upload/` Endpoint:** The new API requires you to provide public URLs for your `target_url` and `swap_url` directly. File uploads via a dedicated endpoint are no longer supported.
2. **New Base URL:** The base URL for the service has changed.
3. **New Endpoint Paths for Submitting Jobs:** The paths for initiating image and video faceswaps are new.
4. **Separate Result Endpoints:** Previously, you might have used a single `/result/` endpoint. Now, there are distinct endpoints for fetching image results (`/image/result/`) and video results (`/video/result/`).

Other aspects like authentication (using `x-api-market-key`) and the core parameters for `target_url` and `swap_url` remain conceptually similar, though the new API introduces an optional `target_face_index`.

### Step-by-Step Migration

#### 1. Update API Base URLs and Endpoint Paths

This is the most critical part of the migration.

* **Old Capix API Base URL (example):** `https://prod.api.market/api/v1/capix/faceswap`
* **New `magicapi/faceswap-capix` API Base URL:** `https://prod.api.market/api/v1/magicapi/faceswap-capix`

### **Endpoint Changes:**

* **Submitting Image FaceSwap:**
  * **Old:** `POST {OLD_BASE_URL}/faceswap/v1/image`
  * **New:** `POST {NEW_BASE_URL}/image/run`
    * *Key Change:* Base URL and path. Functionality is similar (takes `target_url`, `swap_url`).
* **Getting Image FaceSwap Result:**
  * **Old:** `POST {OLD_BASE_URL}/result/` (with `request_id` for an image job)
  * **New:** `POST {NEW_BASE_URL}/image/result/` (with `request_id`)
    * *Key Change:* Base URL and a dedicated path for image results.
* **Submitting Video FaceSwap:**
  * **Old:** `POST {OLD_BASE_URL}/faceswap/v1/video`
  * **New:** `POST {NEW_BASE_URL}/video/run`
    * *Key Change:* Base URL and path. Functionality is similar (takes `target_url`, `swap_url`). Response structure is the same as the new image run endpoint.
* **Getting Video FaceSwap Result:**
  * **Old:** `POST {OLD_BASE_URL}/result/` (with `request_id` for a video job)
  * **New:** `POST {NEW_BASE_URL}/video/result/` (with `request_id`)
    * *Key Change:* Base URL and a dedicated path for video results. Response structure is the same as the new image result endpoint.

#### 2. Adapt to the Absence of `/upload/` Endpoint

If you were using the `/upload/` endpoint in the old API, you must now ensure your image and video files are accessible via public URLs before calling the new `/image/run` or `/video/run` endpoints. The new API expects `target_url` and `swap_url` parameters to be direct public links.

**Alternative for Uploading:** If you require a way to upload your images to get a public URL, API.market provides a free, managed Image Upload API that you can use: <https://api.market/store/magicapi/image-upload>. This service can help you host your images and obtain the necessary public URLs for the `magicapi/faceswap-capix` API.

#### 3. Review Request Parameters

* The core parameters `target_url` and `swap_url` remain.
* The new API introduces an optional `target_face_index` (integer, default: 0) for both `/image/run` and `/video/run` if you need to specify which face to target in media with multiple faces.

#### 4. Understand Response Structures

The new API provides well-defined JSON responses. The `/run` endpoints immediately return a `request_id`. The `/result/` endpoints provide status and, upon completion, a `result_url`.

* **Important Note:** For video operations (`/video/run` and `/video/result/`), the main JSON response object key is `image_process_response`, the same as for image operations. Adapt your parsing logic accordingly.

If you have questions or need assistance with the migration, please contact API.market support.
