Discussions

Ask a Question
Back to All

Response 500 from https://api.d-id.com/talks

I have tried to create a call but whenever I tried I get a 500 http error response.
I don´t know what I am doing wrong?

Please, see below the python code:

Thanks in advance

def generate_video(text):
    DID_API_KEY = os.getenv("DID_API_KEY") #tipo "user:password" generated in account-settings 

    if not DID_API_KEY:
       raise ValueError("DID_API_KEY no está configurada en las variables de entorno")

    url = "https://api.d-id.com/talks"
    headers = {
    "accept": "application/json",
    "content-type": "application/json",
    "authorization": f"Basic {DID_API_KEY}"
    }
    payload = {
        "source_url": "https://scenes-avatars.d-id.com/google-oauth2|108348274080833759746/avt_9u5te8JL0eEuTIG6uh8Yj/image.png",  # Reemplaza con la URL de la imagen del avatar
        "script": {
            "type": "text",          
      			"input": "Hola amigos!!!"}
        }
    try:
        response = requests.post(url, json=payload, headers=headers)
        response.raise_for_status()  # Esto lanzará una excepción para códigos de estado HTTP 4xx/5xx
        return response.json().get("result_url", "")
    except requests.exceptions.HTTPError as http_err:
        print(f"HTTP error occurred: {http_err}")  # Imprime el error HTTP
    except Exception as err:
        print(f"Other error occurred: {err}")  # Imprime cualquier otro error
    return None