Image workflow
Create an isolated environment
- 1Install the single dependency
python -m pip install -r requirements.txt - 2Set the server-side key
export FACESWAPAI_API_KEY="YOUR_API_KEY" - 3Run the example
python examples/python/image_swap.py source.jpg target.jpg
import os
from src.python.faceswapai import FaceSwapAIClient
client = FaceSwapAIClient(os.environ["FACESWAPAI_API_KEY"])
accepted = client.submit_image("source.jpg", "target.jpg")
task = client.wait_for_task("image", accepted["taskId"])
print((task.get("result") or {}).get("url"))
Failure handling
Keep HTTP context intact
FaceSwapAIError preserves the HTTP status and parsed response body so integrations can distinguish verification, credit, input, rate-limit and provider failures.
401Missing or invalid API key
402Insufficient credits
403Email verification required
413Request or file exceeds a limit
429Authenticated request limit reached
503Processing provider unavailable