# Faceswap > Cambia caras en un vídeo con IA mediante la API de HeyGen. Úsalo para reemplazar una cara, aplicar la de una imagen origen sobre un vídeo o personalizar vídeos con la cara de alguien. Fuente: https://skillsagentes.com/skills/calesthio/openmontage/faceswap Markdown: https://skillsagentes.com/skills/calesthio/openmontage/faceswap.md Repositorio: https://github.com/calesthio/OpenMontage Autor: calesthio Licencia: AGPL-3.0 Actualizado: hace 4 meses Coste de contexto: 80 tok instalada, 1.8k tok al activarse, 1.8k tok con todos los archivos del bundle Bundle: 1 archivo, 7 KB Permisos que pide: mcp__heygen__* ## Instalación Un skill son archivos markdown: los mismos archivos valen para cualquier agente y lo único que cambia es el directorio de destino, es decir la bandera `--agent`. Añade `-g` para instalarlo en todos los proyectos de la máquina. ```bash # Claude Code npx -y skills add calesthio/OpenMontage --skill faceswap --agent claude-code # Cursor npx -y skills add calesthio/OpenMontage --skill faceswap --agent cursor # Codex npx -y skills add calesthio/OpenMontage --skill faceswap --agent codex # Gemini CLI npx -y skills add calesthio/OpenMontage --skill faceswap --agent gemini # Windsurf npx -y skills add calesthio/OpenMontage --skill faceswap --agent windsurf # Cline npx -y skills add calesthio/OpenMontage --skill faceswap --agent cline ``` ## Qué hace - Cambia la cara de un vídeo con IA usando el endpoint `/v1/workflows/executions` de HeyGen - Toma la cara de una imagen origen y la aplica sobre el vídeo destino - Lanza el trabajo, consulta el estado y hace polling hasta completarlo - Se puede encadenar tras generar un vídeo de avatar, con ejemplos en curl, TypeScript y Python ## Cuándo usarla - Reemplazar una cara de un vídeo por otra - Aplicar la cara de una imagen origen sobre un vídeo destino - Crear vídeos personalizados metiendo la cara de una persona ## Qué la activa - "Cambia la cara de este vídeo por la de esta foto" - "Personaliza este vídeo con mi cara" - "Haz un face swap sobre el vídeo del avatar" ## Antes de instalar - Necesita `HEYGEN_API_KEY` y las herramientas `mcp__heygen__*`. - Necesita en el PATH: curl - Variables de entorno: HEYGEN_API_KEY - makes network requests - needs API credentials ## Archivos - SKILL.md — 7 KB ## SKILL.md Reproducido tal cual desde calesthio/OpenMontage bajo AGPL-3.0. Esta sección es el documento original y está en inglés. # Face Swap (HeyGen API) Swap a face from a source image into a target video using GPU-accelerated AI processing. The source image provides the face to swap in, and the target video receives the new face. ## Authentication All requests require the `X-Api-Key` header. Set the `HEYGEN_API_KEY` environment variable. ```bash curl -X POST "https://api.heygen.com/v1/workflows/executions" \ -H "X-Api-Key: $HEYGEN_API_KEY" \ -H "Content-Type: application/json" \ -d '{"workflow_type": "FaceswapNode", "input": {"source_image_url": "https://example.com/face.jpg", "target_video_url": "https://example.com/video.mp4"}}' ``` ## Default Workflow 1. Call `POST /v1/workflows/executions` with `workflow_type: "FaceswapNode"`, a source face image, and a target video 2. Receive a `execution_id` in the response 3. Poll `GET /v1/workflows/executions/{id}` every 10 seconds until status is `completed` 4. Use the returned `video_url` from the output ## Execute Face Swap ### Endpoint `POST https://api.heygen.com/v1/workflows/executions` ### Request Fields | Field | Type | Req | Description | |-------|------|:---:|-------------| | `workflow_type` | string | Y | Must be `"FaceswapNode"` | | `input.source_image_url` | string | Y | URL of the face image to swap in | | `input.target_video_url` | string | Y | URL of the video to apply the face swap to | ### curl ```bash curl -X POST "https://api.heygen.com/v1/workflows/executions" \ -H "X-Api-Key: $HEYGEN_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "workflow_type": "FaceswapNode", "input": { "source_image_url": "https://example.com/face-photo.jpg", "target_video_url": "https://example.com/original-video.mp4" } }' ``` ### TypeScript ```typescript interface FaceswapInput { source_image_url: string; target_video_url: string; } interface ExecuteResponse { data: { execution_id: string; status: "submitted"; }; } async function faceswap(input: FaceswapInput): Promise { const response = await fetch("https://api.heygen.com/v1/workflows/executions", { method: "POST", headers: { "X-Api-Key": process.env.HEYGEN_API_KEY!, "Content-Type": "application/json", }, body: JSON.stringify({ workflow_type: "FaceswapNode", input, }), }); const json: ExecuteResponse = await response.json(); return json.data.execution_id; } ``` ### Python ```python import requests import os def faceswap(source_image_url: str, target_video_url: str) -> str: payload = { "workflow_type": "FaceswapNode", "input": { "source_image_url": source_image_url, "target_video_url": target_video_url, }, } response = requests.post( "https://api.heygen.com/v1/workflows/executions", headers={ "X-Api-Key": os.environ["HEYGEN_API_KEY"], "Content-Type": "application/json", }, json=payload, ) data = response.json() return data["data"]["execution_id"] ``` ### Response Format ```json { "data": { "execution_id": "node-gw-f1s2w3p4", "status": "submitted" } } ``` ## Check Status ### Endpoint `GET https://api.heygen.com/v1/workflows/executions/{execution_id}` ### curl ```bash curl -X GET "https://api.heygen.com/v1/workflows/executions/node-gw-f1s2w3p4" \ -H "X-Api-Key: $HEYGEN_API_KEY" ``` ### Response Format (Completed) ```json { "data": { "execution_id": "node-gw-f1s2w3p4", "status": "completed", "output": { "video_url": "https://resource.heygen.ai/faceswap/output.mp4" } } } ``` ## Polling for Completion ```typescript async function faceswapAndWait( input: FaceswapInput, maxWaitMs = 600000, pollIntervalMs = 10000 ): Promise { const executionId = await faceswap(input); console.log(`Submitted face swap: ${executionId}`); const startTime = Date.now(); while (Date.now() - startTime < maxWaitMs) { const response = await fetch( `https://api.heygen.com/v1/workflows/executions/${executionId}`, { headers: { "X-Api-Key": process.env.HEYGEN_API_KEY! } } ); const { data } = await response.json(); switch (data.status) { case "completed": return data.output.video_url; case "failed": throw new Error(data.error?.message || "Face swap failed"); case "not_found": throw new Error("Workflow not found"); default: await new Promise((r) => setTimeout(r, pollIntervalMs)); } } throw new Error("Face swap timed out"); } ``` ## Usage Examples ### Basic Face Swap ```bash curl -X POST "https://api.heygen.com/v1/workflows/executions" \ -H "X-Api-Key: $HEYGEN_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "workflow_type": "FaceswapNode", "input": { "source_image_url": "https://example.com/headshot.jpg", "target_video_url": "https://example.com/presentation.mp4" } }' ``` ### Chain with Avatar Video Generate an avatar video first, then swap in a custom face: ```python import time # Step 1: Generate avatar video avatar_execution_id = requests.post( "https://api.heygen.com/v1/workflows/executions", headers={"X-Api-Key": os.environ["HEYGEN_API_KEY"], "Content-Type": "application/json"}, json={ "workflow_type": "AvatarInferenceNode", "input": { "avatar": {"avatar_id": "Angela-inblackskirt-20220820"}, "audio_list": [{"audio_url": "https://example.com/speech.mp3"}], }, }, ).json()["data"]["execution_id"] # Step 2: Wait for avatar video to complete while True: status = requests.get( f"https://api.heygen.com/v1/workflows/executions/{avatar_execution_id}", headers={"X-Api-Key": os.environ["HEYGEN_API_KEY"]}, ).json()["data"] if status["status"] == "completed": avatar_video_url = status["output"]["video"]["video_url"] break time.sleep(10) # Step 3: Swap in a custom face faceswap_execution_id = faceswap( source_image_url="https://example.com/custom-face.jpg", target_video_url=avatar_video_url, ) ``` ## Best Practices 1. **Use a clear, front-facing face photo** — the source image should show a single face with good lighting 2. **Face swap is GPU-intensive** — expect 1-3 minutes processing time, poll every 10 seconds 3. **Source image quality matters** — higher resolution face photos produce better results 4. **One face per source image** — the source should contain exactly one face to swap in 5. **Works with any video** — the target video can be an avatar video, a recording, or any video with visible faces 6. **Chain with other workflows** — generate an avatar video first, then swap in a custom face for personalization ## Dónde encaja - Categoría: [Diseño y UI](https://skillsagentes.com/categorias/diseno-ui.md) — Sistemas de diseño, trabajo con componentes y acabado visual. - Creador: [calesthio](https://skillsagentes.com/creators/calesthio.md) — 0 skills en el directorio - [Todas las skills](https://skillsagentes.com/skills.md) - [Ranking de instalaciones](https://skillsagentes.com/ranking.md) ## Otras skills del mismo repositorio - [Seedance 2 5](https://skillsagentes.com/skills/calesthio/openmontage/seedance-2-5.md): Genera vídeo cinematográfico de 4-30 s con ByteDance Seedance 2.5 por fal.ai, Volcengine Ark, Runway o ComfyUI. Cubre el contrato de prompt 2.5, cortes duros, locks de continuidad y voz. - [Comfyui](https://skillsagentes.com/skills/calesthio/openmontage/comfyui.md): Úsalo al trabajar con workflows de ComfyUI en OpenMontage: comfyui_image/video/music, workflows propios, selección de output_node, modelos que faltan, LoRAs, poca VRAM e importación de workflows de la comunidad. - [Fish Audio Tts](https://skillsagentes.com/skills/calesthio/openmontage/fish-audio-tts.md): Genera narración expresiva y multilingüe con fish.audio (modelos S1 / S2) y reutiliza voces clonadas mediante reference_id. - [Minimax H3](https://skillsagentes.com/skills/calesthio/openmontage/minimax-h3.md): Genera vídeo con MiniMax H3 (Hailuo 3.0) por la API oficial v2, fal.ai, Runway, nodos partner de ComfyUI o pesos abiertos locales. Clips de 4-15s a 2K con animación de primer/último fotograma. - [Gemini Omni](https://skillsagentes.com/skills/calesthio/openmontage/gemini-omni.md): Genera y edita conversacionalmente vídeos cortos con Google Gemini Omni Flash: itera con ediciones en lenguaje natural, clips de 3-10s a 720p con audio y texto en pantalla, e imágenes de referencia por etiquetas. --- Skills Agentes · [Índice de páginas en markdown](https://skillsagentes.com/sitemap.md) · [Inicio](https://skillsagentes.com/index.md)