Discussions

Ask a Question
Back to All

v2 generate video with curl and python requests

hi, I am calling v2 generate video api, https://api.heygen.com/v2/video/generate

when I do curl with

{  
  "video_inputs": [  
    {  
      "character": {  
        "type": "talking_photo",  
        "talking_photo_id": "my_id",  
        "scale": 0.7,  
        "talking_photo_style": "circle"  
      },  
      "voice": {  
        "type": "text",  
        "input_text": "hello",  
        "voice_id": "my_voice_id"  
      }  
    }  
  ],  
  "test": true,  
  "caption": true,  
    "dimension": {  
    "width": 1080,  
    "height": 1920  
  }  
}

it will start generating no problem, however,

if I do the same thing with python requests as follows

import requests 
headers = {
    "accept": "application/json",
    "content-type": "application/json",
    "x-api-key": os.environ["HEYGEN_API_KEY"]
}
data = {
  ... # same with aboce
}
res = requests.request("POST", 
    url,
    headers=headers, 
    json=data)

I get validation error as

{'data': None, 'error': {'code': 'invalid_parameter', 'message': "type.video_inputs.0.character is invalid: unexpected value; permitted: 'avatar'"}}

what is the problem? I might be doing something stupid??