Crea post in diverse lingue
In questo esempio vedremo come creare post in lingue diverse dall'inglese predefinito utilizzando il file Predis.ai API. Il parametro output_language controlla la lingua del post generato. Puoi anche impostare input_language parametro se si volesse passare il file text parametro in una lingua diversa.
Imposteremo il valore di output_language a spanish per generare il post in lingua spagnola. Dai un'occhiata a API Riferimento per saperne di più sulle lingue supportate.
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": "carousel",
"model_version": "4",
"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 = json_response.get("post_id")
post_status = json_response.get("status")
else:
print("Error occurred - {}".format(response.text))
Se ottieni un file inProgress status in response, your request is successful and the post is getting generated. Once the post gets generated successfully (or fails), you will get a request on your configured webhook URL with more details about the post.