{
  "openapi": "3.0.0",
  "info": {
    "title": "Digital Human",
    "version": "1.0.0",
    "description": "API reference for Digital Human on Ace Data Cloud."
  },
  "servers": [
    {
      "url": "https://api.acedata.cloud",
      "description": "Ace Data Cloud API"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "API token from https://platform.acedata.cloud"
      }
    },
    "schemas": {
      "DigitalHumanTaskResult": {
        "type": "object",
        "description": "Flat task result when action is omitted. Video or voice output fields appear when available.",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the task query succeeded."
          },
          "task_id": {
            "type": "string",
            "description": "Asynchronous task identifier."
          },
          "trace_id": {
            "type": "string",
            "description": "Request trace identifier.",
            "nullable": true
          },
          "state": {
            "type": "string",
            "description": "Current task state."
          },
          "progress": {
            "type": "number",
            "description": "Completion percentage from 0 to 100."
          },
          "video_url": {
            "type": "string",
            "description": "Generated video URL when available.",
            "format": "uri"
          },
          "duration": {
            "type": "number",
            "description": "Length of the generated video in seconds — not the task's processing time."
          },
          "width": {
            "type": "number",
            "description": "Generated video width in pixels."
          },
          "height": {
            "type": "number",
            "description": "Generated video height in pixels."
          },
          "engine": {
            "type": "string",
            "description": "Rendering engine selected for the task."
          },
          "voice_id": {
            "type": "string",
            "description": "Cloned voice ID when the voice task has completed."
          },
          "error": {
            "type": "string",
            "description": "Task failure detail when present."
          }
        },
        "example": {
          "success": true,
          "task_id": "task_...",
          "trace_id": "...",
          "state": "succeed",
          "progress": 100,
          "video_url": "https://cdn.acedata.cloud/634d760216.mp4",
          "duration": 17.2,
          "width": 1280,
          "height": 720,
          "engine": "latentsync"
        },
        "required": [
          "success",
          "task_id",
          "trace_id",
          "state",
          "progress"
        ]
      },
      "DigitalHumanDetailedTask": {
        "type": "object",
        "required": [
          "id",
          "status",
          "kind",
          "created_at",
          "started_at",
          "finished_at",
          "elapsed",
          "request",
          "response"
        ],
        "description": "Detailed task returned by retrieve and as each history item. Output URLs and voice IDs are nested in response.",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "number",
            "nullable": true,
            "description": "Creation Unix timestamp in seconds."
          },
          "started_at": {
            "type": "number",
            "nullable": true,
            "description": "Start Unix timestamp in seconds, null until claimed."
          },
          "finished_at": {
            "type": "number",
            "nullable": true,
            "description": "Completion Unix timestamp in seconds, null until finished."
          },
          "elapsed": {
            "type": "number",
            "nullable": true,
            "description": "Processing seconds, null until both timestamps exist."
          },
          "request": {
            "type": "object",
            "description": "Original public video or voice request parameters.",
            "additionalProperties": true
          },
          "response": {
            "$ref": "#/components/schemas/DigitalHumanTaskResult"
          }
        }
      },
      "DigitalHumanTaskHistory": {
        "type": "object",
        "required": [
          "count",
          "items"
        ],
        "description": "Recent tasks for the authenticated caller, newest first. This is a history listing, not a batch lookup by ID.",
        "properties": {
          "count": {
            "type": "integer",
            "minimum": 0
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DigitalHumanDetailedTask"
            }
          }
        }
      },
      "DigitalHumanDeletedTask": {
        "type": "object",
        "required": [
          "id",
          "deleted"
        ],
        "description": "Whether the requested task was deleted for the authenticated caller.",
        "properties": {
          "id": {
            "type": "string"
          },
          "deleted": {
            "type": "boolean"
          }
        }
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/digital-human/videos": {
      "post": {
        "summary": "Digital Human Videos",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "video_url": {
                    "type": "string",
                    "description": "Public URL of the source face video (preferred). Supply either video_url or image_url.",
                    "example": "https://cdn.acedata.cloud/634d760216.mp4"
                  },
                  "image_url": {
                    "type": "string",
                    "description": "Public URL of a source face photo (photo-driven path). Supply either video_url or image_url."
                  },
                  "audio_url": {
                    "type": "string",
                    "description": "Public URL of the driving audio (.wav/.mp3/.m4a). OR supply text(+voice_id)."
                  },
                  "text": {
                    "type": "string",
                    "description": "Spoken text -> TTS (requires voice_id).",
                    "example": "大家好，这是离线生成的数字人。"
                  },
                  "voice_id": {
                    "type": "string",
                    "description": "A cloned voice from POST /digital-human/voices."
                  },
                  "engine": {
                    "type": "string",
                    "enum": [
                      "latentsync",
                      "heygem"
                    ],
                    "default": "latentsync",
                    "deprecated": true,
                    "description": "[Deprecated] Accepted for backward compatibility but no longer changes the output or the price — every request is billed at the unified rate."
                  },
                  "guidance": {
                    "type": "number",
                    "default": 2.0,
                    "description": "Lip-sync strength (LatentSync). Lower loosens sync."
                  },
                  "steps": {
                    "type": "integer",
                    "default": 40,
                    "description": "Diffusion steps (LatentSync)."
                  },
                  "seam_fix": {
                    "type": "boolean",
                    "default": true,
                    "description": "Apply the mouth-seam reduction blend."
                  },
                  "speed": {
                    "type": "number",
                    "default": 1.0,
                    "description": "Audio tempo multiplier."
                  },
                  "resolution": {
                    "type": "string",
                    "enum": [
                      "720p",
                      "540p"
                    ],
                    "default": "720p",
                    "deprecated": true,
                    "description": "[Deprecated] Output is always rendered at 720p."
                  },
                  "callback_url": {
                    "type": "string",
                    "description": "Webhook; if set (or async=true) returns task_id immediately."
                  },
                  "async": {
                    "type": "boolean",
                    "default": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "example": {
                    "success": true,
                    "task_id": "0c0b4d3a-2f1e-4a6b-9c2d-2b3c4d5e6f70",
                    "trace_id": "a9063166-26ed-4451-85b5-54e896817c69",
                    "video_url": "https://cdn.acedata.cloud/634d760216.mp4",
                    "duration": 17.2,
                    "width": 1280,
                    "height": 720,
                    "engine": "latentsync",
                    "state": "succeed"
                  },
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "task_id": {
                      "type": "string"
                    },
                    "trace_id": {
                      "type": "string"
                    },
                    "video_url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "duration": {
                      "type": "number",
                      "format": "double"
                    },
                    "width": {
                      "type": "integer"
                    },
                    "height": {
                      "type": "integer"
                    },
                    "engine": {
                      "type": "string"
                    },
                    "state": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "example": {
                    "error": {
                      "code": "bad_request",
                      "message": "video_url or image_url is required"
                    },
                    "trace_id": "..."
                  },
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "example": {
                    "error": {
                      "code": "invalid_token",
                      "message": "The specified token is invalid or wrong."
                    },
                    "trace_id": "..."
                  },
                  "additionalProperties": true
                }
              }
            }
          },
          "403": {
            "description": "Balance",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "example": {
                    "error": {
                      "code": "used_up",
                      "message": "Your balance is not sufficient for current request."
                    },
                    "trace_id": "..."
                  },
                  "additionalProperties": true
                }
              }
            }
          },
          "429": {
            "description": "Rate limit",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "example": {
                    "error": {
                      "code": "too_many_requests",
                      "message": "You have exceeded the rate limit."
                    },
                    "trace_id": "..."
                  },
                  "additionalProperties": true
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "example": {
                    "error": {
                      "code": "api_error",
                      "message": "Internal server error."
                    },
                    "trace_id": "..."
                  },
                  "additionalProperties": true
                }
              }
            }
          }
        },
        "operationId": "createDigitalHumanVideos"
      }
    },
    "/digital-human/voices": {
      "post": {
        "summary": "Digital Human Voices",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "audio_url"
                ],
                "properties": {
                  "audio_url": {
                    "type": "string",
                    "description": "Public URL of a clean 10-20s voice sample.",
                    "example": "https://cdn1.suno.ai/ec13e502-d043-4eb2-92ee-e900c6da69d1.wav"
                  },
                  "lang": {
                    "type": "string",
                    "enum": [
                      "zh",
                      "en"
                    ],
                    "default": "zh"
                  },
                  "name": {
                    "type": "string",
                    "description": "Optional label."
                  },
                  "async": {
                    "type": "boolean",
                    "default": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "example": {
                    "success": true,
                    "task_id": "...",
                    "trace_id": "...",
                    "voice_id": "f754a190e26c",
                    "state": "succeed"
                  },
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "task_id": {
                      "type": "string"
                    },
                    "trace_id": {
                      "type": "string"
                    },
                    "voice_id": {
                      "type": "string"
                    },
                    "state": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "example": {
                    "error": {
                      "code": "bad_request",
                      "message": "audio_url is required"
                    },
                    "trace_id": "..."
                  },
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "example": {
                    "error": {
                      "code": "invalid_token",
                      "message": "The specified token is invalid or wrong."
                    },
                    "trace_id": "..."
                  },
                  "additionalProperties": true
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "example": {
                    "error": {
                      "code": "api_error",
                      "message": "voice clone (asr) failed"
                    },
                    "trace_id": "..."
                  },
                  "additionalProperties": true
                }
              }
            }
          }
        },
        "operationId": "createDigitalHumanVoices"
      }
    },
    "/digital-human/tasks": {
      "post": {
        "summary": "Digital Human Tasks",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "task_id": {
                    "type": "string",
                    "example": "task_49af42c410c24f04ad416b28af55d237",
                    "description": "One task identifier for flat polling, retrieve, or delete. Not an ID array. retrieve_batch ignores this field and lists recent history."
                  },
                  "action": {
                    "type": "string",
                    "enum": [
                      "retrieve",
                      "retrieve_batch",
                      "delete"
                    ],
                    "description": "Omit for a flat result, use retrieve for one detailed task, delete for one task, or retrieve_batch to list the authenticated caller's recent tasks. retrieve_batch does not query an array of IDs."
                  },
                  "id": {
                    "type": "string",
                    "description": "Alternative to task_id for a single retrieve or delete request."
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100,
                    "default": 20,
                    "description": "Maximum number of recent tasks for retrieve_batch."
                  },
                  "created_at_min": {
                    "type": "integer",
                    "description": "For retrieve_batch: only tasks created strictly after this Unix timestamp in seconds."
                  },
                  "created_at_max": {
                    "type": "integer",
                    "description": "For retrieve_batch: only tasks created strictly before this Unix timestamp in seconds."
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "videos",
                      "voices"
                    ],
                    "description": "Optional retrieve_batch history kind filter."
                  }
                },
                "anyOf": [
                  {
                    "required": [
                      "action"
                    ],
                    "properties": {
                      "action": {
                        "enum": [
                          "retrieve_batch"
                        ]
                      }
                    }
                  },
                  {
                    "required": [
                      "task_id"
                    ],
                    "properties": {
                      "action": {
                        "enum": [
                          "retrieve",
                          "delete"
                        ]
                      }
                    }
                  },
                  {
                    "required": [
                      "id"
                    ],
                    "properties": {
                      "action": {
                        "enum": [
                          "retrieve",
                          "delete"
                        ]
                      }
                    }
                  }
                ],
                "description": "Use one ID for polling, retrieve, or delete. Use action=retrieve_batch without an ID to list recent history. To retrieve a chosen set of IDs, send individual retrieve requests."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/DigitalHumanTaskResult"
                    },
                    {
                      "$ref": "#/components/schemas/DigitalHumanDetailedTask"
                    },
                    {
                      "$ref": "#/components/schemas/DigitalHumanTaskHistory"
                    },
                    {
                      "$ref": "#/components/schemas/DigitalHumanDeletedTask"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "example": {
                    "error": {
                      "code": "no_task",
                      "message": "task not found"
                    },
                    "trace_id": "..."
                  },
                  "additionalProperties": true
                }
              }
            }
          }
        },
        "operationId": "queryDigitalHumanTask"
      }
    }
  }
}
