Developer Docs/Talking Photo API

Talking Photo API

Build Talking Photo integrations with HeadSwap. Review authentication, request parameters, task creation, status, and result endpoints.

Overview

Animate a portrait photo to lip-sync with a given audio track, generating a realistic talking-head video from a single still image.

Primary Endpoint

POST/api/v1/talkingPhoto/start

Create an asynchronous talking-photo task from the submitted portrait image and audio or text input, then return the task record used to monitor video generation. ### Request - Send a valid bearer token. The server evaluates the operation in the authenticated caller's access context. - Send an `application/json` body. Required fields: `name`, `image_url`, `prompt`, `negative_prompt`. - API-token callers may include `webhook_url` and `webhook_token` for best-effort terminal-state notifications; ordinary JWT/cookie calls ignore these fields. ### Behavior - This is an asynchronous operation: a successful submission creates a task and returns before processing finishes. - Persist the returned task identifier and use the corresponding detail or list operation to observe progress. - Treat the detail endpoint as the source of truth even when webhook delivery is enabled. ### Response - A `200` response confirms task acceptance; it does not by itself mean media generation has completed. - Retain the returned identifier and wait for a documented terminal status before using output URLs. - JSON object responses, including error responses, normally carry a top-level `trace_id` string for this request; include it when contacting support. It is not a task identifier. - Do not infer undocumented fields or statuses; clients should tolerate additional response properties. ### Errors - `400` — Bad Request - Invalid parameters. - `401` — Unauthorized - Invalid or missing JWT token. ### Related Operations - `GET /api/v1/talkingPhoto/allRecords` — Get all task records. - `GET /api/v1/talkingPhoto/{_id}` — Get task details. - `DELETE /api/v1/talkingPhoto/{_id}` — Delete task. Authentication: set header Authorization: Bearer <token> (supports user JWT or sk_ API token).

Request Parameters

NameTypeRequiredDescription
namestringYesName of the talking photo task
image_urlstringYesURL of the source image
audio_urlstringNoOptional audio URL
durationintegerNoDuration in seconds; minimum: 1; maximum: 20; default: 3
promptstringYesGeneration prompt
negative_promptstringYesNegative prompt to avoid unwanted features
minor_suspected_skipbooleanNoSet to true when retrying after error code 1004 to confirm and bypass the suspected-minor soft block.; default: false
webhook_urlstringNoHTTPS URL to receive task.completed / task.failed notifications. Best-effort delivery, single attempt, no retries; clients should treat the detail API as the source of truth.; maxLength: 2048
webhook_tokenstringNoOptional plaintext token returned in the X-A2e-Webhook-Token header so receivers can verify the request originated from a2e.; maxLength: 256
Request schema and conditional rules
{
  "allOf": [
    {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "Name of the talking photo task",
          "example": "My Talking Photo"
        },
        "image_url": {
          "type": "string",
          "description": "URL of the source image",
          "example": "https://example.com/photo.jpg"
        },
        "audio_url": {
          "type": "string",
          "description": "Optional audio URL",
          "example": "https://example.com/audio.mp3"
        },
        "duration": {
          "type": "integer",
          "description": "Duration in seconds",
          "minimum": 1,
          "maximum": 20,
          "default": 3,
          "example": 5
        },
        "prompt": {
          "type": "string",
          "description": "Generation prompt",
          "example": "Make this person smile and speak"
        },
        "negative_prompt": {
          "type": "string",
          "description": "Negative prompt to avoid unwanted features",
          "example": "blurry, distorted"
        },
        "minor_suspected_skip": {
          "type": "boolean",
          "default": false,
          "description": "Set to true when retrying after error code 1004 to confirm and bypass the suspected-minor soft block."
        }
      },
      "required": [
        "name",
        "image_url",
        "prompt",
        "negative_prompt"
      ]
    },
    {
      "$ref": "#/components/schemas/WebhookInput"
    }
  ]
}

Response Fields

code: integer
data: object
data._id: string
data.name: string
data.image_url: string
data.current_status: string
data.duration: number
data.coins: number
trace_id: string
Trace ID of this HTTP request. Include it when contacting support about this request. It is generated per request and is not a task identifier; use the returned task `_id` to query results.

Request Example

curl -X POST "https://headswap.app/api/v1/talkingPhoto/start" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "My Talking Photo",
  "image_url": "https://example.com/photo.jpg",
  "prompt": "Make this person smile and speak",
  "negative_prompt": "blurry, distorted"
}'

Related Endpoints

Responses

200

Talking photo task started successfully

400

Bad Request - Invalid parameters

401

Unauthorized - Invalid or missing bearer token

Talking Photo API Documentation