# Freja Faceswap — Deepixels Swap faces in photos and videos with our optimized proprietary pipeline, using source portraits and optional identity matching. Model ID: freja/faceswap Revision: freja-faceswap-v1 Playground: https://www.deepixels.co/explore/freja/faceswap API reference: https://www.deepixels.co/explore/freja/faceswap/api Availability: Enabled Categories: Image to image, Video to video ## API usage Authenticate requests with your Deepixels API key in the x-api-key header. Keep the key server-side; never include it in public source code. Submit POST https://api.deepixels.co/v1/generate with JSON {model, input}. Use the model ID above and the input schema below. Poll GET https://api.deepixels.co/v1/get?jobId=YOUR_JOB_ID with the same x-api-key header, or use a webhook as documented by the API. ## Request body fields - model (string, required): The exact model ID to run. Value: "freja/faceswap". - input (object, required): Model inputs as a JSON object. Supported fields and limits are documented below. - webhook (string, optional): Optional public HTTPS URL. Deepixels sends a POST when the job completes or fails, with the same job body returned by GET /v1/get. Return a 2xx status to acknowledge delivery. Delivery may be retried, so handle repeated job IDs safely. ## Create-job response - jobId (string): The job ID. Use it to read this job's status and result. - status (string): The initial job status. Submission returns before generation finishes. - credit (number): Credits reserved by the server using the current model pricing. This is a response field; do not send it in the request. Expected HTTP 200 response (illustrative; credit is not a quote): ```json { "jobId": "example-job-id", "status": "created", "credit": 1 } ``` ## Get-job response - jobId (string): The job ID. - model (string): The model used by this job. - status (string): Stop polling at completed or failed. Values: created, pending, processing, completed, failed. - input (object | null): The saved model inputs. - webhook (string | null): The callback URL, when supplied. - output (object | null): The current Deepixels job API returns result URL arrays, such as videoUrl, imageUrl or audioUrl when available. It can be null before a result exists. The worker schema below describes worker media metadata, not this job envelope. - date (number | null): Job creation time as a Unix timestamp in milliseconds, when available. - startedAt (number | null): Job start time as a Unix timestamp in milliseconds, when available. - finishedAt (number | null): Job finish time as a Unix timestamp in milliseconds, when available. - durationMs (number | null): Recorded job duration in milliseconds, when available. - resultExpiresAt (number | null): Result expiry time as a Unix timestamp in milliseconds, when available. - recordExpiresAt (number | null): Job record expiry time as a Unix timestamp in milliseconds, when available. Expected HTTP 200 response examples. IDs, URLs and timings are illustrative; stop polling at completed or failed. ### completed ```json { "jobId": "example-job-id", "model": "freja/faceswap", "status": "completed", "input": { "images": [ { "url": "https://r2.deepixels.co/explore/freja/inpaint/examples/599cc84a-b20e-4a2a-9185-9baf17038c3f/inputs/target-v1.png", "role": "source" }, { "url": "https://r2.deepixels.co/explore/freja/h3-image/examples/9ca91ff7-9fa6-44a8-9eae-a3be4f2ac97a/inputs/character-reference-v1.png", "role": "target" } ], "parameters": { "face_mask_types": [ "box" ], "reference_face_distance": 0.3 } }, "webhook": null, "output": { "imageUrl": [ "https://r2.deepixels.co/results/example-result.png" ], "videoUrl": [ "https://r2.deepixels.co/results/example-result.mp4" ] }, "date": 1767225600000, "startedAt": 1767225601000, "finishedAt": 1767225901000, "durationMs": 300000, "resultExpiresAt": 1767312301000, "recordExpiresAt": null } ``` ### processing ```json { "jobId": "example-job-id", "model": "freja/faceswap", "status": "processing", "input": { "images": [ { "url": "https://r2.deepixels.co/explore/freja/inpaint/examples/599cc84a-b20e-4a2a-9185-9baf17038c3f/inputs/target-v1.png", "role": "source" }, { "url": "https://r2.deepixels.co/explore/freja/h3-image/examples/9ca91ff7-9fa6-44a8-9eae-a3be4f2ac97a/inputs/character-reference-v1.png", "role": "target" } ], "parameters": { "face_mask_types": [ "box" ], "reference_face_distance": 0.3 } }, "webhook": null, "output": null, "date": 1767225600000, "startedAt": 1767225601000, "finishedAt": null, "durationMs": null, "resultExpiresAt": null, "recordExpiresAt": null } ``` ### failed ```json { "jobId": "example-job-id", "model": "freja/faceswap", "status": "failed", "input": { "images": [ { "url": "https://r2.deepixels.co/explore/freja/inpaint/examples/599cc84a-b20e-4a2a-9185-9baf17038c3f/inputs/target-v1.png", "role": "source" }, { "url": "https://r2.deepixels.co/explore/freja/h3-image/examples/9ca91ff7-9fa6-44a8-9eae-a3be4f2ac97a/inputs/character-reference-v1.png", "role": "target" } ], "parameters": { "face_mask_types": [ "box" ], "reference_face_distance": 0.3 } }, "webhook": null, "output": null, "date": 1767225600000, "startedAt": 1767225601000, "finishedAt": 1767225901000, "durationMs": 300000, "resultExpiresAt": null, "recordExpiresAt": null } ``` ## List requests GET https://api.deepixels.co/v1/model-requests?model=freja%2Ffaceswap with the same x-api-key header. Only your jobs for this model are returned, newest first, up to 20 per page. Response: {requests: [{response, source, contractVersion, billing}], next_cursor}. response is the full Get-job response. billing has state, reservedCredits, chargedCredits and refundedCredits; unknown amounts are null. source is playground, api or unknown (informational only). Pass next_cursor as cursor for the next page; null means the end. Temporary media can expire without removing request details. ## Model inputs ### source Type: public HTTPS media URL; required Add one to five clear portraits of the same person whose face you want to use. Each photo must show exactly one face. Different angles can help. Maximum length: 8,192 characters Example: One front-facing portrait and one three-quarter portrait of the same adult. ### target_image Type: public HTTPS media URL Choose the photo to edit, or use target_video below. Remove target_video first if it is selected. Input links support PNG/JPEG/WebP up to 50 MiB; images are reduced to at most 4 megapixels and 4096 pixels per side. Maximum length: 8,192 characters Example: A portrait or group photo containing the face to replace. ### target_video Type: public HTTPS media URL Choose an MP4 instead of a photo. Remove target_image first if it is selected. Upload up to 25 MiB, or paste a public MP4 link up to 256 MiB. Only the first 30 seconds are processed; videos fit within 1280x720 landscape, 720x1280 portrait or 720x720 square and up to 30 FPS. Smaller videos stay smaller. Maximum length: 8,192 characters Example: A short MP4 with a clearly visible face. ### reference Type: public HTTPS media URL Optionally choose a portrait of the person to replace in the target. This is different from source: source supplies the new face, reference identifies the old face. Without reference, the largest detected face is selected separately in each video frame. Maximum length: 8,192 characters Example: A crop showing the target person when several people appear. ### parameters.face_mask_types Type: array box blends the face boundary. occlusion helps preserve objects covering the face. Select at least one. Minimum items: 1 Maximum items: 2 Example: Select box and occlusion for a face partly covered by a hand. Default: ["box"] ### parameters.reference_face_distance Type: number With a reference portrait, choose 0.05–0.6 for identity matching. Lower values are stricter and may leave more frames unchanged. Has no effect without a reference portrait. Minimum: 0.05 Maximum: 0.6 Example: Start at 0.3; try 0.2 for stricter matching. Default: 0.3 ## Input schema ```json { "type": "object", "additionalProperties": false, "required": [ "images" ], "properties": { "images": { "type": "array", "minItems": 1, "maxItems": 7, "items": { "type": "object", "additionalProperties": false, "required": [ "url", "role" ], "properties": { "url": { "type": "string", "format": "uri", "pattern": "^https://", "maxLength": 8192 }, "role": { "enum": [ "source", "reference", "target" ] } } }, "allOf": [ { "contains": { "type": "object", "required": [ "role" ], "properties": { "role": { "const": "source" } } }, "minContains": 1, "maxContains": 5 }, { "contains": { "type": "object", "required": [ "role" ], "properties": { "role": { "const": "reference" } } }, "minContains": 0, "maxContains": 1 }, { "contains": { "type": "object", "required": [ "role" ], "properties": { "role": { "const": "target" } } }, "minContains": 0, "maxContains": 1 } ], "description": "One to five source portraits of the same person; optionally one reference portrait identifying whom to replace, and one image target when no video target is supplied. Each source/reference must show exactly one face." }, "videos": { "type": "array", "minItems": 1, "maxItems": 1, "items": { "type": "object", "additionalProperties": false, "required": [ "url", "role" ], "properties": { "url": { "type": "string", "format": "uri", "pattern": "^https://", "maxLength": 8192 }, "role": { "const": "target" } } }, "description": "One MP4 target instead of an image target. Public URLs up to 256 MiB; uploads up to 25 MiB. The first 30 seconds are processed, fitted within 720p bounds and capped to 30 FPS." }, "parameters": { "type": "object", "additionalProperties": false, "default": {}, "properties": { "face_mask_types": { "type": "array", "minItems": 1, "maxItems": 2, "uniqueItems": true, "default": [ "box" ], "items": { "type": "string", "enum": [ "box", "occlusion" ] }, "description": "Choose box to blend the face boundary; add occlusion to protect objects covering the face. At least one is required." }, "reference_face_distance": { "type": "number", "minimum": 0.05, "maximum": 0.6, "default": 0.3, "description": "Identity matching tolerance when a reference portrait is supplied. Lower values are stricter. Ignored without a reference." } } } }, "oneOf": [ { "properties": { "images": { "contains": { "type": "object", "required": [ "role" ], "properties": { "role": { "const": "target" } } }, "minContains": 1, "maxContains": 1 } }, "not": { "required": [ "videos" ] } }, { "required": [ "videos" ], "properties": { "images": { "not": { "contains": { "type": "object", "required": [ "role" ], "properties": { "role": { "const": "target" } } } } } } } ] } ``` ## Worker output schema ```json { "type": "object", "required": [ "schema_version", "results", "metadata" ], "properties": { "schema_version": { "const": 1 }, "results": { "type": "array", "minItems": 1, "maxItems": 1, "items": { "type": "object", "required": [ "type", "url", "content_type", "bytes", "width", "height" ], "properties": { "type": { "enum": [ "image", "video" ] }, "url": { "type": "string", "format": "uri", "pattern": "^https://", "maxLength": 8192 }, "content_type": { "enum": [ "image/png", "video/mp4" ] }, "bytes": { "type": "integer", "minimum": 1 }, "width": { "type": "integer", "minimum": 1, "maximum": 4096 }, "height": { "type": "integer", "minimum": 1, "maximum": 4096 }, "duration_seconds": { "type": "number", "exclusiveMinimum": 0 }, "fps": { "type": "number", "exclusiveMinimum": 0 }, "num_frames": { "type": "integer", "minimum": 1 }, "has_audio": { "type": "boolean" } } } }, "metadata": { "type": "object" } } } ``` The worker output schema describes model media output. Use the documented Deepixels job response and output URL fields when polling. ## Example: undefined ```json { "model": "freja/faceswap", "input": { "images": [ { "url": "https://r2.deepixels.co/explore/freja/inpaint/examples/599cc84a-b20e-4a2a-9185-9baf17038c3f/inputs/target-v1.png", "role": "source" }, { "url": "https://r2.deepixels.co/explore/freja/h3-image/examples/9ca91ff7-9fa6-44a8-9eae-a3be4f2ac97a/inputs/character-reference-v1.png", "role": "target" } ], "parameters": { "face_mask_types": [ "box" ], "reference_face_distance": 0.3 } } } ``` ## Submit a generation (cURL) Bash or a compatible shell. Replace the API key placeholder. ```shell curl https://api.deepixels.co/v1/generate \ -H 'Content-Type: application/json' \ -H 'x-api-key: YOUR_DEEPIXELS_API_KEY' \ --data-raw '{"model":"freja/faceswap","input":{"images":[{"url":"https://r2.deepixels.co/explore/freja/inpaint/examples/599cc84a-b20e-4a2a-9185-9baf17038c3f/inputs/target-v1.png","role":"source"},{"url":"https://r2.deepixels.co/explore/freja/h3-image/examples/9ca91ff7-9fa6-44a8-9eae-a3be4f2ac97a/inputs/character-reference-v1.png","role":"target"}],"parameters":{"face_mask_types":["box"],"reference_face_distance":0.3}}}' ``` ## Submit a generation (JavaScript) Run server-side with Node.js 18 or newer. Set DEEPIXELS_API_KEY in your environment. ```javascript const apiKey = process.env.DEEPIXELS_API_KEY; if (!apiKey) throw new Error("Set DEEPIXELS_API_KEY first."); const request = { "model": "freja/faceswap", "input": { "images": [ { "url": "https://r2.deepixels.co/explore/freja/inpaint/examples/599cc84a-b20e-4a2a-9185-9baf17038c3f/inputs/target-v1.png", "role": "source" }, { "url": "https://r2.deepixels.co/explore/freja/h3-image/examples/9ca91ff7-9fa6-44a8-9eae-a3be4f2ac97a/inputs/character-reference-v1.png", "role": "target" } ], "parameters": { "face_mask_types": [ "box" ], "reference_face_distance": 0.3 } } }; const response = await fetch("https://api.deepixels.co/v1/generate", { method: "POST", headers: { "Content-Type": "application/json", "x-api-key": apiKey }, body: JSON.stringify(request), }); const job = await response.json(); if (!response.ok) throw new Error(job.message || "Generation request failed."); console.log(job); ``` ## Submit a generation (Python) Python 3, using only its standard library. Set DEEPIXELS_API_KEY in your environment. ```python import json import os import urllib.request payload = json.loads("{\"model\":\"freja/faceswap\",\"input\":{\"images\":[{\"url\":\"https://r2.deepixels.co/explore/freja/inpaint/examples/599cc84a-b20e-4a2a-9185-9baf17038c3f/inputs/target-v1.png\",\"role\":\"source\"},{\"url\":\"https://r2.deepixels.co/explore/freja/h3-image/examples/9ca91ff7-9fa6-44a8-9eae-a3be4f2ac97a/inputs/character-reference-v1.png\",\"role\":\"target\"}],\"parameters\":{\"face_mask_types\":[\"box\"],\"reference_face_distance\":0.3}}}") request = urllib.request.Request( "https://api.deepixels.co/v1/generate", data=json.dumps(payload).encode("utf-8"), headers={ "Content-Type": "application/json", "x-api-key": os.environ["DEEPIXELS_API_KEY"], }, method="POST", ) with urllib.request.urlopen(request, timeout=60) as response: job = json.load(response) print(job) ``` ## Request body (JSON) Send this JSON body to POST /v1/generate with your x-api-key header. ```json { "model": "freja/faceswap", "input": { "images": [ { "url": "https://r2.deepixels.co/explore/freja/inpaint/examples/599cc84a-b20e-4a2a-9185-9baf17038c3f/inputs/target-v1.png", "role": "source" }, { "url": "https://r2.deepixels.co/explore/freja/h3-image/examples/9ca91ff7-9fa6-44a8-9eae-a3be4f2ac97a/inputs/character-reference-v1.png", "role": "target" } ], "parameters": { "face_mask_types": [ "box" ], "reference_face_distance": 0.3 } } } ``` ## Credit pricing 0.05 credits per image, or 0.02 credits per started second of video. - Videos have a five-second minimum charge. Video seconds always round upward: 5.1 seconds costs 0.12 credits. - Only the first 30 seconds are processed and billed, so the maximum video charge is 0.60 credits. - The backend measures the target video before reserving credits. It uses a temporary snapshot for processing so the checked video cannot change afterward. - Extra source portraits, identity matching and occlusion masking have no separate surcharge. - Credits are reserved before inference. Failed jobs refund the reserved credits. Pricing rules and exact billing details (credits): ```json { "version": "freja-faceswap-credits-v1", "combine": "sum", "minimum_credits": "0", "description": "0.05 credits per image, or 0.02 credits per started second of video.", "selectors": [ { "name": "media_type", "cases": [ { "input_schema": { "type": "object", "required": [ "videos" ] }, "value": "video" }, { "input_schema": { "type": "object" }, "value": "image" } ] } ], "rules": [ { "id": "image", "metric": "billing.images", "credits_per_unit": "0.05", "unit_size": 1, "quantity_rounding": "ceil", "when": {}, "when_selected": { "media_type": "image" }, "aggregation": "sum", "minimum_credits": "0", "rounding": { "mode": "ceil", "scope": "total", "increment": "0.000001" } }, { "id": "video", "metric": "billing.video_seconds", "credits_per_unit": "0.02", "unit_size": 1, "quantity_rounding": "ceil", "when": {}, "when_selected": { "media_type": "video" }, "aggregation": "sum", "minimum_credits": "0", "rounding": { "mode": "ceil", "scope": "total", "increment": "0.000001" } } ], "notes": [ "Videos have a five-second minimum charge. Video seconds always round upward: 5.1 seconds costs 0.12 credits.", "Only the first 30 seconds are processed and billed, so the maximum video charge is 0.60 credits.", "The backend measures the target video before reserving credits. It uses a temporary snapshot for processing so the checked video cannot change afterward.", "Extra source portraits, identity matching and occlusion masking have no separate surcharge.", "Credits are reserved before inference. Failed jobs refund the reserved credits." ] } ``` ## Limits and behavior - This model has no text prompt, negative prompt, seed, step count or LoRA input. - Source and reference portraits must each contain exactly one detectable face. Use source photos of the same person. - Without a reference portrait, the largest detected face is chosen per frame; a video with several people may switch subjects. This is not persistent identity tracking. - With a reference portrait, frames without a matching face remain unchanged. Jobs with no selected face fail and refund reserved credits. - Only one image or video target and one output are supported. Image outputs are PNG; videos are H.264 MP4. - Image URLs: PNG/JPEG/WebP up to 50 MiB, 64 megapixels and 16384 pixels per side; normalized to at most 4 megapixels/4096 per side. Playground image uploads use 10 MiB/12 MP limits. - MP4 intake is up to 256 MiB/4096 pixels per side; Playground uploads are capped at 25 MiB. Longer clips use only their first 30 seconds. Video resolution and FPS may be reduced automatically. - The existing audio track is requested when available; full audio-preservation acceptance and maximum-load quality remain unverified. - Editing quality depends on face angle, lighting and occlusion. Result media expires after 24 hours unless saved to assets.