Skip to main content

Create Posts in Different Languages

In this example we will look at how to create posts in languages other than the default English using the Predis.ai API. The parameter output_language controls the language of the generated post. You can also set input_language parameter if you would be passing the text parameter in a different language.

We will set the value of output_language to spanish to generate the post in the Spanish language. Check out the API Reference to know more about the supported languages.

import requests

url = "https://brain.predis.ai/predis_api/v1/create_content/"

payload = {
"brand_id": "YOUR_BRAND_ID",
"text": "3 tips for a healthy morning breakfast",
"media_type": "video",
"video_duration": "long", # long signifies multi-scene videos
"template_ids": [], # pass template_ids if you want video in specific design
"output_language": "spanish",
"input_language": "english" # change it if your text param is in a different language
}

headers = {"Authorization": "YOUR_API_KEY"}

response = requests.request("POST", url, data=payload, headers=headers)

if response.status_code == 200:
json_response = response.json()
post_id = response.get("post_id")
post_status = response.get("status")

else:
print("Error occurred - {}".format(response.text))

If you get a inProgress status in response, your request is successful and the video is getting generated. Once the video gets generated successfully (or fails), you will get a request on your configured webhook URL with more details about the video.