Discussions

Ask a Question
Back to all

Subject: Assistance Needed with HeyGen API to Generate Video Using Uploaded Image and Audio

Dear HeyGen Support Team,My name is Carlos, and I’m developing an iOS app in SwiftUI (Xcode 16.0+, iOS 14+) that integrates with the HeyGen API to generate talking avatar videos, replicating the workflow of the HeyGen web portal (https://app.heygen.com/home, phone and video section). My goal is to allow users to upload an image and audio via the app’s UI, pass these to the HeyGen API, and generate a video with a custom avatar and voice, but I’m encountering issues with the API integration. I’d appreciate your guidance to ensure my app matches the portal’s functionality.


Problem
My current code (attached for reference) uses /v2/avatars/list and /v2/voices/list to fetch avatar_id and voice_id, then calls /v2/video/generate with a stock avatar_id (e.g., Daisy-inskirt-20220818) and voice_id, ignoring the uploaded image and audio from the UI. This results in videos with a generic avatar and stock voice, not the user-uploaded assets. I attempted to switch to /v1/asset and /v1/avatar/iv_video to use the uploaded image and audio, but I’m unsure if my implementation is correct, and the videos still don’t reflect the uploaded assets. Additionally, the /v1/video_status.get endpoint previously returned a 404 error, so I switched to /v1/video/status, but I need confirmation this is correct.

Console Logs (example, anonymized):
List Avatars Response Status: 200
List Avatars Response Body: {"avatars":[],"code":100,"message":"Success"}
List Voices Response Status: 200
List Voices Response Body: {"voices":[],"code":100,"message":"Success"}
Generate Response Status: 200
Generate Response Body: {"data":{"video_id":"abc123"},"code":100,"message":"Success"}
Poll 1 Status URL: https://api.heygen.com/v1/video/status?video_id=abc123
Status Response Status: 200
Status Response Body: {"data":{"status":"completed","video_url":"https://..."},"code":100,"message":"Success"}